/* ==========================================================================
   EE Translation Studio — design tokens + base components  (v2)
   Calm cream / gold / deep-teal system. Every text pair is WCAG AA (≥ 4.5:1);
   most are ≥ 7:1.  Drop this file into the Django static folder and link it
   BEFORE studio.css, then replace the old blue/pink/green/yellow rules with the
   classes below.  No JavaScript required (filters + menus use <details>).
   ========================================================================== */

:root {
  /* ---- Surfaces & lines (warm neutrals) -------------------------------- */
  --color-bg:            #f5efe6;   /* parchment fallback colour              */
  --color-surface:       #ffffff;   /* cards, nav, inputs                     */
  --color-surface-sunk:  #fbf8f2;   /* toolbar band, filter panel, source col */
  --color-line:          #e6ddcb;   /* hairlines, card borders                */
  --color-line-strong:   #cdbfa3;   /* input / pill borders                   */

  /* ---- Text ------------------------------------------------------------- */
  --color-text:          #2f2619;   /* 14.9:1 on white                        */
  --color-heading:       #2c2416;
  --color-text-muted:    #675a45;   /* 6.7:1 on white, 5.9:1 on cream         */

  /* ---- Primary (deep teal) & accent (library gold) ---------------------- */
  --color-primary:        #0f5a62;  /* 7.9:1 with white text                  */
  --color-primary-hover:  #0b484f;
  --color-primary-soft:   #e1eeee;  /* selected pill / hover tint             */
  --color-primary-fg:     #ffffff;
  --color-accent:         #c9a84c;  /* decoration only (rules, dots) — not text */
  --color-accent-text:    #85650f;  /* 5.4:1 on white — gold used as text     */
  --color-accent-soft:    #f7edcf;
  --color-focus:          #0f5a62;

  /* ---- Feedback --------------------------------------------------------- */
  --color-success:        #1f6b3a;
  --color-danger:         #8a1c1c;
  --color-ins-bg:         #d3f0d8;  --color-ins-fg: #14532d;   /* added   */
  --color-del-bg:         #fbdada;  --color-del-fg: #8a1c1c;   /* removed */

  /* ---- STAGES  (bg / fg / border) — fg-on-bg 6.9–8.2:1 ------------------ */
  --stage-unchanged-bg:     #efebe3;  --stage-unchanged-fg:     #544d40;  --stage-unchanged-border:     #d6cfc0;  /* warm grey  */
  --stage-ai-agreed-bg:     #e2efe5;  --stage-ai-agreed-fg:     #1f5236;  --stage-ai-agreed-border:     #b4d3bd;  /* sage       */
  --stage-question-bg:      #e3ecf6;  --stage-question-fg:      #234a73;  --stage-question-border:      #b5cae3;  /* slate blue */
  --stage-disputed-bg:      #fbe4de;  --stage-disputed-fg:      #8a2616;  --stage-disputed-border:      #eeb7ab;  /* clay red   */
  --stage-needs-review-bg:  #fbf0cf;  --stage-needs-review-fg:  #6b4c00;  --stage-needs-review-border:  #e6cf85;  /* amber      */
  --stage-decided-bg:       #d8edee;  --stage-decided-fg:       #0b4a50;  --stage-decided-border:       #9fcfd2;  /* deep teal  */
  --stage-new-bg:           #ebe5f5;  --stage-new-fg:           #4a3677;  --stage-new-border:           #c8bbe2;  /* soft plum  */

  /* ---- TYPES  (bg / fg / border) --------------------------------------- */
  --type-meaning-error-bg:  #f7e1ea;  --type-meaning-error-fg:  #7a1d4e;  --type-meaning-error-border:  #e4b4cb;  /* berry */
  --type-change-bg:         #efe7d3;  --type-change-fg:         #5a4513;  --type-change-border:         #d9c995;  /* sand  */
  --type-new-bg:            #ebe5f5;  --type-new-fg:            #4a3677;  --type-new-border:            #c8bbe2;  /* plum (same as New translation stage) */

  /* ---- Radii ------------------------------------------------------------ */
  --radius-xs: 4px;  --radius-sm: 8px;  --radius-md: 12px;  --radius-lg: 18px;  --radius-pill: 999px;

  /* ---- Shadows (warm, soft; never black) --------------------------------- */
  --shadow-xs: 0 1px 2px rgba(74, 56, 24, .06);
  --shadow-sm: 0 1px 2px rgba(74, 56, 24, .06), 0 2px 8px rgba(74, 56, 24, .06);
  --shadow-md: 0 2px 4px rgba(74, 56, 24, .05), 0 8px 24px rgba(74, 56, 24, .08);
  --shadow-lg: 0 4px 8px rgba(74, 56, 24, .06), 0 18px 44px rgba(74, 56, 24, .12);
  --shadow-focus: 0 0 0 3px rgba(15, 90, 98, .28);

  /* ---- Spacing scale (4 px base) ---------------------------------------- */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --page-max: 1180px;

  /* ---- Typography -------------------------------------------------------- */
  --font-serif: "Source Serif 4", "Source Serif Pro", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-ui:    "Inter", "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:  ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --text-xs: .75rem;  --text-sm: .8125rem;  --text-base: .9375rem;  --text-md: 1.0625rem;
  --text-book: 1.125rem;  --text-h3: 1.25rem;  --text-h2: 1.5rem;  --text-h1: 2rem;
  --leading-ui: 1.45;  --leading-book: 1.65;  --leading-tight: 1.2;

  /* ---- Backgrounds ------------------------------------------------------- */
  --bg-tile: url("parchment-tile.webp");
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--color-text); font: 400 var(--text-base)/var(--leading-ui) var(--font-ui);
  background-color: var(--color-bg);
}
/* Living parchment, CSS-only: the 5 KB tile + two very soft colour glows.
   Add class="bg-parchment" to <body>. (Alternative: the baked 1920×1080 image.) */
.bg-parchment {
  background-color: var(--color-bg);
  background-image:
    radial-gradient(60vw 70vh at 4% 0%,    rgba(255, 208, 140, .34), transparent 70%),
    radial-gradient(55vw 65vh at 100% 100%, rgba(184, 222, 198, .40), transparent 70%),
    radial-gradient(40vw 50vh at 100% 0%,   rgba(248, 200, 184, .20), transparent 70%),
    var(--bg-tile);
  background-attachment: fixed, fixed, fixed, scroll;
}
h1, h2, h3 { font-family: var(--font-serif); color: var(--color-heading); line-height: var(--leading-tight); margin: 0; font-weight: 600; letter-spacing: -.005em; }
h1 { font-size: var(--text-h1); } h2 { font-size: var(--text-h2); } h3 { font-size: var(--text-h3); }
a { color: var(--color-primary); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--color-primary-hover); }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-xs); }
.muted { color: var(--color-text-muted); }
.book-text { font-family: var(--font-serif); font-size: var(--text-book); line-height: var(--leading-book); }
.container { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--space-5); }
.container--wide { max-width: 1360px; }
.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-5); }
.cluster { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.eyebrow { font: 600 var(--text-xs)/1 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--color-text-muted); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer;
  font: 500 var(--text-base)/1 var(--font-ui); padding: 9px 16px; min-height: 38px;
  color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--color-line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs); text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--color-surface-sunk); border-color: #b9a982; }
.btn:focus-visible { box-shadow: var(--shadow-focus); }
.btn--primary { color: var(--color-primary-fg); background: var(--color-primary); border-color: var(--color-primary); }
.btn--primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: var(--color-primary-fg); }
.btn--quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--color-primary); }
.btn--quiet:hover { background: var(--color-primary-soft); border-color: transparent; }
.btn--sm { padding: 6px 12px; min-height: 32px; font-size: var(--text-sm); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ==========================================================================
   Form controls
   ========================================================================== */
.input, .select {
  font: 400 var(--text-base)/1.2 var(--font-ui); color: var(--color-text);
  background: var(--color-surface); border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm); padding: 8px 12px; min-height: 38px;
}
.input::placeholder { color: var(--color-text-muted); }
.input:focus, .select:focus { outline: none; border-color: var(--color-primary); box-shadow: var(--shadow-focus); }
.select { padding-right: 32px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #675a45 50%), linear-gradient(135deg, #675a45 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.select--sm, .input--sm { min-height: 32px; padding: 5px 30px 5px 10px; font-size: var(--text-sm); }
.field-label { display: block; font: 600 var(--text-xs)/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 6px; }

/* ==========================================================================
   Pills (filters) — neutral by default, tinted teal when active
   ========================================================================== */
.pill-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pill {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap;
  font: 500 var(--text-sm)/1 var(--font-ui); color: var(--color-text);
  padding: 7px 13px; min-height: 32px; text-decoration: none;
  background: var(--color-surface); border: 1px solid var(--color-line-strong); border-radius: var(--radius-pill);
  transition: background .15s, border-color .15s, color .15s;
}
.pill:hover { background: var(--color-surface-sunk); border-color: #b9a982; color: var(--color-text); }
.pill.is-active, .pill[aria-pressed="true"], .pill[aria-current="true"] {
  background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-primary);
  font-weight: 600; box-shadow: inset 0 0 0 .5px var(--color-primary);
}
.pill.is-active::after, .pill[aria-pressed="true"]::after { content: "✓"; font-size: .85em; margin-left: -1px; }
.pill__count { font-weight: 400; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.pill.is-active .pill__count { color: var(--color-primary); }
/* A small colour dot lets a pill carry its stage/type colour without turning loud */
.pill__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--color-line-strong)); box-shadow: 0 0 0 1px rgba(0,0,0,.12) inset; }
.pill--unchanged { --dot: var(--stage-unchanged-fg); }  .pill--ai-agreed { --dot: var(--stage-ai-agreed-fg); }
.pill--question { --dot: var(--stage-question-fg); }    .pill--disputed { --dot: var(--stage-disputed-fg); }
.pill--needs-review { --dot: var(--stage-needs-review-fg); } .pill--decided { --dot: var(--stage-decided-fg); }
.pill--new { --dot: var(--stage-new-fg); }              .pill--meaning-error { --dot: var(--type-meaning-error-fg); }
.pill--change { --dot: var(--type-change-fg); }

/* ==========================================================================
   Badges — read-only labels.  Always text + a shape glyph, never colour alone.
   Usage: <span class="badge badge--ai-agreed">AI-agreed</span>
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font: 600 var(--text-xs)/1 var(--font-ui); letter-spacing: .01em;
  padding: 4px 10px 4px 8px; border-radius: var(--radius-pill);
  background: var(--b-bg, var(--stage-unchanged-bg)); color: var(--b-fg, var(--stage-unchanged-fg));
  border: 1px solid var(--b-bd, var(--stage-unchanged-border));
}
.badge::before { content: var(--b-glyph, "○"); font-size: .9em; line-height: 1; }
.badge--neutral { --b-bg: var(--color-surface-sunk); --b-fg: var(--color-text-muted); --b-bd: var(--color-line); --b-glyph: ""; }
.badge--neutral::before { content: none; }
/* stages */
.badge--unchanged    { --b-bg: var(--stage-unchanged-bg);    --b-fg: var(--stage-unchanged-fg);    --b-bd: var(--stage-unchanged-border);    --b-glyph: "○"; }
.badge--ai-agreed    { --b-bg: var(--stage-ai-agreed-bg);    --b-fg: var(--stage-ai-agreed-fg);    --b-bd: var(--stage-ai-agreed-border);    --b-glyph: "●"; }
.badge--question     { --b-bg: var(--stage-question-bg);     --b-fg: var(--stage-question-fg);     --b-bd: var(--stage-question-border);     --b-glyph: "?"; }
.badge--disputed     { --b-bg: var(--stage-disputed-bg);     --b-fg: var(--stage-disputed-fg);     --b-bd: var(--stage-disputed-border);     --b-glyph: "▲"; }
.badge--needs-review { --b-bg: var(--stage-needs-review-bg); --b-fg: var(--stage-needs-review-fg); --b-bd: var(--stage-needs-review-border); --b-glyph: "◐"; }
.badge--decided      { --b-bg: var(--stage-decided-bg);      --b-fg: var(--stage-decided-fg);      --b-bd: var(--stage-decided-border);      --b-glyph: "✓"; }
.badge--new-translation { --b-bg: var(--stage-new-bg);       --b-fg: var(--stage-new-fg);          --b-bd: var(--stage-new-border);          --b-glyph: "✦"; }
/* types */
.badge--meaning-error { --b-bg: var(--type-meaning-error-bg); --b-fg: var(--type-meaning-error-fg); --b-bd: var(--type-meaning-error-border); --b-glyph: "◆"; }
.badge--change        { --b-bg: var(--type-change-bg);        --b-fg: var(--type-change-fg);        --b-bd: var(--type-change-border);        --b-glyph: "↻"; }
.badge--type-new      { --b-bg: var(--type-new-bg);           --b-fg: var(--type-new-fg);           --b-bd: var(--type-new-border);           --b-glyph: "✦"; }
.badge--lg { font-size: var(--text-sm); padding: 6px 12px 6px 10px; }

/* ==========================================================================
   Cards, toolbar, panels
   ========================================================================== */
.card {
  background: var(--color-surface); border: 1px solid var(--color-line);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: var(--space-5);
}
.card--flat { box-shadow: var(--shadow-xs); }
.card--raised { box-shadow: var(--shadow-lg); }
.card--sunk { background: var(--color-surface-sunk); box-shadow: var(--shadow-xs); }
.card__header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }

/* Summary toolbar: one calm line + the Filters toggle + the "More" menu */
.toolbar {
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  background: rgba(255,255,255,.72); backdrop-filter: blur(6px);
  border: 1px solid var(--color-line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); padding: var(--space-3) var(--space-4);
}
.toolbar__summary { font-size: var(--text-base); color: var(--color-text); }
.toolbar__summary strong { font-weight: 650; font-variant-numeric: tabular-nums; }
.toolbar__summary .sep { color: var(--color-line-strong); margin: 0 6px; }
.save-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: 500; color: var(--color-success); }
.save-status::before { content: "✓"; }
.save-status.is-saving { color: var(--stage-needs-review-fg); } .save-status.is-saving::before { content: "…"; }
.save-status.is-error { color: var(--color-danger); } .save-status.is-error::before { content: "!"; }

/* Collapsible Filters panel (<details class="filters">) */
.filters { background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.filters > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); font-weight: 600; border-radius: var(--radius-md);
}
.filters > summary::-webkit-details-marker { display: none; }
.filters > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--color-text-muted); border-bottom: 2px solid var(--color-text-muted); transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; }
.filters[open] > summary::before { transform: rotate(45deg); }
.filters > summary:hover { background: var(--color-surface-sunk); }
.filters__active { display: flex; flex-wrap: wrap; gap: 6px; font-weight: 400; }
.filters[open] .filters__active { display: none; }
.filters__body { border-top: 1px solid var(--color-line); padding: var(--space-5); display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5) var(--space-6); }
.filter-group__head { display: flex; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-2); }
.filter-group__head .eyebrow { margin: 0; }
.filter-group__help { margin-left: auto; font-size: var(--text-xs); }
.chip { display: inline-flex; gap: 4px; font-size: var(--text-xs); color: var(--color-text-muted); background: var(--color-surface-sunk); border: 1px solid var(--color-line); border-radius: var(--radius-pill); padding: 3px 9px; }
.chip b { color: var(--color-text); font-weight: 600; }

/* Dropdown menu (<details class="menu">) for secondary actions */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 250px;
  background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: var(--space-2);
}
.menu__item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); width: 100%; text-align: left;
  font: 400 var(--text-base)/1.3 var(--font-ui); color: var(--color-text); background: none; border: 0; border-radius: var(--radius-sm); padding: 9px 12px; cursor: pointer; text-decoration: none; }
.menu__item:hover { background: var(--color-primary-soft); color: var(--color-text); }
.menu__sep { height: 1px; background: var(--color-line); margin: var(--space-2) 4px; }
.switch { width: 32px; height: 18px; border-radius: 99px; background: #cfc6b3; position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: left .15s; }
.switch.is-on { background: var(--color-primary); } .switch.is-on::after { left: 16px; }

/* Top navigation */
.topnav { background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--color-line); box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 20; }
.topnav__inner { display: flex; align-items: center; gap: var(--space-4); padding-top: var(--space-3); padding-bottom: var(--space-3); }
.brand { white-space: nowrap; font: 600 1.15rem/1 var(--font-serif); color: var(--color-heading); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand::before { content: ""; width: 10px; height: 10px; border-radius: 50% 50% 50% 0; background: var(--color-accent); transform: rotate(-45deg); }
.nav-links { display: flex; gap: var(--space-1); }
.nav-link { white-space: nowrap; color: var(--color-text); text-decoration: none; font-weight: 500; font-size: var(--text-base); padding: 7px 12px; border-radius: var(--radius-sm); }
.nav-link:hover { background: var(--color-primary-soft); color: var(--color-primary); }
.nav-link[aria-current="page"] { color: var(--color-primary); background: var(--color-primary-soft); }
.searchbox { display: flex; gap: var(--space-2); }

/* Breadcrumb + page header */
.breadcrumb { font-size: var(--text-sm); color: var(--color-text-muted); display: flex; gap: 8px; align-items: center; }
.breadcrumb a { color: var(--color-text-muted); } .breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb .sep { color: var(--color-line-strong); }
.meta-grid { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-5) var(--space-7); align-items: start; }

/* Paragraph rows (source | translation) */
.para { display: grid; grid-template-columns: 1fr 1fr; background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-md); box-shadow: var(--shadow-md); overflow: hidden; }
.para__cell { padding: var(--space-5); }
.para__cell--src { background: var(--color-surface-sunk); border-right: 1px solid var(--color-line); }
.para__head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); flex-wrap: wrap; }
.para__num { font: 600 var(--text-xs)/1 var(--font-ui); color: var(--color-text-muted); letter-spacing: .06em; margin-right: auto; font-variant-numeric: tabular-nums; }
ins.diff-ins { text-decoration: none; background: var(--color-ins-bg); color: var(--color-ins-fg); border-radius: 3px; padding: 0 2px; box-shadow: inset 0 -2px 0 rgba(20,83,45,.5); }
del.diff-del { background: var(--color-del-bg); color: var(--color-del-fg); border-radius: 3px; padding: 0 2px; text-decoration: line-through; text-decoration-thickness: 2px; }
.legend-inline { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--color-text-muted); flex-wrap: wrap; }

@media (max-width: 820px) {
  .filters__body, .para, .meta-grid { grid-template-columns: 1fr; }
  .para__cell--src { border-right: 0; border-bottom: 1px solid var(--color-line); }
  .topnav__inner { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (prefers-contrast: more) { :root { --color-line: #b9a982; --color-text-muted: #4f4433; } }
