:root {
    color-scheme: light;
    --ink: #17211b;
    --muted: #647168;
    --forest: #245844;
    --forest-dark: #183e30;
    --sage: #dfe9df;
    --paper: #fbfaf5;
    --line: #d9dfd8;
    --danger: #9f2f2f;
    --shadow: 0 24px 70px rgba(32, 55, 43, .13);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 10%, rgba(164, 196, 169, .42), transparent 30rem),
        radial-gradient(circle at 92% 85%, rgba(224, 190, 128, .25), transparent 26rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, textarea { font: inherit; }

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 58px 0 26px;
}

.hero {
    display: flex;
    align-items: center;
    gap: 22px;
    max-width: 780px;
    margin-bottom: 30px;
}

.brand-mark {
    display: grid;
    flex: 0 0 68px;
    width: 68px;
    height: 68px;
    place-items: center;
    border-radius: 20px 6px 20px 6px;
    color: #fff;
    background: var(--forest);
    font-family: Georgia, serif;
    font-size: 25px;
    box-shadow: 8px 8px 0 var(--sage);
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--forest);
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.1rem, 5vw, 3.7rem);
    font-weight: 500;
    letter-spacing: -.035em;
    line-height: 1.02;
}

h1 span { color: #a26f2a; }
.intro { margin: 10px 0 0; color: var(--muted); line-height: 1.55; }

.comparison-controls {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.control-group {
    border: 1px solid rgba(36, 88, 68, .15);
    border-radius: 15px;
    padding: 14px;
    background: rgba(255, 255, 255, .76);
}

.control-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.control-heading span {
    color: var(--forest-dark);
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.control-heading small { color: var(--muted); font-size: .72rem; text-align: right; }

.segmented-control {
    display: grid;
    gap: 7px;
    padding: 5px;
    border-radius: 12px;
    background: #edf2ec;
}

.model-tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.direction-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.segment-button {
    min-height: 52px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 8px 10px;
    color: var(--muted);
    background: transparent;
    line-height: 1.25;
    transition: color .2s, background .2s, border-color .2s, box-shadow .2s;
}

.segment-button strong, .segment-button small { display: block; }
.segment-button strong { color: inherit; font-size: .82rem; }
.segment-button small { margin-top: 3px; font-size: .7rem; }
.segment-button:hover:not(.active) { color: var(--forest-dark); background: rgba(255,255,255,.55); }
.segment-button.active {
    border-color: #bfd0c3;
    color: var(--forest-dark);
    background: #fff;
    box-shadow: 0 4px 12px rgba(36, 88, 68, .09);
}

.evaluation-strip {
    display: grid;
    grid-template-columns: minmax(190px, 1.4fr) repeat(2, minmax(92px, .48fr)) minmax(200px, 1.35fr);
    align-items: center;
    gap: 18px;
    margin: 0 0 18px;
    border: 1px solid rgba(36, 88, 68, .15);
    border-radius: 15px;
    padding: 14px 18px;
    background: rgba(242, 247, 240, .82);
}

.evaluation-title span, .metric span {
    display: block;
    color: var(--forest-dark);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.evaluation-title small { color: var(--muted); font-size: .78rem; }
.metric { border-left: 1px solid #cad7cd; padding-left: 18px; }
.metric strong { display: block; margin-top: 2px; color: var(--forest); font-size: 1.45rem; line-height: 1; }
.evaluation-strip p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }

.sample-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 0 0 18px;
    border: 1px solid rgba(36, 88, 68, .15);
    border-radius: 15px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, .76);
}

.sample-heading span {
    display: block;
    color: var(--forest-dark);
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.sample-heading small { color: var(--muted); font-size: .75rem; }

.sample-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }

.sample-button {
    cursor: pointer;
    border: 1px solid #bfd0c3;
    border-radius: 9px;
    padding: 8px 11px;
    color: var(--forest-dark);
    background: #fff;
    font-size: .78rem;
    font-weight: 700;
    transition: color .2s, background .2s, transform .2s;
}

.sample-button:hover:not(:disabled) { color: #fff; background: var(--forest); transform: translateY(-1px); }
.sample-button:disabled { cursor: wait; opacity: .55; }

.translator-card {
    overflow: hidden;
    border: 1px solid rgba(36, 88, 68, .15);
    border-radius: 22px;
    background: rgba(255, 255, 255, .86);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

form { padding: 22px; }

.context-panel {
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f7f9f5;
}

.context-panel summary {
    display: flex;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    color: var(--forest-dark);
    font-weight: 700;
}

.context-panel summary small { color: var(--muted); font-weight: 500; }
.context-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 0 16px 16px; }

label span, .language-label {
    display: block;
    margin-bottom: 9px;
    color: var(--forest-dark);
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
}

textarea {
    width: 100%;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 13px 14px;
    color: var(--ink);
    background: #fff;
    line-height: 1.55;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

textarea:focus { border-color: #5f957b; box-shadow: 0 0 0 4px rgba(95, 149, 123, .14); }
.translation-grid { display: grid; grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr); align-items: stretch; }

.language-panel {
    position: relative;
    min-height: 285px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 15px;
}

.source-panel textarea { min-height: 205px; border: 0; padding: 4px 0 25px; font-size: 1.15rem; }
.source-panel textarea:focus { box-shadow: none; }
.output-panel { background: linear-gradient(145deg, #f1f6f0, #fafbf8); }
.output-heading { display: flex; align-items: start; justify-content: space-between; }
.direction { display: grid; place-items: center; color: #a26f2a; font-size: 1.65rem; }

.translation-output {
    margin: 29px 0 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.35rem, 2.2vw, 1.8rem);
    line-height: 1.55;
    white-space: pre-wrap;
}

.translation-output.placeholder { color: #879188; font-family: inherit; font-size: 1rem; }
.character-count { position: absolute; right: 20px; bottom: 16px; color: var(--muted); font-size: .76rem; }
.device-status { position: absolute; right: 20px; bottom: 16px; margin: 0; color: var(--muted); font-size: .76rem; }

.copy-button {
    cursor: pointer;
    border: 1px solid #bed0c4;
    border-radius: 999px;
    padding: 6px 12px;
    color: var(--forest-dark);
    background: #fff;
}

.translate-button {
    display: flex;
    min-width: 174px;
    min-height: 50px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0 0 auto;
    border: 0;
    border-radius: 12px;
    padding: 13px 24px;
    color: #fff;
    background: var(--forest);
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(36, 88, 68, .22);
    transition: transform .2s, background .2s;
}

.translate-button:hover:not(:disabled) { transform: translateY(-2px); background: var(--forest-dark); }
.translate-button:disabled { cursor: wait; opacity: .78; }
.spinner { display: none; width: 17px; height: 17px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.loading .spinner { display: block; }

.error-message { margin-top: 16px; border-radius: 10px; padding: 11px 13px; color: var(--danger); background: #fff0ef; }

.feedback-panel {
    padding: 24px 22px;
    border-top: 1px solid var(--line);
    background: #f4f7f1;
}

.feedback-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
}

.feedback-question h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.45rem;
    font-weight: 500;
}

.feedback-question p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); }
.feedback-actions, .feedback-form-actions { display: flex; align-items: center; gap: 10px; }
.feedback-form-actions { justify-content: flex-end; margin-top: 14px; }

.secondary-button, .text-button {
    cursor: pointer;
    border-radius: 10px;
    padding: 10px 15px;
    font-weight: 750;
}

.secondary-button { border: 1px solid var(--forest); color: #fff; background: var(--forest); }
.secondary-button:hover:not(:disabled) { background: var(--forest-dark); }
.secondary-button:disabled { cursor: wait; opacity: .7; }
.text-button { border: 1px solid transparent; color: var(--forest-dark); background: transparent; }
.text-button:hover { background: rgba(36, 88, 68, .08); }

.feedback-pair-preview {
    margin: 13px 0 0;
    border-left: 3px solid #9cba9f;
    padding: 8px 12px;
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.65;
}

.feedback-pair-preview strong { color: var(--ink); }
.feedback-status { margin: 0; color: var(--forest-dark); font-weight: 700; }
.feedback-status.error { color: var(--danger); }
footer { padding: 18px 8px 0; color: var(--muted); font-size: .78rem; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
    .page-shell { padding-top: 30px; }
    .hero { align-items: flex-start; }
    .brand-mark { flex-basis: 54px; width: 54px; height: 54px; }
    .comparison-controls, .context-grid, .translation-grid { grid-template-columns: 1fr; }
    .sample-panel { align-items: flex-start; flex-direction: column; }
    .sample-buttons { justify-content: flex-start; }
    .model-tabs { grid-template-columns: 1fr; }
    .control-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
    .control-heading small { text-align: left; }
    .evaluation-strip { grid-template-columns: 1fr 1fr; gap: 14px; }
    .evaluation-title, .evaluation-strip p { grid-column: 1 / -1; }
    .metric { border-left: 0; border-top: 1px solid #cad7cd; padding: 10px 0 0; }
    .direction { height: 42px; transform: rotate(90deg); }
    .context-panel summary { align-items: flex-start; flex-direction: column; gap: 4px; }
    .language-panel { min-height: 245px; }
    .feedback-question { align-items: flex-start; flex-direction: column; }
    .feedback-actions { width: 100%; flex-wrap: wrap; }
}
