:root {
    color-scheme: dark;
    --bg: #101314;
    --panel: #181c1d;
    --line: #292f30;
    --line-strong: #41494a;
    --text: #edf1ef;
    --muted: #adb7b4;
    --faint: #929e9a;
    --accent: #a5e2cb;
    --bar: #79b7ac;
    --bar-new: #a5e2cb;
    --warn: #e3c98f;
    --danger: #f0a39c;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 6px;
}

input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"]), select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    outline: none;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input:focus-visible, select:focus-visible { outline: none; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: middle; }
input::placeholder { color: var(--faint); }
input[type="file"] { font-size: 12px; }
input::file-selector-button {
    border: 0;
    border-radius: 4px;
    padding: 3px 8px;
    margin-right: 10px;
    background: var(--line);
    color: var(--text);
    cursor: pointer;
}
[hidden] { display: none !important; }
select option { background: var(--bg); color: var(--text); }

.hint { display: block; font-size: 11px; color: var(--faint); margin-top: 6px; line-height: 1.4; }
.form-group { margin-bottom: 20px; }

button.primary {
    padding: 10px 16px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #000;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
button.primary:hover { opacity: 0.9; }

.card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    background: var(--panel);
}
.card > h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: -0.1px;
    margin-bottom: 16px;
}

:root {
    --press-hover: none;
    --press-active: translateY(0) scale(0.99);
}

button, .clickable, a[href], select,
input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"]) {
    transition: transform 0.06s ease, opacity 0.12s ease,
                color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

button:hover, .clickable:hover, a[href]:hover, select:hover,
input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"]):hover {
    transform: var(--press-hover);
}

button:active, .clickable:active, a[href]:active, select:active,
input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"]):active {
    transform: var(--press-active);
}

select:focus,
input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"]):focus {
    transform: var(--press-hover);
}

button:disabled, input:disabled, select:disabled {
    transform: none;
    opacity: 0.5;
    cursor: not-allowed;
}
button:disabled:hover, button:disabled:active,
input:disabled:hover, input:disabled:active,
select:disabled:hover, select:disabled:active { transform: none; }

@media (prefers-reduced-motion: reduce) {
    :root { --press-hover: none; --press-active: none; }
    button, .clickable, a[href], select, input { transition: none; }
}

/* Base additions ------------------------------------------------------- */

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; line-height: 1.3; }
code, kbd { font-family: var(--mono); font-size: 12px; }
kbd {
    padding: 0 5px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    color: var(--muted);
}

select:focus,
input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"]):focus,
textarea:focus { border-color: var(--accent); }

textarea {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    line-height: 1.5;
    outline: none;
    resize: vertical;
    field-sizing: content;
    transition: border-color 0.12s ease;
}
textarea::placeholder { color: var(--faint); }
textarea:focus-visible { outline: none; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.warn-text { color: var(--warn); }
.nowrap { white-space: nowrap; }
.spaced { margin-top: 16px; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.code {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--faint);
    background: var(--line);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: 1px;
}

/* Buttons -------------------------------------------------------------- */

button.primary.block { width: 100%; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--line); text-decoration: none; }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }
.btn.primary:hover { opacity: 0.9; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: transparent; }

.linkish {
    background: none;
    border: 0;
    padding: 0;
    color: var(--faint);
    font: inherit;
    cursor: pointer;
}
.linkish:hover { color: var(--text); }

/* Layout --------------------------------------------------------------- */

.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--line); }
.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--faint);
    font-size: 13px;
}
.topbar-right strong { color: var(--text); font-weight: 500; }

.container { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }
.narrow { max-width: 520px; margin: 32px auto; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head p { margin-top: 4px; }
.eyebrow { font-size: 12px; color: var(--faint); margin-bottom: 2px; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    align-items: start;
    margin-bottom: 20px;
}
.grid > .card { margin-bottom: 0; }

.auth { max-width: 380px; margin: 48px auto; }
.auth h1 { margin-bottom: 6px; }
.auth-lead { margin-bottom: 24px; }

.flash {
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
}
.flash.error { border-left-color: var(--danger); }

.empty { color: var(--faint); padding: 8px 0; }
.card .table-wrap + .empty { padding-top: 16px; }

/* Tables --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--faint);
    padding: 0 12px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * + * { margin-left: 6px; }
td.actions form { display: inline; }
td.progress-cell { width: 30%; min-width: 140px; }
tr.inactive td:not(.actions) { opacity: 0.55; }

/* Small components ----------------------------------------------------- */

.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 8px;
    font-size: 11px;
    line-height: 18px;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    vertical-align: 1px;
}
.badge.accent { color: var(--accent); border-color: var(--bar); margin-left: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
    font-family: var(--mono);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--line);
    color: var(--muted);
}

.progress {
    display: flex;
    height: 6px;
    min-width: 100px;
    background: var(--line);
    border-radius: 3px;
    overflow: hidden;
}
.progress .done { background: var(--bar); transition: width 0.3s ease; }
.progress .review { background: var(--warn); transition: width 0.3s ease; }

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 8px;
    cursor: pointer;
}
.check .code { margin-left: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }

.copy-field { display: flex; gap: 6px; align-items: center; min-width: 300px; }
.copy-field input:not([type]) { padding: 5px 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); }

.lang-list { list-style: none; }
.lang-list li + li { border-top: 1px solid var(--line); }
.lang-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(100px, 220px) 80px;
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    color: var(--text);
}
.lang-row:hover { text-decoration: none; color: var(--accent); }
.lang-row .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Editor --------------------------------------------------------------- */

.lang-switch select { width: auto; min-width: 200px; }

.toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}
.toolbar input[type="search"] { flex: 1 1 240px; width: auto; padding: 8px 12px; }
.toolbar-progress { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.toolbar-progress .progress { width: 140px; }

.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
}
.segmented button {
    padding: 5px 10px;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--line); color: var(--text); }
.segmented .count { margin-left: 2px; color: var(--faint); font-variant-numeric: tabular-nums; }

.tip { margin: 12px 0 16px; font-size: 12px; color: var(--faint); }

.ph { font-family: var(--mono); font-size: 0.92em; color: var(--accent); }

.card.entries { padding-top: 0; padding-bottom: 0; }
.entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    padding: 20px 0;
    border-bottom: 1px solid var(--line);
    scroll-margin-top: 90px;
}
.entry:last-child { border-bottom: 0; }
.entry-key {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--faint);
    word-break: break-all;
}
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.entry[data-status="done"] .dot { background: var(--bar); }
.entry[data-status="outdated"] .dot { background: var(--warn); }
.entry-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-desc { margin-top: 6px; font-size: 12px; color: var(--faint); }

.entry-outdated {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--warn);
}
.entry-outdated q { color: var(--muted); white-space: pre-wrap; }

.entry-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 18px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--faint);
}
.entry-foot .linkish { margin-left: auto; font-size: 12px; white-space: nowrap; }
.problem { color: var(--danger); }
.entry-vars { margin-top: 8px; }
.entry textarea.invalid, .entry textarea.invalid:focus { border-color: var(--danger); }
.state.saving, .state.dirty { color: var(--muted); }
.state.ok { color: var(--accent); }
.state.error { color: var(--danger); }

/* Small screens -------------------------------------------------------- */

@media (max-width: 760px) {
    .entry { grid-template-columns: 1fr; gap: 10px; }
    .toolbar-progress { width: 100%; }
    .toolbar-progress .progress { flex: 1; }
}

@media (max-width: 640px) {
    .topbar-inner { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
    .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
    .container { padding: 20px 16px 64px; }
    .card { padding: 18px; }
    .grid { grid-template-columns: 1fr; }
    .lang-row { grid-template-columns: 1fr 60px; }
    .lang-row .progress { grid-column: 1 / -1; grid-row: 2; }
    .segmented { overflow-x: auto; max-width: 100%; }
}
