:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --ink: #17202a;
    --muted: #667085;
    --line: #d8dee9;
    --brand: #176b87;
    --brand-dark: #0d4f63;
    --warm: #f2a65a;
    --rose: #d45d79;
    --green: #3b8f69;
    --mark: #fff2b8;
    --shadow: 0 16px 40px rgba(23, 32, 42, 0.09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

.app-shell {
    width: 100%;
    padding: 24px;
}

.workspace {
    width: min(1440px, 100%);
    margin: 0 auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0;
}

h2 {
    margin-bottom: 0;
    font-size: 1rem;
}

h3 {
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--muted);
}

.score-stack {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 12px;
}

.score-card {
    min-width: 132px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.score-card span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.score-card strong {
    display: block;
    margin-top: 4px;
    color: var(--brand);
    font-size: 2rem;
}

.controls-panel {
    margin-bottom: 16px;
}

.control-grid {
    display: grid;
    grid-template-columns: 180px 180px 190px minmax(220px, 1fr);
    gap: 14px;
    align-items: end;
}

.control-grid label {
    display: grid;
    gap: 6px;
}

.control-grid span {
    color: var(--muted);
    font-size: 0.84rem;
}

.terms-field input {
    width: 100%;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    color: var(--ink);
}

.editor-grid,
.results-grid,
.comparison-grid,
.triple-grid,
.metric-grid,
.meter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.triple-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 16px;
}

.metric-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    margin-top: 16px;
}

.meter-grid {
    margin-top: 16px;
}

.metric {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric span,
.change-type {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 1.4rem;
}

.meter-panel .panel-head {
    margin-bottom: 14px;
}

.meter-panel strong {
    color: var(--brand);
    font-size: 1.4rem;
}

.meter-track {
    width: 100%;
    height: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #edf2f7;
}

.meter-fill {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: 999px;
    transition: width 180ms ease;
}

.human-fill {
    background: linear-gradient(90deg, var(--green), var(--brand));
}

.ai-fill {
    background: linear-gradient(90deg, var(--warm), var(--rose));
}

.results-grid {
    margin-top: 16px;
}

.panel {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    margin-bottom: 12px;
}

label {
    color: var(--muted);
    font-size: 0.84rem;
}

select,
button,
textarea {
    font: inherit;
}

select {
    min-width: 138px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
}

textarea {
    width: 100%;
    min-height: 330px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    color: var(--ink);
    line-height: 1.55;
}

textarea:focus,
select:focus,
input:focus,
button:focus {
    outline: 3px solid rgba(23, 107, 135, 0.2);
    outline-offset: 2px;
}

.button-row,
.icon-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button-row {
    margin-top: 12px;
}

.api-status {
    margin-top: 10px;
    min-height: 22px;
    color: var(--muted);
    font-size: 0.86rem;
}

.api-status.is-error {
    color: var(--rose);
}

.api-status.is-ok {
    color: var(--green);
}

button {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #edf2f7;
    color: var(--ink);
    cursor: pointer;
    padding: 0 16px;
    font-weight: 700;
}

button:hover {
    border-color: var(--brand);
}

button.primary {
    background: var(--brand);
    color: #ffffff;
    border-color: var(--brand);
}

button.primary:hover {
    background: var(--brand-dark);
}

.highlight-box,
.suggestion-list,
.text-view {
    min-height: 220px;
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfe;
    line-height: 1.6;
    white-space: pre-wrap;
}

.empty {
    color: var(--muted);
}

mark {
    border-radius: 4px;
    padding: 1px 3px;
    background: var(--mark);
    color: var(--ink);
}

.flag-formal {
    background: #d9ecff;
}

.flag-generic {
    background: #ffe1c2;
}

.flag-passive {
    background: #ffd7de;
}

.flag-repeat {
    background: #dff5e8;
}

.flag-evidence {
    background: #f8d7ff;
}

.flag-rhythm {
    background: #d7f1ff;
}

.flag-noun {
    background: #fce6bf;
}

.flag-hedge {
    background: #e4ddff;
}

.flag-cliche {
    background: #ffd6ec;
}

.flag-padding {
    background: #e6f4d7;
}

.suggestion {
    border-left: 4px solid var(--brand);
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #f6f9fc;
    border-radius: 6px;
}

.suggestion:nth-child(3n + 2) {
    border-left-color: var(--warm);
}

.suggestion:nth-child(3n) {
    border-left-color: var(--rose);
}

.suggestion strong {
    display: block;
    margin-bottom: 4px;
}

.suggestion p {
    margin-bottom: 0;
    color: var(--muted);
}

.review-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.review-actions button {
    min-height: 34px;
    padding: 0 12px;
}

.no-revert {
    align-self: center;
    color: var(--muted);
    font-size: 0.8rem;
}

.text-view ins {
    background: var(--mark);
    text-decoration: none;
}

.text-view del {
    background: #ffd7de;
    text-decoration: line-through;
}

.ghost-button {
    background: #ffffff;
}

.comparison-panel {
    margin-top: 16px;
}

@media (max-width: 860px) {
    .app-shell {
        padding: 14px;
    }

    .topbar,
    .editor-grid,
    .results-grid,
    .comparison-grid,
    .triple-grid,
    .metric-grid,
    .meter-grid,
    .control-grid,
    .score-stack {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
    }

    .score-card {
        width: 100%;
    }

    .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    textarea {
        min-height: 260px;
    }
}
