/* ============================================================
   MINGLI STUDIO — Japandi aesthetic
   Visual direction: Japanese-Scandinavian fusion · zen meets hygge
   Palette: warm linen · muted sage · dusty blue-steel · terracotta
   ============================================================ */

:root {
  /* Surfaces — warm, natural, never clinical white */
  --bg:           #f0ece5;
  --surface:      #faf8f4;
  --panel-bg:     #faf8f4;
  --panel-alt:    #f0ece5;
  --zone-input:   #e6ddd2;

  /* Borders — warm stone, not cool gray */
  --border:       rgba(110,88,66,0.13);
  --border-dim:   rgba(110,88,66,0.08);
  --border-hi:    rgba(110,88,66,0.24);

  /* Text — warm charcoal, warm brown-gray */
  --text-pri:     #1c1a18;
  --text-sec:     #6b6058;
  --text-dim:     #9e9488;

  /* Accents — muted, earthy, never neon */
  --green:        #4a7055;   /* muted sage */
  --green-dim:    #365440;
  --cyan:         #3d6080;   /* dusty blue-steel */
  --amber:        #9a6040;   /* warm terracotta */
  --amber-dim:    #6e4428;
  --magenta:      #7a4060;   /* dusty mauve */
  --red:          #8c3030;   /* muted red */
  --white:        #faf8f4;

  /* Fonts */
  --font:    "Courier New", "Lucida Console", Consolas, Monaco, monospace;
  --ui-font: system-ui, -apple-system, "SF Pro Display", "Helvetica Neue", sans-serif;

  /* Radius — unified to a single 5px corner on every box and button. The three
     names are kept so existing call sites need not change; all resolve to 5px. */
  --radius:    5px;
  --radius-sm:  5px;
  --radius-xs:  5px;

  /* Shadows — warm-tinted, soft depth */
  --shadow-card: 0 2px 8px rgba(110,88,66,0.08), 0 8px 28px rgba(110,88,66,0.05);
  --shadow-sm:   0 1px 3px rgba(110,88,66,0.07), 0 2px 8px rgba(110,88,66,0.04);

  /* Layout */
  --column-input: 420px;
  --w-input:  620px;
  --w-output: 1080px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; scrollbar-gutter: stable; }

body {
  background-color: var(--bg);
  color: var(--text-pri);
  font-family: var(--ui-font);
  font-size: 18px;
  line-height: 1.6;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  background: #1a1814;
  padding: 32px 32px 28px;
  flex-shrink: 0;
}

.header-inner {
  max-width: var(--w-output);
  margin: 0 auto;
  position: relative;
}

/* Language toggle aligned to the bottom-right of the header, level with the brand. */
.header-lang {
  position: absolute;
  bottom: 0;
  right: 0;
}
.header-lang .lang-toggle { margin-bottom: 0; }
@media (max-width: 640px) {
  .header-lang { position: static; margin-top: 14px; }
}

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.header-han {
  font-family: var(--ui-font);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -1px;
  color: #a8c890;
  line-height: 1;
}

.header-title {
  font-family: var(--ui-font);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.2px;
  color: rgba(250, 248, 244, 0.72);
  line-height: 1;
}

.header-sub {
  font-family: var(--ui-font);
  color: rgba(250, 248, 244, 0.30);
  font-size: 18px;
  letter-spacing: 0.2px;
}

/* ── Main workspace ─────────────────────────────────────── */
.workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ── Input zone ─────────────────────────────────────────── */
.input-zone {
  background: var(--zone-input);
  padding: 36px 24px 44px;
}

.zone-inner {
  max-width: var(--w-input);
  margin: 0 auto;
}

/* ── Form card ───────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-dim);
  padding: 32px 32px 28px;
  margin-bottom: 22px;
}

.form-card-hd { margin-bottom: 24px; }

.zone-eyebrow {
  font-family: var(--ui-font);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ── Form ────────────────────────────────────────────────── */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  /* Sole field row before the Analyze button (the fixed-locale field was removed),
     so it carries the spacing that separates the inputs from the button. */
  margin-bottom: 24px;
}

.field-group { margin-bottom: 0; }

.field-label {
  display: block;
  font-family: var(--ui-font);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--text-sec);
  margin-bottom: 7px;
}

.field-label-han {
  font-family: var(--font);
  font-size: 19px;
  color: var(--text-pri);
  margin-left: 4px;
  font-weight: normal;
}

.field-hint {
  font-family: var(--ui-font);
  font-size: 18px;
  color: var(--text-dim);
  margin-top: 5px;
}

.field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-pri);
  font-family: var(--font);
  font-size: 22px;
  padding: 11px 14px;
  outline: none;
  border-radius: var(--radius-xs);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.field-input:focus,
.field-input:focus-visible {
  border-color: rgba(61,96,128,0.5);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(61,96,128,0.10);
}

.field-input::placeholder { color: var(--text-dim); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-sec);
  font-family: var(--ui-font);
  font-size: 18px;
  font-weight: 400;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  line-height: 1.4;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.btn:hover {
  background: var(--bg);
  border-color: var(--border-hi);
  color: var(--text-pri);
}

.btn:focus,
.btn:focus-visible {
  outline: 2px solid rgba(61,96,128,0.35);
  outline-offset: 2px;
}

.btn:active { opacity: 0.75; }

/* Primary CTA — solid sage fill, white text.
   Two-class selector (.btn.btn-primary) beats the base .btn to ensure
   background/border/color are not overridden. */
.btn.btn-primary {
  width: 100%;
  padding: 14px 20px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: #3d7550;
  border: none;
  color: #ffffff;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px rgba(40,90,60,0.28);
  transition: background 0.18s, box-shadow 0.18s, opacity 0.15s;
}

.btn.btn-primary:hover {
  background: #2d5e3e;
  box-shadow: 0 5px 18px rgba(30,75,48,0.38);
  color: #ffffff;
  border: none;
}

.btn.btn-primary:focus,
.btn.btn-primary:focus-visible {
  outline: 2px solid rgba(74,112,85,0.40);
  outline-offset: 2px;
}

.btn.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

/* ── Samples (collapsible drawer) ────────────────────────── */
.samples-drawer {
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xs);
  background: var(--surface);
  margin-bottom: 8px;
}
.samples-summary {
  font-family: var(--ui-font);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
}
.samples-summary::-webkit-details-marker { display: none; }
.samples-summary::before { content: '▸ '; color: var(--text-dim); }
.samples-drawer[open] > .samples-summary::before { content: '▾ '; }
.samples-section { padding: 0 14px 12px; }

.samples-label {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.samples-note {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  margin-top: 8px;
}

.sample-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.btn-sample {
  font-family: var(--font);
  font-size: 18px;
  padding: 6px 14px;
  border-radius: var(--radius);
  letter-spacing: 0;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.btn-sample:hover {
  background: var(--surface);
  box-shadow: var(--shadow-card);
  border-color: var(--border-hi);
}

/* ── Skeleton loading placeholders ───────────────────────── */
@keyframes skel-shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}
.skel {
  display: block;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--border-dim) 0%, var(--border) 50%, var(--border-dim) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
}

/* ── Output zone ─────────────────────────────────────────── */
.output-zone {
  background: var(--bg);
  padding: 36px 24px 64px;
  flex: 1;
}

.output-zone-inner {
  max-width: var(--w-output);
  margin: 0 auto;
}

.output-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-dim);
}
.output-header:not(:has(.s-blocked, .s-error)) { display: none; }

/* ── Panel header label ──────────────────────────────────── */
.panel-header-label {
  font-family: var(--font);
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 2px;
}

.status-indicator {
  font-family: var(--font);
  font-size: 18px;
  letter-spacing: 1.5px;
  font-weight: bold;
}

/* ── Status badge ────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  font-family: var(--font);
  font-size: 18px;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid;
  margin-bottom: 20px;
  font-weight: bold;
}

.s-ready   { color: var(--green); border-color: rgba(74,112,85,0.35);  background: rgba(74,112,85,0.07); }
.s-blocked { color: var(--amber); border-color: rgba(154,96,64,0.35); background: rgba(154,96,64,0.07); }
.s-error   { color: var(--red);   border-color: rgba(140,48,48,0.35); background: rgba(140,48,48,0.07); }

/* ── Result sections — warm cream cards ─────────────────── */
.rsec {
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  border: 1px solid var(--border-dim);
}

.rsec-hd {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border-dim);
  padding: 10px 18px;
  font-family: var(--font);
  color: var(--text-sec);
  font-size: 20px;
  font-weight: normal;
  letter-spacing: 1px;
}

.rsec-bd { padding: 18px; }

/* ── Method info accordion ─────────────────────────────────── */
.method-info-toggle {
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  padding: 3px 9px;
  font: 600 12px/1.4 var(--ui-font);
  color: var(--text-sec);
  background: rgba(0,0,0,0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.method-info-toggle:hover {
  color: var(--text-pri);
  background: rgba(0,0,0,0.09);
  border-color: var(--border-hi);
}
.method-info-toggle[aria-expanded="true"] {
  color: var(--bg);
  background: var(--text-pri);
  border-color: var(--text-pri);
}
.method-info-toggle[aria-expanded="true"]:hover {
  background: var(--text-sec);
  border-color: var(--text-sec);
}
.method-info-panel {
  margin: 0;
  padding: 12px 14px;
  background: var(--panel-alt, var(--bg));
  border-bottom: 1px solid var(--border-dim);
  line-height: 1.6;
  font-size: 0.9em;
}
.method-info-panel[hidden] { display: none; }
.method-info-section + .method-info-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-dim);
}
.method-info-section-title {
  font: 700 0.78em/1.3 var(--ui-font);
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.method-info-section-body {
  color: var(--text-pri);
}

/* ── 五格 lookup numbers ─────────────────────────────────── */
/* Lookup numbers are traditional 81-number keys, not scores: the number is
   visually downplayed and the plain-language reading is the prominent element. */
.gk-helper {
  font-family: var(--ui-font);
  color: var(--text-sec);
  font-size: 18px;
  line-height: 1.5;
  margin-bottom: 6px;
}
.gk-helper-sub { color: var(--text-dim); font-size: 18px; margin-bottom: 12px; }

.gokaku-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.gk-cell {
  border: 1px solid var(--border-dim);
  background: var(--surface);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
  text-align: left;
}

.gk-cell-hd {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.gk-label {
  font-family: var(--ui-font);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}

/* Downplayed: small, muted, non-bold — deliberately not grade/score styling. */
.gk-lookup {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 400;
}

.gk-reading {
  font-family: var(--ui-font);
  color: var(--text-sec);
  font-size: 18px;
  line-height: 1.5;
  margin-top: 4px;
}
.gk-reading-unavail { color: var(--text-dim); font-style: italic; }

/* ── Traditional Lookup Readings (reader-first primary cards) ─ */
/* Up to 2 cards per row when there is horizontal space; 1 per row when narrow. */
.lr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }

.lr-card {
  border: 1px solid var(--border-dim);
  background: var(--surface);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
  text-align: left;
}
.lr-card-unavail { background: transparent; }

.lr-card-hd { display: flex; align-items: baseline; gap: 10px; }

.lr-gridname {
  font-family: var(--ui-font);
  color: var(--text-pri);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Downplayed: small, muted, non-bold — deliberately not grade/score styling. */
.lr-lookup {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 400;
}

/* Reader-first source/reference area above the lookup cards (Phase 51F).
   Short visible note + collapsed bibliographic details; secondary to the readings. */
.lookup-source-note {
  margin-top: 8px;
}
.lookup-source-details {
  margin-bottom: 14px;
}
.lookup-source-summary {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.lookup-source-summary::-webkit-details-marker { display: none; }
.lookup-source-summary::before {
  content: '▸';
  font-size: 18px;
  transition: transform 0.12s ease;
}
.lookup-source-details[open] .lookup-source-summary::before { transform: rotate(90deg); }
.lookup-source-summary:hover { color: var(--text-sec, var(--text)); }
.lookup-source-body {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1.6;
  margin-top: 6px;
  padding-left: 14px;
}

/* Readings layout (Phase 51K). Default (narrow): single column — the .rsec section
   box stacks above the AI reading (.lr-aside), which falls to the bottom after 總格. */
.lr-outer { display: block; }

/* Wide screens (≥1280px): float the AI reading OUTSIDE the section box. .lr-outer
   breaks out of the 720px output column (width tracks the available output area:
   viewport − input sidebar − paddings − scrollbar, capped at 1060px) so the section
   box keeps a comfortable width while the AI column sits in the space at its right.
   The aside is sticky, so it scrolls/docks with the reader until the section ends. */
@media (min-width: 1280px) {
  .lr-outer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 28px;
    align-items: start;
    width: min(1060px, calc(100vw - 520px));
  }
  .lr-outer > .rsec { margin-bottom: 0; }
  .lr-aside {
    position: sticky;
    top: 16px;
    align-self: start;
  }
  /* In the narrower right column, stack the robot above the bubble (full-width text)
     and drop the side tail, which would otherwise point at empty space. */
  .lr-aside .five-grid-reading-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
  }
  .lr-aside .five-grid-reading-robot { margin-top: 0; }
  .lr-aside .five-grid-reading { width: 100%; }
  .lr-aside .five-grid-reading::before,
  .lr-aside .five-grid-reading::after { display: none; }
}

/* Five-Grid Pattern Reading (五格格局解讀, Phase 51H): an AI-assisted summary that
   highlights the salient points of the five readings. Given deliberate visual
   weight: an abstract robot sits beside a speech bubble to signal that the summary
   is machine-generated. Still neutral — never styled like a score/verdict. */
.five-grid-reading-wrap {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 22px 0 18px;
}
/* Abstract line robot — sits to the left of the bubble, sage-green to match theme. */
.five-grid-reading-robot {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  margin-top: 6px;
  color: var(--green);
}
.five-grid-reading-robot svg {
  display: block;
  width: 100%;
  height: 100%;
}
/* Speech bubble — elevated and accented for importance, with a left-pointing tail
   aimed at the robot. */
.five-grid-reading {
  position: relative;
  flex: 1 1 auto;
  font-family: var(--ui-font);
  padding: 18px 20px;
  border: 1.5px solid var(--green);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f6f3ec 0%, var(--surface) 100%);
  box-shadow: 0 6px 18px rgba(54, 84, 64, 0.12);
}
/* Tail: a small triangle on the bubble's left edge pointing at the robot. The
   ::before is the border, the ::after the fill sitting 1.5px inside it. */
.five-grid-reading::before,
.five-grid-reading::after {
  content: "";
  position: absolute;
  top: 22px;
  width: 0;
  height: 0;
  border-style: solid;
}
.five-grid-reading::before {
  left: -11px;
  border-width: 9px 11px 9px 0;
  border-color: transparent var(--green) transparent transparent;
}
.five-grid-reading::after {
  left: -8px;
  border-width: 8px 10px 8px 0;
  border-color: transparent var(--surface) transparent transparent;
}
/* AI badge — small pill; uses rem so it stays under the 18px px-floor test. */
.five-grid-reading-tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--green-dim);
  background: rgba(74, 112, 85, 0.12);
  border: 1px solid rgba(74, 112, 85, 0.28);
  border-radius: var(--radius);
  padding: 2px 10px;
  margin-bottom: 10px;
}
.five-grid-reading-title {
  font-size: 21px;
  font-weight: 700;
  color: var(--green-dim);
  margin-bottom: 4px;
}
.five-grid-reading-pattern {
  font-size: 18px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 10px;
}
.five-grid-reading-body p {
  font-size: 18px;
  line-height: 1.65;
  color: var(--text-sec, var(--text));
  margin: 0 0 8px;
}
.five-grid-reading-body p:last-child { margin-bottom: 0; }
.five-grid-reading-note {
  margin-top: 10px;
  font-style: italic;
}
.five-grid-reading-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  padding: 2px 0;
}
.fgr-load-text { flex: 0 1 auto; }
/* "Thinking" indicator: three dots that bounce in sequence while the AI reading
   is being prepared — a more obvious cue than a static ellipsis. */
.fgr-dots {
  display: inline-flex;
  gap: 4px;
  flex: 0 0 auto;
}
.fgr-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: fgr-bounce 1.1s ease-in-out infinite both;
}
.fgr-dots i:nth-child(2) { animation-delay: 0.16s; }
.fgr-dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes fgr-bounce {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.45; }
  35% { transform: translateY(-5px); opacity: 1; }
}
/* Gentle pulse on the robot while the reading is loading. */
.five-grid-reading-wrap.is-loading .five-grid-reading-robot {
  animation: fgr-robot-pulse 1.6s ease-in-out infinite;
}
@keyframes fgr-robot-pulse {
  0%, 100% { opacity: 0.55; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}
/* A little personality: the robot blinks its eyes once every few seconds. The eyes
   squash to a line (scaleY) about their own centre, then pop back open. */
.five-grid-reading-robot .fgr-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: fgr-blink 5.4s ease-in-out infinite;
}
@keyframes fgr-blink {
  0%, 90%, 100% { transform: scaleY(1); }
  94% { transform: scaleY(0.1); }
  98% { transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
  .fgr-dots i,
  .five-grid-reading-robot .fgr-eye,
  .five-grid-reading-wrap.is-loading .five-grid-reading-robot { animation: none; }
}

/* Five-grid role helper (Phase 51E): what this grid generally represents.
   Visually secondary but readable — sits between the header and the reading. */
/* Role helper: clearly secondary to the reading — muted, italic, with a small
   accent rule so it reads as "what this grid is", distinct from the reading body. */
.lr-role {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-style: italic;
  font-size: 18px;
  line-height: 1.45;
  margin-top: 8px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
}

/* Actual source label, e.g. "From 《姓名學大奧義》（地之卷）, entry #26:" */
.lr-source {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  margin-top: 6px;
}

/* The number-specific reading is the prominent element — darker and a touch
   larger than the muted role helper so the two clearly differentiate. */
.lr-reading {
  font-family: var(--ui-font);
  color: var(--text-pri);
  font-size: 19px;
  line-height: 1.65;
  margin-top: 12px;
}
.lr-reading-unavail { color: var(--text-dim); font-style: italic; }

.lr-soft {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  margin-top: 4px;
}

.lr-guard {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  margin-top: 6px;
}

/* ── Right-column status box (idle / loading / status line) ─────────────────
   Name analyzed, 讀音 and 同音參考 now all render in the LEFT column, so this box
   only ever carries the #output states (idle welcome, loading, errors, status). */
.result-top:not(:empty) {
  background: var(--surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin-bottom: 22px;
}
/* Flatten the inner card so it merges into the shared box. */
.result-top > #output .rsec {
  margin-bottom: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
/* #output holds an always-present (often empty) div, so collapse the bordered box
   whenever none of its slots actually have content. */
.result-top:not(:has(> *:not(:empty))) { display: none; }

/* ── 讀音 + 同音參考 + 粵語讀音細節 in the left column (under the name readout) ──
   Pronunciation is a compact card; the sound-alike and Cantonese accordions carry
   their own card chrome (.reader-details) and just need matched spacing so the
   narrow input column keeps a consistent vertical rhythm. The Cantonese rows are
   flex-wrap (min-width 86px) and reflow into the column without overflow. */
.input-zone #pronunciation-output:not(:empty) {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  margin-bottom: 22px;
}
.input-zone #ziyi-output:not(:empty),
.input-zone #homophone-output:not(:empty),
.input-zone #cantonese-output:not(:empty) {
  display: block;
  margin-bottom: 22px;
}

/* ── Disclaimer / attribution small text ─────────────────────── */
.sec-disclaimer {
  font-family: var(--ui-font);
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
}

/* ── Global guardrail (Name analyzed section) ───────────────── */
.global-guardrail {
  display: block;
  font-family: var(--ui-font);
  color: var(--text-sec);
  margin-top: 10px;
}

/* ── Reader-first collapsible details (method/source/Cantonese) */
.reader-details {
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xs);
  background: var(--surface);
  margin-bottom: 8px;
}
.reader-details-sum {
  font-family: var(--ui-font);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
}
.reader-details-sum::-webkit-details-marker { display: none; }
.reader-details-sum::before { content: '▸ '; color: var(--text-dim); }
.reader-details[open] > .reader-details-sum::before { content: '▾ '; }
.reader-details-bd { padding: 0 14px 12px; }

.method-details { margin-top: 18px; }
.method-details-hd {
  font-family: var(--ui-font);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}
.method-details-sub {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  margin-bottom: 10px;
}
.homo-subtitle {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  margin-bottom: 8px;
}

/* ── Strokes row ─────────────────────────────────────────── */
.strokes-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stroke-chip {
  font-family: var(--font);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xs);
  padding: 5px 13px;
  background: var(--surface);
  font-size: 18px;
}

.stroke-char { color: var(--text-pri); margin-right: 5px; }
.stroke-num  { color: var(--cyan); }

/* ── Name readout (left-column confirmation) ─────────────────────────────
   After a successful analysis the analyzed name is confirmed under the input form
   in the left column. Compact card matched to the form-card aesthetic, with a green
   accent edge and surname/given pills sized for the narrow input column. */
.name-readout {
  background: var(--surface);
  border: 1px solid var(--border-dim);
  border-left: 3px solid var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 20px 20px;
  margin-bottom: 22px;
}
.name-readout-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--ui-font);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.name-readout-status-badge { display: inline-flex; align-items: center; gap: 5px; }
.name-readout-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.name-readout-status-label { font-size: 13px; font-weight: 600; color: var(--green); letter-spacing: 0; text-transform: none; }
.name-readout-name {
  font-family: var(--font);
  font-size: 30px;
  line-height: 1.2;
  color: var(--text-pri);
}
.name-readout-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.nr-part {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xs);
  padding: 5px 11px;
}
.nr-part-lbl { font-family: var(--ui-font); font-size: 18px; color: var(--text-dim); }
.nr-part-val { font-family: var(--font); font-size: 20px; color: var(--text-pri); }

/* ── Disclosures ─────────────────────────────────────────── */
.disc-list { list-style: none; }

.disc-item {
  font-family: var(--ui-font);
  border-left: 2px solid var(--border);
  padding: 6px 14px;
  margin-bottom: 7px;
  font-size: 18px;
  color: var(--text-sec);
}

.disc-item.w-warning { border-left-color: var(--amber); color: var(--amber); }
.disc-item.w-info    { border-left-color: var(--border); }

.disc-code {
  display: block;
  font-family: var(--font);
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 1px;
  margin-bottom: 3px;
}

/* ── Warnings ────────────────────────────────────────────── */
.warn-list { list-style: none; }

.warn-item {
  font-family: var(--ui-font);
  color: var(--amber);
  font-size: 18px;
  border-left: 2px solid var(--amber);
  padding: 6px 14px;
  margin-bottom: 6px;
  background: rgba(154,96,64,0.04);
}

/* ── Audit row ───────────────────────────────────────────── */
.audit-row { font-family: var(--font); color: var(--text-dim); font-size: 18px; line-height: 1.8; }

/* ── Disambiguation ──────────────────────────────────────── */
.disambig-prompt {
  font-family: var(--ui-font);
  color: var(--amber);
  font-size: 18px;
  border-left: 2px solid var(--amber);
  padding: 10px 14px;
  margin-bottom: 14px;
  background: rgba(154,96,64,0.05);
}
.disambig-prompt-label,
.block-msg-label {
  display: inline-block;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-right: 4px;
}

.disambig-char-hi {
  font-family: var(--font);
  font-size: 18px;
  font-weight: bold;
  color: var(--magenta);
}

.disambig-opts { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.disambig-opt {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  color: var(--text-pri);
  font-family: var(--ui-font);
  width: 100%;
  text-align: left;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s, border-color 0.18s, background 0.18s;
}

.disambig-opt:hover {
  border-color: rgba(154,96,64,0.45);
  background: rgba(154,96,64,0.04);
  box-shadow: var(--shadow-card);
}

.disambig-opt:focus,
.disambig-opt:focus-visible {
  outline: 2px solid rgba(154,96,64,0.35);
  outline-offset: 2px;
}

.dopt-char   { font-family: var(--font); font-size: 32px; color: var(--amber); min-width: 42px; }
.dopt-ks     { font-family: var(--font); color: var(--text-dim); font-size: 18px; letter-spacing: 0.5px; }
.dopt-note   { color: var(--text-sec); font-size: 18px; flex: 1; }

/* ── Block / error messages ──────────────────────────────── */
.block-msg {
  font-family: var(--ui-font);
  border: 1px solid rgba(140,48,48,0.20);
  border-radius: var(--radius-sm);
  background: rgba(140,48,48,0.04);
  padding: 16px 18px;
  color: var(--red);
  font-size: 18px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.block-char {
  font-family: var(--font);
  color: var(--magenta);
  font-size: 20px;
  font-weight: bold;
}

.block-detail { font-family: var(--ui-font); color: var(--text-sec); font-size: 18px; margin-top: 8px; }

/* ── Idle / loading ───────────────────────────────────────── */
.idle-msg {
  font-family: var(--font);
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 2px;
  padding: 40px 0;
}

.blink { animation: blink 1.1s step-end infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

.loading {
  font-family: var(--font);
  color: var(--cyan);
  font-size: 18px;
  letter-spacing: 3px;
  /* Renders inside the bordered top result box, so it needs horizontal inset too —
     otherwise the in-progress text hugs the top-left edge of the card border. */
  padding: 40px 22px;
}

/* ── Welcome panel ───────────────────────────────────────── */
/* Sits inside the bordered top result box, so it needs its own inset padding —
   otherwise the kicker/title hug the top-left edge of the card border. */
.welcome-panel {
  padding: 0 0 22px;
}

.welcome-hero {
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 20px;
}

.welcome-hero-img {
  display: block;
  width: 100%;
  height: auto;
}

.welcome-kicker,
.welcome-title,
.welcome-body,
.welcome-steps,
.welcome-note {
  padding-left: 22px;
  padding-right: 22px;
}

.welcome-kicker {
  font-family: var(--font);
  font-size: 18px;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.welcome-title {
  font-family: var(--ui-font);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-pri);
  letter-spacing: -0.2px;
  line-height: 1.25;
  margin-bottom: 14px;
}

.welcome-body {
  font-family: var(--ui-font);
  font-size: 18px;
  color: var(--text-sec);
  line-height: 1.7;
  margin-bottom: 32px;
  max-width: 480px;
}

.welcome-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.welcome-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.welcome-step-num {
  font-family: var(--ui-font);
  font-size: 18px;
  font-weight: 600;
  color: var(--green);
  background: rgba(74,112,85,0.10);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.welcome-step-text {
  font-family: var(--ui-font);
  font-size: 18px;
  color: var(--text-sec);
  line-height: 1.6;
  padding-top: 3px;
}

.welcome-note {
  font-family: var(--ui-font);
  font-size: 18px;
  color: var(--text-dim);
  border-left: 2px solid var(--border);
  padding: 4px 0 4px 14px;
  line-height: 1.6;
  max-width: 420px;
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border-dim);
  background: var(--panel-alt);
  padding: 12px 32px;
  flex-shrink: 0;
}

.footer-inner {
  max-width: var(--w-output);
  margin: 0 auto;
}

/* Plain-language footer note + creator credit (MVP statement). */
.footer-note {
  font-family: var(--ui-font);
  color: var(--text-sec);
  font-size: 18px;
  line-height: 1.6;
  text-align: center;
}
.footer-note a { color: var(--green); text-decoration: none; }
.footer-note a:hover { text-decoration: underline; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(110,88,66,0.15); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(110,88,66,0.28); }

/* ── Responsive: narrow/mobile (< 680px) ────────────────── */
@media (max-width: 679px) {
  .field-row { grid-template-columns: 1fr; }
  .header { padding: 24px 20px 18px; }
  .header-han { font-size: 32px; }
  .header-title { font-size: 20px; }
  .form-card { padding: 24px 20px 20px; }
  .input-zone { padding: 20px 16px 28px; }
  .output-zone { padding: 20px 16px 40px; }
}

/* ── Responsive: two-column wide layout (≥ 1024px) ──────── */
@media (min-width: 1024px) {
  .header-inner { max-width: none; }
  .header { padding: 32px 40px 28px; }

  .workspace {
    flex-direction: row;
    align-items: flex-start;
  }

  .input-zone {
    width: var(--column-input);
    flex-shrink: 0;
    padding: 32px 24px 40px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border-dim);
    border-bottom: none;
  }

  .input-zone .zone-inner {
    max-width: none;
    margin: 0;
  }

  .form-card {
    padding: 26px 24px 22px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
  }

  .input-zone .field-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .output-zone {
    flex: 1;
    min-width: 0;
    padding: 32px 40px 64px;
  }

  .output-zone-inner {
    max-width: 720px;
    margin: 0;
  }
}

/* ── Cantonese pronunciation panel ──────────────────────────────────────── */
/* Separator between 五格 output and Cantonese section; only visible when
   the element has content (loading, result, or error). */
#cantonese-output:not(:empty) {
  margin-top: 24px;
  padding-top: 4px;
  border-top: 1px solid var(--border-dim);
}

.canto-section-hd {
  color: var(--text-pri);
  font-size: 18px;
  letter-spacing: 0.3px;
  font-weight: 600;
  /* Match the other accordion summaries (.reader-details-sum 11px 14px) so the
     ▸ marker has the same left padding instead of sitting flush-left. */
  padding: 11px 14px;
}
/* Neutral role label clarifying the Cantonese sidecar vs the Pronunciation panel (Phase 50B). */
.canto-subtitle {
  color: var(--text-dim);
  line-height: 1.5;
  margin: -4px 0 10px;
}

/* Cantonese-specific status badge colours — cyan for ok (distinct from 五格
   green), amber for advisory warnings, red for service/error states. */
.s-canto-ok  { color: var(--cyan);  border-color: rgba(61,96,128,0.35);  background: rgba(61,96,128,0.06); }
.s-canto-warn{ color: var(--amber); border-color: rgba(154,96,64,0.35); background: rgba(154,96,64,0.06); }
.s-canto-err { color: var(--red);   border-color: rgba(140,48,48,0.35); background: rgba(140,48,48,0.06); }

/* ── Per-character reading blocks ─────────────────────────────────────── */
.canto-char-row { display: flex; flex-wrap: wrap; gap: 8px; }

.canto-char-block {
  border: 1px solid var(--border-dim);
  background: var(--surface);
  border-radius: var(--radius-xs);
  padding: 10px 13px;
  min-width: 86px;
}

.canto-char      { font-size: 26px; color: var(--text-pri); margin-bottom: 6px; }
.canto-reading   { font-size: 18px; margin: 2px 0; }
.canto-jyutping  { color: var(--cyan); }
.canto-tone      { color: var(--text-dim); font-size: 18px; margin-left: 4px; }
.canto-src-flag  { color: var(--text-dim); font-size: 18px; letter-spacing: 0.3px; margin-left: 4px; }
.canto-unknown   { color: var(--amber); font-size: 18px; }

/* ── Tone-pattern list ────────────────────────────────────────────────── */
.canto-pattern-list { list-style: none; }

.canto-pattern-item {
  font-size: 18px;
  border-left: 2px solid var(--border-dim);
  padding: 3px 10px;
  margin-bottom: 4px;
}

.canto-pjyut  { color: var(--cyan); }
.canto-ptones { color: var(--text-dim); font-size: 18px; margin-left: 8px; }
.canto-trunc  { color: var(--amber); font-size: 18px; margin-top: 5px; }

/* ── Attribution ──────────────────────────────────────────────────────── */
.canto-attr { margin-top: 8px; }

/* ── Multiple-reading notice ──────────────────────────────────────────── */
/* Advisory shown above JYUTPING_READINGS when any character has >1 reading. */
.canto-multi-notice {
  color: var(--text-sec);
  font-size: 18px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-dim);
}

/* Per-character hint shown below the selection buttons. */
.canto-multi-hint {
  color: var(--text-dim);
  font-size: 18px;
  margin-top: 5px;
}

/* ── Reading selection buttons ────────────────────────────────────────── */
.canto-reading-group { display: flex; flex-direction: column; gap: 4px; }

.canto-reading-opt {
  background: var(--surface);
  border: 1px solid var(--border-dim);
  color: var(--text-pri);
  font-family: var(--font);
  font-size: 18px;
  padding: 5px 10px;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.5;
  width: 100%;
  transition: border-color 0.18s, background 0.18s;
}

.canto-reading-opt:hover {
  border-color: rgba(61,96,128,0.40);
  background: rgba(61,96,128,0.04);
  color: var(--text-pri);
}

.canto-reading-opt:hover .canto-tone { color: var(--text-sec); }

.canto-reading-opt:focus,
.canto-reading-opt:focus-visible {
  outline: 2px solid rgba(61,96,128,0.30);
  outline-offset: 2px;
}

.canto-reading-selected {
  border-color: var(--cyan);
  background: rgba(61, 96, 128, 0.07);
  color: var(--cyan);
}

.canto-reading-selected .canto-tone { color: var(--cyan); opacity: 0.7; }

/* "source-weighted primary" advisory label inside a selection button. */
.canto-sel-src-primary {
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 0.3px;
  margin-left: 4px;
}

.canto-reading-selected .canto-sel-src-primary { color: var(--cyan); opacity: 0.55; }

/* ── Selected pronunciation summary ──────────────────────────────────── */
/* Shown when all characters have a resolved reading (selected or single). */
.canto-sel-summary {
  border: 1px solid var(--cyan);
  background: rgba(61, 96, 128, 0.05);
  border-radius: var(--radius-xs);
  padding: 11px 14px;
  margin-bottom: 14px;
}

/* Shown when at least one character is unknown — incomplete pronunciation. */
.canto-sel-partial {
  border: 1px solid var(--amber);
  background: rgba(154, 96, 64, 0.05);
  border-radius: var(--radius-xs);
  padding: 11px 14px;
  margin-bottom: 14px;
}

.canto-sel-hd {
  color: var(--cyan);
  font-size: 18px;
  letter-spacing: 2px;
  font-weight: bold;
  margin-bottom: 6px;
}

.canto-sel-partial .canto-sel-hd { color: var(--amber); }

.canto-sel-seq { margin-bottom: 4px; }

/* Advisory disclaimer below selected pronunciation. */
.canto-sel-note {
  color: var(--text-dim);
  font-size: 18px;
  margin-top: 6px;
}

/* Pending prompt — shown when multi-reading chars still need selection. */
.canto-sel-pending {
  color: var(--text-sec);
  font-size: 18px;
  padding: 6px 0;
  margin-bottom: 14px;
}

/* Preview-only note under the Cantonese badge. */
.canto-preview-note {
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 1px;
  margin: 2px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-dim);
}
/* Labels inside the selection summary (Selected Jyutping / tone pattern). */
.canto-sel-lbl {
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.canto-sel-seq > div { margin-bottom: 4px; }
/* Source provenance flags on a reading (e.g. Unihan-backed). */
.canto-src-unihan,
.canto-sel-src-unihan {
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 1px;
  margin-left: 4px;
}
.canto-unknown { color: var(--amber); font-size: 18px; letter-spacing: 1px; }
/* Selected reading button state. */
.canto-reading-selected {
  border-color: var(--cyan) !important;
  background: rgba(61, 96, 128, 0.08) !important;
  color: var(--text-pri) !important;
}
/* Non-blocking Cantonese error detail (advisory only). */
.canto-err-detail {
  color: var(--text-dim);
  font-size: 18px;
  margin-top: 4px;
  font-family: var(--font);
}

/* ── Language toggle ──────────────────────────────────────────────────────── */
.lang-toggle {
  display: inline-flex;
  gap: 0;
  margin-bottom: 12px;
  border: 1px solid rgba(250, 248, 244, 0.18);
  border-radius: var(--radius-sm, 8px);
  overflow: hidden;
  background: rgba(250, 248, 244, 0.04);
}
.lang-btn {
  padding: 6px 14px;
  font-size: 18px;
  line-height: 1.3;
  font-family: var(--ui-font, sans-serif);
  border: none;
  border-right: 1px solid rgba(250, 248, 244, 0.12);
  border-radius: 0;
  background: transparent;
  color: rgba(250, 248, 244, 0.62);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.lang-btn:last-child { border-right: none; }
.lang-btn:hover { background: rgba(250, 248, 244, 0.08); color: rgba(250, 248, 244, 0.92); }
.lang-btn-active,
.lang-btn-active:hover { background: var(--green); color: #f4f0eb; }

/* ── Title line inside interpretation grid ─────────────────────────────────── */
.interp-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-sec);
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

/* ── 81-number traditional interpretation panel (additive, fail-closed) ───── */
.interp-disclaimer {
  color: var(--amber);
  font-size: 18px;
  line-height: 1.5;
  border-left: 2px solid var(--amber);
  background: rgba(154, 96, 64, 0.05);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  padding: 7px 12px;
  margin-bottom: 12px;
}
.interp-overall {
  font-size: 18px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-pri);
}
.interp-overall-complete    { border-left: 3px solid var(--green); }
.interp-overall-partial     { border-left: 3px solid var(--amber); }
.interp-overall-unavailable { border-left: 3px solid var(--text-dim); color: var(--text-sec); }
.interp-overall-note {
  display: block;
  color: var(--text-dim);
  font-size: 18px;
  margin-top: 4px;
}

.interp-grids { display: flex; flex-direction: column; gap: 8px; }
.interp-grid {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 11px 14px;
}
.interp-grid.interp-unavail { opacity: 0.72; box-shadow: none; }
.interp-grid-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}
.interp-gname { color: var(--text-sec); font-size: 18px; letter-spacing: 1px; }
.interp-gnum  { color: var(--green); font-size: 18px; font-weight: bold; }
.interp-cat {
  margin-left: auto;
  font-size: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.interp-cat-auspicious,
.interp-cat-great_auspicious { color: var(--green); border-color: var(--green); background: rgba(74, 112, 85, 0.08); }
.interp-cat-inauspicious,
.interp-cat-great_inauspicious { color: var(--red); border-color: var(--red); background: rgba(140, 48, 48, 0.07); }
.interp-cat-mixed,
.interp-cat-caution { color: var(--amber); border-color: var(--amber); background: rgba(154, 96, 64, 0.07); }
.interp-cat-unavailable,
.interp-cat-unresolved { color: var(--text-dim); border-color: var(--border); }
.interp-summary { color: var(--text-pri); font-size: 18px; line-height: 1.55; }
.interp-reason  { color: var(--text-dim); font-size: 18px; }
.interp-soft {
  color: var(--amber-dim);
  font-size: 18px;
  margin-top: 5px;
}

/* ── 三才配置 panel (additive, default-off, fail-closed) ──────────────────── */
.sancai-subtitle { color: var(--text-sec); font-size: 18px; letter-spacing: 1px; margin-bottom: 8px; }
.sancai-elements { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sancai-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-xs);
  padding: 5px 10px;
  font-size: 18px;
  color: var(--text-pri);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}
.sancai-grid { color: var(--text-sec); font-size: 18px; letter-spacing: 1px; }
.sancai-rels { display: flex; flex-direction: column; gap: 6px; }
.sancai-rel {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}
.sancai-rel-pair { color: var(--text-sec); font-size: 18px; letter-spacing: 1px; }
.sancai-rel-type { color: var(--text-pri); font-size: 18px; margin-left: auto; }
.sancai-rel-note {
  color: var(--text-sec);
  font-size: 18px;
  line-height: 1.5;
  padding: 5px 10px 3px;
  border-left: 2px solid var(--border);
  margin: 0 0 2px 6px;
}
.sancai-note-tag {
  display: inline-block;
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-right: 6px;
}
.sancai-unavail { color: var(--text-dim); font-size: 18px; letter-spacing: 1px; }
.sancai-note { color: var(--text-dim); font-size: 18px; line-height: 1.5; margin-top: 8px; }

/* ── 三才配置 verdict badge (Phase 52A, flag-gated SANCAI_VERDICT_ENABLED) ── */
.sancai-verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
}
.sancai-verdict-lead { color: var(--text-sec); font-size: 18px; letter-spacing: 1px; }
.sancai-verdict-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.sancai-verdict-badge.g-da-ji   { color: #1a7f4b; background: #e7f6ec; border-color: #b6e3c6; }
.sancai-verdict-badge.g-ji      { color: #2f7d32; background: #eef7ee; border-color: #c7e6c8; }
.sancai-verdict-badge.g-ban-ji  { color: #8a6d1f; background: #faf4e3; border-color: #ead9a8; }
.sancai-verdict-badge.g-xiong   { color: #a8431f; background: #fbeee8; border-color: #ecc6b4; }
.sancai-verdict-badge.g-da-xiong{ color: #97231c; background: #fae9e7; border-color: #ecb9b4; }
.sancai-verdict-caveat {
  flex-basis: 100%;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1.5;
}

/* ── Dual pronunciation advisory panel (Phase 48G, default-off / inert) ──────── */
/* Only ever populated when the flag-gated endpoint returns enabled results; stays
   empty (no separator) by default. Advisory, subordinate styling — no judgment
   colors, no green/red coding. */
#pronunciation-output:not(:empty) {
  margin-top: 14px;
}
.pron-panel { color: var(--text-pri); }
/* 讀音 label: quiet, matches the sound-alike sub-header (no blue, no uppercase rule). */
.pron-hd {
  font-family: var(--ui-font);
  color: var(--text-dim);
  font-size: 18px;
  margin-bottom: 8px;
}
.pron-char-row { display: flex; flex-wrap: wrap; gap: 10px; }
.pron-char-block {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 11px 14px;
  min-width: 150px;
}
.pron-char { font-size: 22px; color: var(--text-pri); margin-bottom: 6px; }
.pron-lang { margin-top: 6px; }
.pron-lang-label {
  display: block;
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.pron-readings { display: flex; flex-wrap: wrap; gap: 6px; }
.pron-reading {
  color: var(--text-pri);
  font-size: 18px;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xs);
  padding: 2px 8px;
}
.pron-numeric { color: var(--text-dim); }
.pron-unavailable { color: var(--text-dim); font-size: 18px; }
.pron-multi-note { color: var(--text-sec); font-size: 18px; margin-top: 6px; }
.pron-disclaimer { color: var(--text-dim); font-size: 18px; line-height: 1.5; margin-top: 10px; }

@media (max-width: 679px) {
  .pron-char-block { min-width: 0; flex: 1 1 100%; }
}

/* ── Homophones advisory panel (Phase 49H-J, default-off / inert) ────────────── */
/* Only ever populated when the flag-gated endpoint returns enabled results; stays
   empty (no separator) by default. Advisory, subordinate styling — no judgment colors. */
#homophone-output:not(:empty) {
  margin-top: 24px;
  padding-top: 4px;
  border-top: 1px solid var(--border-dim);
}
.homo-panel { color: var(--text-pri); }
.homo-hd {
  color: var(--cyan);
  font-size: 18px;
  letter-spacing: 3px;
  font-weight: bold;
  text-transform: uppercase;
  padding: 0 0 10px;
}
.homo-char-row { display: flex; flex-wrap: wrap; gap: 10px; }
.homo-char-block {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 11px 14px;
  min-width: 170px;
}
.homo-char-hd { font-size: 22px; color: var(--text-pri); margin-bottom: 6px; }
.homo-lang { margin-top: 6px; }
.homo-lang-label {
  display: block;
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.homo-note { color: var(--text-sec); font-size: 18px; margin-bottom: 4px; }
.homo-group { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.homo-key { color: var(--text-dim); font-size: 18px; font-family: var(--font); }
.homo-chars { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.homo-char {
  color: var(--text-pri);
  font-size: 18px;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xs);
  padding: 1px 6px;
}
.homo-omitted { color: var(--text-dim); font-size: 18px; }
.homo-none { color: var(--text-dim); font-size: 18px; }
.homo-disclaimer { color: var(--text-dim); font-size: 18px; line-height: 1.5; margin-top: 10px; }

@media (max-width: 679px) {
  .homo-char-block { min-width: 0; flex: 1 1 100%; }
}

/* -- 字義 / Character Meaning reference panel (Phase 53K, default-off / inert) -- */
/* Only populated when CHARACTER_MEANING_ENABLED is on and entries exist.
   Left-column placement; stays empty (no separator) by default. */
#ziyi-output:not(:empty) {
  margin-top: 14px;
}
.ziyi-panel { color: var(--text-pri); }
.ziyi-subtitle { margin-top: 12px; }
.ziyi-char-row { display: flex; flex-wrap: wrap; gap: 10px; }
.ziyi-char-block {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 11px 14px;
  min-width: 170px;
  max-width: 320px;
}
.ziyi-char { font-size: 28px; color: var(--text-pri); margin-bottom: 6px; }
.ziyi-meaning { color: var(--text-pri); font-size: 18px; line-height: 1.6; }
.ziyi-src {
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1.5;
  margin-top: 6px;
}
.ziyi-src-label {
  color: var(--text-dim);
  font-size: 18px;
  letter-spacing: 0.5px;
}

@media (max-width: 679px) {
  .ziyi-char-block { min-width: 0; flex: 1 1 100%; max-width: none; }
}
