:root {
    --bg: #fbf9f7;
    --card: #ffffff;
    --soft: #faf8f5;
    --border: #efeae4;
    --border-soft: #f5f1ec;
    --text: #33302e;
    --muted: #787063;
    --accent: #e0558c;
    --accent-deep: #c13e72;
    --accent-soft: #fdf2f6;
    --ok: #12855f;
    --warn: #b97a10;
    --bad: #cf3a5a;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    background:
        radial-gradient(640px 420px at 8% -6%, rgba(236, 114, 182, .07), transparent 70%),
        radial-gradient(720px 460px at 96% 4%, rgba(196, 181, 253, .09), transparent 70%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
    letter-spacing: -0.005em;
}

/* the old animated blobs are retired — calm static wash instead */
.bg-scene { display: none; }

::selection { background: #fce7f1; }

.accent-grad {
    background: linear-gradient(90deg, var(--accent), #9d6bd8);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 26px 28px;
    box-shadow: 0 1px 2px rgba(35, 25, 20, .03);
}
.card-title { font-weight: 700; font-size: .98rem; letter-spacing: -.01em; margin-bottom: 14px; color: var(--text); }

.label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }

.input {
    width: 100%;
    background: var(--soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 11px 14px;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
    resize: vertical;
}
.input:focus { border-color: #f0b3cc; background: #fff; box-shadow: 0 0 0 3.5px rgba(224, 85, 140, .09); }

.link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; background: none; border: none; padding: 0; font: inherit; }
.link:hover { color: var(--accent-deep); }

/* header subtitle — calm gray, not opacity-hacked */
.header-sub { color: var(--muted); line-height: 1.6; }
#lang-select { font-size: .82rem; padding: 7px 10px; }

.btn-primary {
    background: var(--accent);
    color: white; font-weight: 700;
    border: none; border-radius: 14px;
    cursor: pointer;
    transition: transform .12s, background .15s, box-shadow .15s;
    box-shadow: 0 6px 18px rgba(224, 85, 140, .22);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-deep); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-secondary {
    background: #ffffff;
    border: 1px solid var(--border);
    color: #6b635a;
    border-radius: 12px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 600;
    transition: border-color .15s, color .15s, background .15s;
}
.btn-secondary:hover:not(:disabled) { border-color: #e6c3d2; color: var(--accent-deep); background: var(--accent-soft); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }

.drop-zone {
    border: 1.5px dashed #e3d5ce;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    font-size: .88rem;
    color: var(--muted);
    background: var(--soft);
    transition: border-color .15s, background .15s;
    cursor: pointer;
}
.drop-zone:hover, .drop-zone.drag { border-color: #ee9ec0; background: var(--accent-soft); }

/* Results */
.score-wrap { display: flex; gap: 30px; align-items: center; flex-wrap: wrap; }
.score-ring { position: relative; width: 130px; height: 130px; flex-shrink: 0; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .num {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.85rem; line-height: 1; color: var(--text);
}
.score-ring .num small { font-size: .62rem; font-weight: 600; color: var(--muted); margin-top: 4px; letter-spacing: .02em; }

.subscores { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; flex: 1; min-width: 250px; }
.subscore { background: var(--soft); border: 1px solid var(--border-soft); border-radius: 14px; padding: 12px; }
.subscore .bar { height: 5px; border-radius: 999px; background: #eee8e2; margin-top: 8px; overflow: hidden; }
.subscore .bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ee9ec0, var(--accent)); }

table.kw { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.kw th { text-align: start; color: #a89f92; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.kw td { padding: 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
table.kw tr:last-child td { border-bottom: none; }
table.kw tr { transition: background .12s; }
table.kw tbody tr:hover { background: #fdfbf9; }

.chip { display: inline-block; font-size: .68rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.chip.found { background: #eefaf3; color: var(--ok); border: 1px solid #cdeedb; }
.chip.partial { background: #fdf7e9; color: var(--warn); border: 1px solid #f3e4bd; }
.chip.missing { background: #fdf0f2; color: var(--bad); border: 1px solid #f6d3da; }
.chip.must { background: #fdf0f2; color: var(--bad); border: 1px solid #f6d3da; }
.chip.nice { background: #f6f4f1; color: #7d746a; border: 1px solid #eae5df; }

.verdict { font-weight: 700; padding: 5px 15px; border-radius: 999px; font-size: .84rem; }
.verdict.strong { background: #eefaf3; color: var(--ok); border: 1px solid #cdeedb; }
.verdict.possible { background: #fdf7e9; color: var(--warn); border: 1px solid #f3e4bd; }
.verdict.weak { background: #fdf0f2; color: var(--bad); border: 1px solid #f6d3da; }

.item-card { background: var(--soft); border: 1px solid var(--border-soft); border-radius: 16px; padding: 16px; }
.item-card .why { color: var(--muted); font-size: .84rem; margin-top: 5px; line-height: 1.55; }
.item-card .example { margin-top: 10px; padding: 10px 14px; border-left: 3px solid #ee9ec0; background: var(--accent-soft); border-radius: 0 10px 10px 0; font-size: .84rem; }
.badge-count { display: inline-flex; align-items: center; justify-content: center; min-width: 25px; height: 25px; border-radius: 999px; font-weight: 700; font-size: .76rem; background: #f6f4f1; color: #7d746a; }

/* ---- typed result sections (summary / add / improve / remove) ---- */
.sum-text { font-size: .95rem; line-height: 1.75; color: var(--text); background: var(--soft); border-inline-start: 3px solid var(--accent); padding: 13px 16px; border-radius: 4px 12px 12px 4px; }
[dir="rtl"] .sum-text { border-radius: 12px 4px 4px 12px; }

.sec-card.add { border-top: 3px solid #a8dfc4; }
.sec-card.improve { border-top: 3px solid #f0dda8; }
.sec-card.remove { border-top: 3px solid #f4c3ce; }

.sec-items { display: grid; gap: 10px; }
.sec-item { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; background: var(--soft); border: 1px solid var(--border-soft); border-radius: 14px; }
.num-chip { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 800; margin-top: 1px; }
.sec-body { flex: 1; min-width: 0; }
.sec-head { font-weight: 600; line-height: 1.45; }
.sec-why { color: var(--muted); font-size: .85rem; margin-top: 4px; line-height: 1.6; }
.sec-item .example { margin-top: 9px; padding: 9px 13px; border-inline-start: 3px solid #ee9ec0; background: var(--accent-soft); border-radius: 4px 10px 10px 4px; font-size: .84rem; }
[dir="rtl"] .sec-item .example { border-radius: 10px 4px 4px 10px; }

/* before → after mini diff inside improve items */
.diff { margin-top: 10px; display: grid; gap: 6px; }
.diff-row { display: flex; gap: 9px; align-items: flex-start; font-size: .84rem; }
.diff-label { flex-shrink: 0; font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 3px 9px; border-radius: 999px; margin-top: 1px; }
.diff-row.before .diff-label { background: #fdf7e9; color: var(--warn); }
.diff-row.after .diff-label { background: #eefaf3; color: var(--ok); }
.diff-text { line-height: 1.55; min-width: 0; overflow-wrap: break-word; }
.diff-row.before .diff-text { color: var(--muted); text-decoration: line-through; text-decoration-color: #d9c9a8; text-decoration-thickness: 1.5px; }
.diff-row.after .diff-text { color: var(--text); font-weight: 500; }

/* keyword placement tag */
.where-tag { display: inline-block; font-size: .64rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.where-tag.ok { background: #eefaf3; color: var(--ok); border: 1px solid #cdeedb; }
.where-tag.warn { background: #fdf7e9; color: var(--warn); border: 1px solid #f3e4bd; }

/* before/after delta badge */
.delta { font-weight: 700; padding: 5px 14px; border-radius: 999px; font-size: .78rem; }
.delta.up { background: #eefaf3; color: var(--ok); border: 1px solid #cdeedb; }
.delta.down { background: #fdf0f2; color: var(--bad); border: 1px solid #f6d3da; }

/* history */
.hist-row { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--border-soft); }
.hist-row:last-child { border-bottom: none; }
.hist-del { background: none; border: none; color: #b6ada1; cursor: pointer; font-size: .9rem; padding: 4px 7px; border-radius: 8px; transition: color .12s, background .12s; }
.hist-del:hover { color: var(--bad); background: #fdf0f2; }

/* AI rewrites */
.rewrite-card .rw-orig { color: var(--muted); font-size: .84rem; padding: 10px 12px; background: #f6f4f1; border-radius: 12px; overflow-wrap: break-word; }
.rewrite-card .rw-better { margin-top: 9px; padding: 12px 14px; border-left: 3px solid #86d7b2; background: #f1fbf6; border-radius: 0 12px 12px 0; font-size: .88rem; position: relative; padding-inline-end: 92px; overflow-wrap: break-word; }
.rw-label { display: inline-block; font-size: .6rem; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: #a89f92; margin-inline-end: 8px; }
.rw-label.ok { color: var(--ok); }
.rewrite-card .rw-copy { position: absolute; top: 7px; inset-inline-end: 9px; padding: 3px 10px; font-size: .7rem; }
.rewrite-card .why { margin-top: 9px; }

/* RTL (Arabic) */
[dir="rtl"] table.kw th, [dir="rtl"] table.kw td { text-align: right; }
[dir="rtl"] .item-card .example { border-left: none; border-right: 3px solid #ee9ec0; border-radius: 10px 0 0 10px; }
[dir="rtl"] .rewrite-card .rw-better { border-left: none; border-right: 3px solid #86d7b2; border-radius: 12px 0 0 12px; }
[dir="rtl"] .score-ring svg { transform: none; }
[dir="rtl"] body { font-family: 'Plus Jakarta Sans', 'Segoe UI', Tahoma, system-ui, sans-serif; }

#rewrites-box:empty { display: none; }

/* gentle entrance for results cards */
#results .card { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    #results .card { animation: none; }
    html { scroll-behavior: auto; }
}

@media print {
    .bg-scene, header, #settings-panel, #btn-analyze, footer, #history, .no-print { display: none !important; }
    body { background: white; color: black; }
    .card { border-color: #ddd; box-shadow: none; }
    .sec-item, .item-card, .rewrite-card { break-inside: avoid; }
}
