:root {
    --bg: #f5f1e8;
    --bg-accent: #efe2cf;
    --ink: #1f2421;
    --muted: #5f685f;
    --panel: rgba(255, 251, 245, 0.9);
    --line: rgba(31, 36, 33, 0.12);
    --brand: #b04a1a;
    --brand-dark: #8d3812;
    --teal: #235a52;
    --olive: #687057;
    --success: #2f6d49;
    --warning: #8a5c0f;
    --info: #355f86;
    --danger: #842d2d;
    --shadow: 0 18px 44px rgba(31, 36, 33, 0.12);
    --radius: 22px;
    --radius-sm: 14px;
    --font-sans: "Segoe UI Variable", "Trebuchet MS", "Gill Sans", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(176, 74, 26, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(35, 90, 82, 0.14), transparent 24%),
        linear-gradient(180deg, #fbf7f0 0%, var(--bg) 48%, #ece3d4 100%);
    min-height: 100vh;
}

a {
    color: var(--brand-dark);
}

.page-shell {
    width: min(1360px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 16px 20px 20px;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 8px);
    background: rgba(255, 250, 242, 0.8);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.brand {
    display: inline-block;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    font-weight: 800;
    text-decoration: none;
    color: var(--ink);
    letter-spacing: 0.01em;
}

.tagline {
    margin: 6px 0 0;
    color: var(--muted);
    max-width: 58ch;
}

.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.user-chip,
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    background: rgba(35, 90, 82, 0.12);
}

.content-shell {
    margin-top: 24px;
    display: grid;
    gap: 24px;
}

.flash-stack {
    margin-top: 18px;
    display: grid;
    gap: 10px;
}

.flash {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
}

.flash-success {
    background: rgba(47, 109, 73, 0.12);
    border-color: rgba(47, 109, 73, 0.2);
}

.flash-error {
    background: rgba(132, 45, 45, 0.12);
    border-color: rgba(132, 45, 45, 0.2);
}

.panel,
.project-card,
.file-card,
.glossary-card,
.unit-card,
.auth-panel,
.feature-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel,
.auth-panel,
.feature-panel {
    padding: 24px;
}

.accent-panel {
    background:
        linear-gradient(160deg, rgba(176, 74, 26, 0.08), rgba(35, 90, 82, 0.05)),
        var(--panel);
}

.panel-heading,
.project-card-head,
.file-card-head,
.unit-card-head,
.editor-hero,
.project-hero {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.panel-eyebrow,
.pane-label {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.76rem;
    font-weight: 800;
    color: var(--brand-dark);
}

h1,
h2,
h3 {
    margin: 8px 0 10px;
    line-height: 1.05;
}

h1 {
    font-size: clamp(2rem, 3.3vw, 3rem);
}

h2 {
    font-size: clamp(1.25rem, 2vw, 1.75rem);
}

h3 {
    font-size: 1.15rem;
}

p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.panel-copy,
.helper-line {
    margin-top: 8px;
}

.section-grid,
.toolbar-grid,
.auth-layout {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stack-form {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(31, 36, 33, 0.14);
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
}

textarea {
    min-height: 88px;
    resize: vertical;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    background: var(--brand);
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease;
}

button:hover,
.button-link:hover {
    transform: translateY(-1px);
    background: var(--brand-dark);
}

.secondary-button {
    background: rgba(35, 90, 82, 0.14);
    color: var(--teal);
}

.secondary-button:hover {
    background: rgba(35, 90, 82, 0.24);
}

.feature-list,
.sample-list {
    margin: 16px 0 0;
    padding-left: 20px;
    color: var(--ink);
    line-height: 1.6;
}

.project-grid,
.file-card-list,
.glossary-list,
.user-list {
    display: grid;
    gap: 18px;
}

.project-card,
.file-card,
.glossary-card {
    padding: 20px;
}

.metric-row,
.metric-strip {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.metric-row {
    margin-top: 16px;
}

.metric-strip {
    margin-top: -6px;
}

.metric-box {
    border-radius: 18px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(31, 36, 33, 0.08);
}

.metric-box strong {
    display: block;
    font-size: 1.55rem;
    color: var(--ink);
}

.metric-box span {
    color: var(--muted);
}

.text-link {
    font-weight: 800;
    text-decoration-thickness: 2px;
}

.empty-state-panel {
    padding: 28px;
    border-radius: var(--radius-sm);
    border: 1px dashed rgba(31, 36, 33, 0.18);
    background: rgba(255, 255, 255, 0.44);
}

.crumbs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-weight: 700;
    color: var(--muted);
}

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

.file-card-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.sticky-panel {
    position: sticky;
    top: 16px;
    align-self: start;
}

.unit-list {
    display: grid;
    gap: 18px;
}

.unit-list-summary,
.unit-list-loader {
    border-radius: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(31, 36, 33, 0.08);
    background: rgba(255, 255, 255, 0.68);
    color: var(--muted);
}

.unit-list-summary {
    display: flex;
    gap: 8px;
    align-items: baseline;
    flex-wrap: wrap;
}

.unit-list-summary strong {
    color: var(--ink);
    font-size: 1.1rem;
}

.unit-list-loader {
    text-align: center;
}

.unit-card {
    padding: 20px;
}

.unit-flags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.unit-flag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 0.84rem;
    font-weight: 700;
    background: rgba(104, 112, 87, 0.12);
    color: var(--olive);
}

.status-untranslated {
    border-color: rgba(138, 92, 15, 0.22);
}

.status-machine {
    border-color: rgba(53, 95, 134, 0.22);
}

.status-reviewed {
    border-color: rgba(47, 109, 73, 0.24);
}

.status-badge.status-untranslated {
    background: rgba(138, 92, 15, 0.12);
    color: var(--warning);
}

.status-badge.status-machine {
    background: rgba(53, 95, 134, 0.12);
    color: var(--info);
}

.status-badge.status-reviewed {
    background: rgba(47, 109, 73, 0.12);
    color: var(--success);
}

.unit-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.unit-path {
    font-size: 0.9rem;
    color: var(--muted);
}

.unit-stat {
    min-width: 82px;
    text-align: right;
}

.unit-stat strong {
    display: block;
    font-size: 1.3rem;
}

.preview-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    margin-top: 18px;
}

.qa-panel,
.reference-panel {
    margin-top: 16px;
    border-radius: 18px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(31, 36, 33, 0.08);
}

.qa-list {
    margin: 10px 0 0;
    padding-left: 20px;
    color: var(--warning);
}

.reference-image-preview {
    display: block;
    width: min(320px, 100%);
    max-height: 220px;
    object-fit: contain;
    margin-top: 12px;
    border-radius: 16px;
    border: 1px solid rgba(31, 36, 33, 0.1);
    background: rgba(239, 226, 207, 0.24);
}

.preview-pane {
    border-radius: 18px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(31, 36, 33, 0.08);
}

.rich-preview {
    margin-top: 10px;
    display: grid;
    gap: 8px;
    color: var(--ink);
}

.rich-preview p,
.rich-preview li,
.rich-preview div,
.rich-preview td,
.rich-preview th {
    color: var(--ink);
}

.rich-preview ul {
    padding-left: 20px;
    margin: 0;
}

.empty-preview {
    color: rgba(31, 36, 33, 0.45);
    font-style: italic;
}

.editor-panel {
    margin-top: 18px;
    border-radius: 18px;
    border: 1px solid rgba(31, 36, 33, 0.12);
    background: rgba(255, 255, 255, 0.48);
    overflow: hidden;
}

.editor-panel summary {
    cursor: pointer;
    padding: 14px 16px;
    font-weight: 800;
    list-style: none;
}

.editor-panel summary::-webkit-details-marker {
    display: none;
}

.segment-form {
    display: grid;
    gap: 14px;
    padding: 0 16px 16px;
}

.segment-editor {
    display: grid;
    gap: 8px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(31, 36, 33, 0.08);
}

.segment-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.segment-head span {
    color: var(--muted);
    font-size: 0.88rem;
}

.segment-source {
    font-size: 0.95rem;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(239, 226, 207, 0.42);
    color: var(--ink);
}

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

.glossary-inline-result {
    display: grid;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(35, 90, 82, 0.18);
    background: rgba(35, 90, 82, 0.08);
}

.glossary-inline-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.glossary-inline-text {
    color: var(--ink);
    white-space: pre-wrap;
    line-height: 1.5;
}

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

.compact-form {
    margin-top: 14px;
}

.translation-progress {
    margin-top: 8px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(31, 36, 33, 0.08);
    background: rgba(255, 255, 255, 0.72);
}

.translation-progress-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.translation-progress-bar {
    margin-top: 12px;
    height: 10px;
    border-radius: 999px;
    background: rgba(31, 36, 33, 0.08);
    overflow: hidden;
}

.translation-progress-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--brand), #d5843b, var(--teal));
    transition: width 0.24s ease;
}

.translation-progress-errors {
    margin-top: 12px;
    display: grid;
    gap: 6px;
    color: var(--danger);
    font-size: 0.92rem;
}

.unit-card.is-processing {
    box-shadow: 0 0 0 3px rgba(53, 95, 134, 0.18), var(--shadow);
}

.unit-card.has-error {
    border-color: rgba(132, 45, 45, 0.28);
}

.glossary-card-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.glossary-term-grid {
    display: grid;
    gap: 12px;
}

.glossary-row {
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(31, 36, 33, 0.08);
    background: rgba(255, 255, 255, 0.68);
}

.glossary-row textarea {
    min-height: 72px;
}

.danger-button {
    background: rgba(132, 45, 45, 0.12);
    color: var(--danger);
}

.danger-button:hover {
    background: rgba(132, 45, 45, 0.22);
}

label.checkbox-field {
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: 700;
}

label.checkbox-field input {
    width: auto;
    margin: 0;
}

.unit-quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

@media (max-width: 780px) {
    .page-shell {
        width: min(100% - 20px, 1360px);
        padding-top: 12px;
    }

    .topbar,
    .panel-heading,
    .project-card-head,
    .file-card-head,
    .unit-card-head,
    .editor-hero,
    .project-hero {
        flex-direction: column;
    }

    .unit-stat {
        text-align: left;
    }

    .sticky-panel {
        position: static;
    }

    .glossary-row {
        grid-template-columns: 1fr;
    }
}
