:root {
  --bg: #f3efe6;
  --bg-elev: rgba(255, 252, 247, 0.92);
  --ink: #1f1a17;
  --muted: #5f564e;
  --line: #e4dacb;
  --accent: #0e6b52;
  --accent-dark: #0a5340;
  --gold: #8d6230;
  --danger: #9f2d2d;
  --danger-bg: #fdecec;
  --shadow: 0 18px 40px rgba(64, 44, 22, 0.08);
  --radius: 18px;
  --font: "Outfit", "Segoe UI", sans-serif;
  --display: "Fraunces", "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 0% -10%, rgba(14, 107, 82, 0.12), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(141, 98, 48, 0.12), transparent 50%),
    var(--bg);
}

a { color: inherit; }

.wrap {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 8px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #f6f1e7;
  font-family: var(--display);
  font-weight: 650;
}

.brand-name {
  font-family: var(--display);
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.brand-domain {
  color: var(--muted);
  font-size: 0.82rem;
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
}

.nav a[aria-current="page"],
.nav a:hover {
  background: rgba(255, 252, 247, 0.8);
  color: var(--ink);
}

.hero { padding: 36px 0 12px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 650;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  letter-spacing: -0.04em;
  line-height: 0.98;
}

.lede {
  max-width: 38rem;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.6;
}

.search {
  position: relative;
  max-width: 36rem;
  margin-top: 22px;
}

.search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #8a8178;
}

.search input,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: 14px;
  font: inherit;
  outline: none;
}

.search input {
  padding: 14px 14px 14px 42px;
  box-shadow: var(--shadow);
}

.field textarea,
.field select,
.field input {
  padding: 12px 14px;
}

.field input[type="file"] {
  padding: 10px 12px;
  background: transparent;
}

.check-field label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.check-field input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.field textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
}

.search input:focus,
.field textarea:focus,
.field select:focus,
.field input:focus {
  border-color: #8fbfae;
  box-shadow: 0 0 0 4px rgba(14, 107, 82, 0.12);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 12px 0 28px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  padding: 22px;
  text-decoration: none;
  background: var(--bg-elev);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.tool-card:hover { transform: translateY(-3px); }

.tool-card-top,
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #efe6d6;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 600;
}

.tool-card h2,
.tool-card h3,
.panel h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  font-weight: 650;
}

.tool-card p,
.panel p,
.hint { color: var(--muted); line-height: 1.55; }

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.tool-page { padding-bottom: 28px; }

.back {
  display: inline-flex;
  margin: 18px 0;
  color: var(--muted);
  text-decoration: none;
}

.tool-heading h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
.tool-heading p { max-width: 40rem; }

.workspace {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.field { display: grid; gap: 8px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 0.92rem; }
.field-meta { color: #8a8178; font-size: 0.8rem; text-align: right; }

.button {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--accent);
  color: #f7f3ea;
  font: inherit;
  font-weight: 600;
}

.button:hover { background: var(--accent-dark); }
.button:disabled { opacity: 0.65; cursor: progress; }
.button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.button.secondary:hover { background: #f6f1e8; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.result-panel { min-height: 320px; }

.state {
  min-height: 260px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 8px;
  color: var(--muted);
}

.state strong { color: var(--ink); font-family: var(--display); font-size: 1.4rem; font-weight: 650; }

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(14, 107, 82, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  width: 100%;
  text-align: left;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 14px;
  padding: 14px 16px;
}

.result-image {
  width: 100%;
  border-radius: 14px;
  background: #ebe4d8;
  display: block;
}

.compare {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 14px;
  background: #ebe4d8;
}

.compare img {
  display: block;
  width: 100%;
  height: auto;
}

.compare .compare-after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compare input[type="range"] {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  width: calc(100% - 24px);
  margin: 0;
  accent-color: var(--accent);
}

.success { display: grid; gap: 12px; }

pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: 14px;
  background: #231e1b;
  color: #f6f1e8;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
  max-height: 480px;
}

.explanation {
  white-space: pre-wrap;
  margin: 0;
}

.site-footer {
  padding: 10px 0 32px;
  color: var(--muted);
  font-size: 0.92rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 10px;
}

.footer-nav a {
  color: var(--muted);
  text-decoration: none;
}

.footer-nav a:hover,
.footer-nav a[aria-current="page"] { color: var(--ink); }

.crumbs { padding-top: 18px; }
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.92rem;
}
.crumbs li:not(:last-child)::after { content: "/"; margin-left: 6px; }
.crumbs a { color: inherit; }

.category-block { padding-top: 8px; }
.category-block > h2,
.guide-block h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.03em;
  font-weight: 650;
}
.category-block > p,
.guide-block p,
.guide-block li { color: var(--muted); line-height: 1.65; }
.guide { display: grid; gap: 28px; padding: 8px 0 12px; }
.guide-block h3 {
  margin: 16px 0 4px;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}
.steps, .tips, .related { margin: 0; padding-left: 1.2rem; }
.related { list-style: none; padding-left: 0; display: grid; gap: 14px; }
.related h3 { margin: 0; font-size: 1.15rem; }
.related a { text-decoration: none; }
.related a:hover { text-decoration: underline; }
.related p { margin: 4px 0 0; }

@media (min-width: 800px) {
  .related { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 720px) {
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .panel { padding: 22px; }
}

@media (min-width: 1040px) {
  .tool-grid { grid-template-columns: 1fr 1fr 1fr; }
}

@media (min-width: 900px) {
  .workspace {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    align-items: start;
  }
  .result-panel { position: sticky; top: 16px; }
}

.nav {
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.nav a { white-space: nowrap; flex: none; }

.lang-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.lang-switch select {
  width: auto;
  min-width: 9.5rem;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
}

.prose {
  white-space: pre-wrap;
  line-height: 1.6;
  margin: 0;
}

.result-video {
  width: 100%;
  border-radius: 14px;
  background: #231e1b;
  max-height: 70vh;
}

html[lang="ja"] body,
html[lang="ko"] body {
  --font: "Noto Sans JP", "Noto Sans KR", "Outfit", sans-serif;
  --display: "Noto Sans JP", "Noto Sans KR", "Fraunces", serif;
}

html[lang="zh-Hans"] body {
  --font: "Noto Sans SC", "Outfit", sans-serif;
  --display: "Noto Sans SC", "Fraunces", serif;
}

.samples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 4px 0 12px;
}

.samples .sample { width: auto; }

.disclaimer {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.label {
  margin: 14px 0 4px;
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.token-canon {
  background: #e5f4ee;
  color: var(--accent-dark);
  border-radius: 4px;
}

.token-fan {
  background: #f6edd9;
  color: var(--gold);
  border-radius: 4px;
}

.token-catchphrase {
  background: #efe6d6;
  color: #6b4a22;
  border-radius: 4px;
}

.token-invented {
  color: var(--danger);
  border-bottom: 1px dotted var(--danger);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.glossary-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.glossary-list li {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--bg-elev);
}

.glossary-list h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.25rem;
}

.glossary-list p { margin: 0 0 6px; }

html[lang="zh-Hant"] body {
  --font: "Noto Sans TC", "Outfit", sans-serif;
  --display: "Noto Sans TC", "Fraunces", serif;
}

@media (max-width: 640px) {
  .wrap { width: min(1080px, calc(100% - 24px)); }
  .actions .button,
  .actions a.button { width: 100%; text-align: center; }
  .search input { box-shadow: none; }
  .site-header { align-items: flex-start; }
}
