:root {
    --ink: #1a2332;
    --ink-soft: #5a6577;
    --line: #dde2ea;
    --paper: #ffffff;
    --canvas: #f4f6f9;
    --accent: #1f5eff;
    --accent-ink: #ffffff;
    --accent-soft: #e8eeff;
    --ok: #157347;
    --ok-soft: #e2f3ea;
    --warn: #9a6a03;
    --warn-soft: #fdf3d8;
    --danger: #b42318;
    --danger-soft: #fbe9e7;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--canvas);
    line-height: 1.5;
}

h1 { font-size: 1.45rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
code { font-size: .85em; background: var(--canvas); padding: .1em .35em; border-radius: 4px; }
a { color: var(--accent); }
.muted { color: var(--ink-soft); }
.nowrap { white-space: nowrap; }

/* ---------- app shell ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 1.25rem;
    height: 56px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 650;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
}

.app-brand svg { width: 22px; height: 22px; color: var(--accent); }

.app-nav { display: flex; gap: .25rem; flex: 1; }

.app-nav a {
    padding: .35rem .7rem;
    border-radius: var(--radius);
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 500;
}

.app-nav a:hover { background: var(--canvas); color: var(--ink); }
.app-nav a.active { background: var(--accent-soft); color: var(--accent); }

.app-user { display: flex; align-items: center; gap: .75rem; }
.app-user-email { color: var(--ink-soft); font-size: .85rem; }
.app-user form { margin: 0; }

.app-main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* ---------- buttons & forms ---------- */
.btn {
    font: inherit;
    font-weight: 550;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: .45rem .9rem;
    cursor: pointer;
    background: var(--canvas);
    color: var(--ink);
    /* Several controls are links wearing a button (navigation that must survive
       without JS). The border already carries the affordance, so the underline
       only makes them look unlike the real buttons standing next to them. */
    text-decoration: none;
}

.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: #1a50d8; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--canvas); }
.btn-danger { color: var(--danger); }
.btn.btn-danger:not(.btn-ghost) { background: var(--danger); color: #fff; }
.btn-accept { background: var(--ok); color: #fff; }
.btn-accept:hover:not(:disabled) { background: #10603b; }

/* ---------- translator progress ---------- */
.progress-summary { margin: .4rem 0 .8rem; }
.progress-track {
    height: 6px;
    border-radius: 3px;
    background: var(--canvas);
    border: 1px solid var(--line);
    overflow: hidden;
    margin-bottom: .35rem;
}
.progress-fill { height: 100%; background: var(--ok); border-radius: 3px; }
.todo-chip { margin: -.4rem 0 .8rem; }
.acceptance-note { margin: .6rem 0; }
.acceptance-note .value-box { margin-top: .4rem; }
.btn-block { width: 100%; }

input[type="text"], input[type="search"], input[type="email"], input[type="password"], select, textarea {
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .45rem .6rem;
    width: 100%;
}

textarea { resize: vertical; }

input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.form-field { margin-bottom: .9rem; }
.form-field label { display: block; font-weight: 550; margin-bottom: .25rem; }
.field-hint { display: block; color: var(--ink-soft); font-size: .82rem; margin-top: .25rem; }
.field-warning { color: var(--warn); font-size: .85rem; margin: .35rem 0 0; }

.alert { border-radius: var(--radius); padding: .6rem .8rem; margin: .6rem 0; font-size: .9rem; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-info { background: var(--accent-soft); color: var(--ink); }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--canvas); margin: 0; }

.login-card {
    width: min(400px, calc(100vw - 2rem));
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 2rem;
}

.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand svg { width: 40px; height: 40px; color: var(--accent); }
.login-brand h1 { font-size: 1.25rem; margin: .5rem 0 .15rem; }
.login-brand p { margin: 0; color: var(--ink-soft); font-size: .9rem; }
.login-hint { font-size: .85rem; color: var(--ink-soft); text-align: center; margin-top: 1rem; }

/* ---------- dashboard ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    text-decoration: none;
    color: var(--ink);
    box-shadow: var(--shadow);
}

.stat-card:hover { border-color: var(--accent); }
.stat-lang { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .6rem; }
.lang-code {
    font-weight: 700;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 6px;
    padding: .1rem .45rem;
    font-size: .85rem;
}
.lang-name { font-weight: 600; }
.stat-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem; margin: 0; }
.stat-card dt { color: var(--ink-soft); font-size: .78rem; }
.stat-card dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-attention { color: var(--warn); }

/* ---------- filters ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: end;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .75rem;
    margin-bottom: 1rem;
}

.filter-bar label { font-size: .82rem; font-weight: 550; color: var(--ink-soft); display: grid; gap: .25rem; }
.filter-bar select, .filter-bar input { width: auto; min-width: 10rem; }
.filter-search { flex: 1; }
.filter-search input { width: 100%; min-width: 12rem; }
.result-count { margin: .25rem 0 .5rem; font-size: .85rem; }

/* ---------- strings table ---------- */
.strings-table {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.strings-head, .strings-row {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr .6fr .45fr;
    gap: .75rem;
    padding: .55rem .9rem;
    align-items: center;
}

.strings-head {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line);
    background: var(--canvas);
}

.strings-row { border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; min-height: 64px; }
.strings-row:last-child { border-bottom: none; }
.strings-row:hover { background: var(--accent-soft); }
.cell-en { color: var(--ink-soft); font-size: .88rem; }
.cell-value { font-size: .92rem; }
.cell-where { color: var(--ink-soft); font-size: .82rem; }

/* ---------- badges ---------- */
.badge {
    display: inline-block;
    font-size: .74rem;
    font-weight: 650;
    border-radius: 999px;
    padding: .12rem .55rem;
    white-space: nowrap;
}

.badge-compiled { background: var(--canvas); color: var(--ink-soft); }
.badge-overridden { background: var(--ok-soft); color: var(--ok); }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-missing { background: var(--danger-soft); color: var(--danger); }
.badge-accepted { background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe3cf; }

/* Not a warning and not work: quieter than "Original", because nobody is being
   asked to do anything about it. */
.badge-nosource { background: var(--canvas); color: var(--ink-soft); border: 1px dashed var(--line); }
.badge-action-proposed { background: var(--accent-soft); color: var(--accent); }
.badge-action-approved { background: var(--ok-soft); color: var(--ok); }
.badge-action-rejected, .badge-action-withdrawn { background: var(--canvas); color: var(--ink-soft); }
.badge-action-reverted { background: var(--danger-soft); color: var(--danger); }
.badge-action-accepted { background: var(--ok-soft); color: var(--ok); }

/* ---------- edit page ---------- */
.breadcrumbs { font-size: .85rem; color: var(--ink-soft); margin-bottom: .5rem; }
.breadcrumbs span { margin: 0 .3rem; }

.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }

.edit-main, .admin-section {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem;
    box-shadow: var(--shadow);
}

.admin-section { margin-bottom: 1.25rem; }

.value-block { margin-bottom: 1.25rem; }
.value-block:last-child { margin-bottom: 0; }

.value-box {
    background: var(--canvas);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .55rem .75rem;
    margin: .25rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.value-reference { border-left: 3px solid var(--accent); }
.value-origin { font-size: .83rem; color: var(--ink-soft); margin: .35rem 0 0; }

/* The mail as a client shows it: the header lines the recipient reads before
   the message, then the message. One card, so the subject is plainly part of
   the same mail and not a note about it. */
.mail-view {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    margin: .25rem 0;
    overflow: hidden;
}

.mail-view-head {
    display: flex;
    gap: .75rem;
    align-items: baseline;
    padding: .55rem .75rem;
    border-bottom: 1px solid var(--line);
    background: var(--canvas);
}

.mail-view-label {
    flex: none;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    padding-top: .1rem;
}

/* A <mark> by default paints itself; only the edited line is highlighted here,
   so the element starts neutral. */
.mail-view-value {
    font-weight: 600;
    word-break: break-word;
    background: none;
    color: inherit;
}

/* Same yellow as the run marker inside the mail (MailPreview.HighlightOpen),
   so "this text highlighted" means one thing wherever the text happens to
   live. Change one and change the other. */
.mail-view-value.is-edited {
    background: #fff3a3;
    box-shadow: 0 0 0 2px #f2c200;
    border-radius: 2px;
}

.mail-view-value.is-empty { font-weight: 400; font-style: italic; color: var(--ink-soft); }

/* Mail bodies are built for a 600px client column; the frame gives them that
   width and lets the mail scroll inside instead of stretching the panel. */
.mail-preview {
    display: block;
    width: 100%;
    height: 32rem;
    border: 0;
    background: #fff;
}

.action-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .75rem; }
/* Moving between strings is not one of the actions that writes, so the pair is
   pushed to the opposite end of the row -- and stays a pair when it wraps. */
.action-nav { display: inline-flex; gap: .6rem; margin-left: auto; }
.action-nav .btn { display: inline-flex; align-items: center; gap: .35rem; }
.action-nav svg { width: 16px; height: 16px; flex: none; }
.confirm-inline { display: inline-flex; gap: .5rem; align-items: center; font-size: .9rem; color: var(--danger); }

.context-panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 72px;
}

.context-panel h3 { display: flex; align-items: center; gap: .4rem; color: var(--ink-soft); text-transform: uppercase; font-size: .78rem; letter-spacing: .04em; }
.context-panel h3 svg { width: 16px; height: 16px; }
.context-panel dl { margin: 0; }
.context-panel dt { font-size: .78rem; color: var(--ink-soft); margin-top: .6rem; }
.context-panel dd { margin: .1rem 0 0; font-size: .9rem; word-break: break-word; }
.context-note { font-size: .83rem; color: var(--warn); background: var(--warn-soft); border-radius: var(--radius); padding: .5rem .65rem; margin: .75rem 0 0; }

.plain-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.plain-table th, .plain-table td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.plain-table th { color: var(--ink-soft); font-weight: 600; white-space: nowrap; }

/* ---------- review ---------- */
.review-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.review-blocked { opacity: .85; }
.review-card header { display: flex; flex-wrap: wrap; gap: .6rem; align-items: baseline; margin-bottom: .5rem; font-size: .9rem; }
.review-reference { font-size: .88rem; margin: .25rem 0 .5rem; }
.review-context { font-size: .83rem; margin: .5rem 0 0; }

.diff { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.diff-old, .diff-new { border-radius: var(--radius); padding: .55rem .7rem; border: 1px solid var(--line); }
.diff-old { background: var(--canvas); }
.diff-new { background: var(--ok-soft); border-color: #bfe3cf; }
.diff-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin-bottom: .2rem; }
.diff p { margin: 0; white-space: pre-wrap; word-break: break-word; }

.reject-row { display: flex; gap: .5rem; margin-top: .6rem; }
.reject-row input { flex: 1; }

/* ---------- history ---------- */
.history-table { width: 100%; border-collapse: collapse; font-size: .85rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.history-table th, .history-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.history-table th { background: var(--canvas); color: var(--ink-soft); font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }
.history-table code { display: block; }
.history-table .muted { display: block; font-size: .78rem; }
.history-comment { display: block; font-style: italic; color: var(--ink-soft); font-size: .8rem; }
.cell-diff { max-width: 220px; word-break: break-word; }

/* ---------- admin ---------- */
.assign-form { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .75rem; }
.assign-form input { flex: 2; min-width: 14rem; }
.assign-form select { flex: 1; min-width: 12rem; width: auto; }
.toggle-row { display: flex; gap: .5rem; align-items: center; font-weight: 550; }
.toggle-row input { width: auto; }

/* ---------- translator management ---------- */
.mode-toggle { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-bottom: .75rem; }
.mode-toggle label { display: flex; gap: .4rem; align-items: center; font-weight: 550; }
.mode-toggle input { width: auto; }
.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.lang-check { display: inline-flex; gap: .3rem; align-items: center; font-size: .85rem; border: 1px solid var(--line); border-radius: 999px; padding: .15rem .6rem; }
.lang-check input { width: auto; }
.lang-chip { display: inline-flex; gap: .25rem; align-items: center; font-size: .8rem; font-weight: 600; background: var(--canvas); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .3rem .1rem .55rem; }
.lang-chip button { border: 0; background: transparent; cursor: pointer; color: var(--ink-soft); font-size: .9rem; line-height: 1; padding: 0 .2rem; }
.lang-chip button:hover:not(:disabled) { color: var(--danger); }
.lang-add { width: auto; min-width: 3rem; font-size: .8rem; padding: .1rem .3rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) {
    .detail-grid { grid-template-columns: 1fr; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .edit-grid { grid-template-columns: 1fr; }
    .context-panel { position: static; }
    .strings-head, .strings-row { grid-template-columns: 1fr 1fr; }
    .cell-where { display: none; }
    .strings-head span:nth-child(3) { display: none; }
    .app-header { flex-wrap: wrap; height: auto; padding: .5rem 1rem; }
    .diff { grid-template-columns: 1fr; }
}

/* ---------- screen context viewer ---------- */
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ctx-viewer {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: .85rem 1rem; margin-bottom: 1.25rem;
}
.ctx-viewer-empty { padding: .5rem 1rem; }
.ctx-empty { margin: .25rem 0; font-size: .85rem; }
.ctx-header { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.ctx-header svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.ctx-header strong { font-size: .9rem; }
.ctx-screen-title { font-size: .85rem; color: var(--ink-soft); }
.ctx-route { font-size: .75rem; background: var(--canvas); border: 1px solid var(--line); border-radius: 4px; padding: .05rem .35rem; }
.ctx-chip {
    font-size: .7rem; font-weight: 650; letter-spacing: .02em; text-transform: uppercase;
    background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: .1rem .5rem;
}
.ctx-stage { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--canvas); }
.ctx-svg { display: block; width: 100%; height: auto; }
/* Light enough that the surrounding translations — the whole point of the
   preview — stay readable; the frame carries the "this one" signal. */
.ctx-dim { fill: rgba(15, 23, 42, .2); }
.ctx-frame {
    fill: none; stroke: var(--accent); stroke-width: 2.5px;
    paint-order: stroke;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, .9));
    animation: ctx-pulse 2.2s ease-in-out infinite;
}
@keyframes ctx-pulse {
    0%, 100% { stroke-opacity: 1; }
    50% { stroke-opacity: .45; }
}
@media (prefers-reduced-motion: reduce) {
    .ctx-frame { animation: none; }
}
.ctx-ghost-bg { fill: var(--paper); stroke: var(--accent); stroke-width: 2px; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.ctx-ghost-text {
    height: 100%; display: flex; align-items: center; padding: 0 4px;
    font-family: inherit; color: var(--ink); white-space: nowrap; overflow: visible;
}
.ctx-ghost.ctx-ghost-overflowing .ctx-ghost-bg { stroke: var(--danger); }
.ctx-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: .5rem; }
.ctx-toggle-label {
    font-size: .8rem; font-weight: 600; color: var(--accent); cursor: pointer;
    border: 1px solid var(--line); border-radius: 6px; padding: .25rem .6rem; background: var(--paper);
}
.ctx-toggle-label:hover { background: var(--accent-soft); }
.ctx-toggle-full:focus-visible ~ .ctx-controls label[for^="ctx-full"],
.ctx-toggle-ghost:focus-visible ~ .ctx-controls label[for^="ctx-ghost"] {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
.ctx-overflow-note { font-size: .8rem; color: var(--danger); font-weight: 600; }
.ctx-note { font-size: .8rem; color: var(--ink-soft); margin: .5rem 0 0; }
.ctx-alternatives { font-size: .8rem; margin: .5rem 0 0; }
.ctx-alternatives a { margin-right: .5rem; }

/* view switching: spotlight by default, whole screen when toggled */
.ctx-toggle-full:not(:checked) ~ .ctx-stage .ctx-svg-full { display: none; }
.ctx-toggle-full:checked ~ .ctx-stage .ctx-svg-spot { display: none; }
.ctx-toggle-full:not(:checked) ~ .ctx-controls .when-full { display: none; }
.ctx-toggle-full:checked ~ .ctx-controls .when-spot { display: none; }

/* ghost preview: on when its checkbox (rendered checked) is ticked */
.ctx-toggle-ghost:not(:checked) ~ .ctx-stage .ctx-ghost { display: none; }
.ctx-toggle-ghost:not(:checked) ~ .ctx-controls .when-ghost { display: none; }
.ctx-toggle-ghost:checked ~ .ctx-controls .when-no-ghost { display: none; }

/* compact variant for review cards */
.ctx-compact { padding: .6rem .75rem; margin-bottom: .75rem; }
.ctx-compact .ctx-header strong { display: none; }
.ctx-compact .ctx-svg { max-height: 240px; }
.ctx-compact .ctx-note, .ctx-compact .ctx-alternatives { margin-top: .35rem; }
