:root { color-scheme: light dark; --muted: #777; --line: #8884; --ok: #2a7; --bad: #d44; }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; }
main { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 .5rem; border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
a { color: inherit; }
.muted { color: var(--muted); }
code { font-size: .9em; }
header.site { border-bottom: 1px solid var(--line); }
header.site .inner { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
header.site .brand { font-weight: 700; text-decoration: none; }
header.site nav { display: flex; gap: 14px; }
header.site nav a, header.site .account a { text-decoration: none; color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
header.site nav a:hover, header.site .account a:hover { color: inherit; }
header.site a[aria-current="page"] { color: inherit; border-bottom-color: currentColor; }
header.site .account { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: .9rem; }
header.site .account form { display: inline; }
header.site .account button { padding: 3px 10px; font-size: .85rem; }
header.site nav.lang { gap: 6px; font-size: .8rem; }
header.site nav.lang a[aria-current="true"] { color: inherit; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.tile .v { font-size: 1.6rem; font-weight: 600; }
.tile .l { color: var(--muted); font-size: .85rem; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.bad { color: var(--bad); }
.ok { color: var(--ok); }
textarea, [contenteditable], input[type=text] { width: 100%; box-sizing: border-box; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: inherit; }
textarea { min-height: 220px; }
[contenteditable] { min-height: 120px; }
.field { margin: 1rem 0; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: .5rem 0; }
button { font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; }
mark { background: #fd05; border-bottom: 2px solid #d44; color: inherit; }
pre { overflow-x: auto; font-size: .85rem; }
.form { max-width: 420px; }
.form label { display: block; font-weight: 600; margin: 12px 0 4px; }
.form input { width: 100%; box-sizing: border-box; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: inherit; }
.form button { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.row input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: inherit; }
.cat:not(.issue .cat) { font-size: .8rem; padding: 1px 8px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: inherit; }
details { margin: .5rem 0; }
.code { font: 700 2rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; margin: .5rem 0 1rem; }
button.primary { background: #2a6fdb; border-color: #2a6fdb; color: #fff; }
a.button { display: inline-block; padding: 8px 14px; border-radius: 6px; background: #2a6fdb; color: #fff; text-decoration: none; font-weight: 600; }

/* Web editor (/editor/{id}) */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; --accent: #2a6fdb; --bg2: #8881; }
@media (max-width: 800px) { .editor { grid-template-columns: 1fr; } }
.editor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.editor-head input { flex: 1; font: 600 1.2rem/1.3 inherit; padding: 6px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: inherit; min-width: 0; }
.editor-head input:hover, .editor-head input:focus { border-color: var(--line); }
.editor-head #save-status { font-size: .8rem; white-space: nowrap; }
.editor textarea#body { min-height: 320px; font-size: 1.05rem; line-height: 1.6; padding: 14px 16px; resize: vertical; }
.editor #foot { font: .8rem ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 8px; }
.editor-side { position: sticky; top: 12px; font-size: .9rem; }
.editor-side section, .editor-side details.tool { margin-top: 16px; }
.editor-side h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; display: inline; border: 0; padding: 0; }
.editor-side .problems-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.editor-side .pill { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 10px; background: #e0454f; color: #fff; font-size: 11px; text-align: center; margin-left: 4px; }
.editor-side .pill:empty { display: none; }
.editor-side button.icon { padding: 4px 8px; display: inline-flex; align-items: center; }
.editor-side button.icon:disabled { opacity: .4; cursor: default; }
.editor-side button.working { opacity: .85; cursor: progress; }
.editor-side button.working::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; vertical-align: -2px; animation: gl-spin .8s linear infinite; }
.editor-side .issues .empty { display: flex; align-items: center; gap: 8px; padding: 12px 10px; border: 1px dashed var(--line); border-radius: 8px; }
.editor-side .issues .empty.clean::before { content: '✓'; color: var(--ok); font-weight: 700; }
.editor-side button.full { width: 100%; margin-bottom: 8px; }
.editor-side .lbl { display: block; font-weight: 600; margin: 8px 0 4px; }
.editor-side select { width: 100%; box-sizing: border-box; font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: inherit; }
.editor-side .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.editor-side .row.between { justify-content: space-between; }
.editor-side .small { font-size: .8rem; }
.editor-side .error { color: #d44; }
.editor-side #status:empty { display: none; }
.editor-side .tone-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.editor-side .tone { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 10px; background: var(--bg2); }
.editor-side .tone[hidden] { display: none; }
.editor-side .tone .emoji { font-size: 26px; line-height: 1; }
.editor-side .tone .lbl { display: inline-block; margin: 0 8px 0 0; font-weight: 400; }
.editor-side .tone .bar { display: inline-block; width: 40px; height: 4px; background: var(--line); border-radius: 2px; vertical-align: middle; margin-left: 4px; }
.editor-side .tone .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.editor-side details.tool { border-top: 1px solid var(--line); }
.editor-side details.tool summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.editor-side details.tool summary::-webkit-details-marker { display: none; }
.editor-side details.tool .chev { color: var(--muted); transition: transform .15s; }
.editor-side details.tool[open] .chev { transform: rotate(180deg); }
.editor-side details.tool .body { padding: 0 0 12px; }
.editor-side details.tool .body button { margin-top: 8px; }
/* Texts list (/editor) */
.texts-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.texts-head p { margin: 0; max-width: 60ch; }
.texts-head form { margin: 0; }
.texts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.text-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; background: #8880a; transition: border-color .15s, box-shadow .15s; }
.text-card:hover { border-color: #8888; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.text-card .text-link { display: block; flex: 1; padding: 14px 16px 6px; text-decoration: none; color: inherit; }
.text-card h3 { margin: 0 0 6px; font-size: 1.05rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-card .preview { margin: 0; font-size: .9rem; line-height: 1.45; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 3.9em; }
.text-card footer { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 6px 16px; font-size: .8rem; }
.text-card footer form { margin: 0; }
.text-card button.icon { border: 0; background: none; padding: 4px 8px; opacity: .5; font-size: .95rem; }
.text-card button.icon:hover { opacity: 1; }
.texts-empty { text-align: center; padding: 56px 16px; border: 1px dashed var(--line); border-radius: 12px; }
.texts-empty .glyph { font-size: 2.5rem; }
.texts-empty h2 { border: 0; margin: .5rem 0 .25rem; }
.texts-empty p { margin: 0 auto 16px; max-width: 46ch; }
.texts-empty form { display: inline; }
footer.site { margin-top: 48px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
footer.site a { color: inherit; }
.lead { font-size: 1.05rem; max-width: 62ch; }
.grid.home { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin: 20px 0; }
.grid.home .tile { display: block; text-decoration: none; color: inherit; padding: 14px 16px; transition: border-color .15s, box-shadow .15s; }
.grid.home .tile:hover { border-color: #8888; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.grid.home .tile .v { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }

/* Editor: busy overlay, flash on generated text, toasts */
.editor-main { position: relative; }
.editor textarea.is-busy { opacity: .45; transition: opacity .2s; }
.editor textarea.flash { box-shadow: 0 0 0 3px #2a6fdb55; transition: box-shadow .9s; }
.busy { position: absolute; left: 0; right: 0; top: 130px; display: flex; justify-content: center; pointer-events: none; }
.busy[hidden] { display: none; }
.busy .pill { pointer-events: auto; position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 999px; background: Canvas; color: CanvasText; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.18); border: 1px solid var(--line); }
.busy .pill button { font: inherit; font-size: .85rem; padding: 3px 10px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; margin-left: 4px; }
.busy .pill button:hover { background: #8882; }
.busy .spinner { width: 14px; height: 14px; border: 2px solid #2a6fdb; border-top-color: transparent; border-radius: 50%; animation: gl-spin .8s linear infinite; }
@keyframes gl-spin { to { transform: rotate(360deg); } }
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(92vw, 520px); }
.toast { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-radius: 10px; background: #222; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: .9rem; animation: gl-rise .18s ease-out; }
.toast.error { background: #b3261e; }
.toast button { font: inherit; font-weight: 600; padding: 4px 10px; border-radius: 6px; border: 1px solid #fff8; background: transparent; color: inherit; cursor: pointer; }
.toast button.close { border: 0; padding: 0 4px; font-size: 1.1rem; line-height: 1; opacity: .8; }
@keyframes gl-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 800px) { .editor-side { position: static; } .editor-head { flex-wrap: wrap; } .editor-head #save-status { width: 100%; text-align: right; } }
/* Site header on narrow screens: brand and account first, nav below */
@media (max-width: 640px) { header.site .inner { gap: 8px 14px; } header.site nav { order: 3; width: 100%; gap: 12px; overflow-x: auto; } header.site .account { margin-left: auto; } }

/* Stats dashboard */
.dash-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 12px 0 18px; }
.dash-toolbar label.custom { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); }
.dash-toolbar input[type=date], .dash-toolbar select { font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { font: inherit; font-size: .85rem; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; }
.chips button.on { background: #2a6fdb; border-color: #2a6fdb; color: #fff; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.charts section { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 10px; min-height: 280px; display: flex; flex-direction: column; }
.charts section h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.charts section canvas { flex: 1; min-height: 220px; max-height: 260px; }
.charts section .small { font-size: .8rem; margin: 6px 0 0; }
@media (max-width: 800px) { .charts { grid-template-columns: 1fr; } }
.overflow { overflow-x: auto; }

/* Review log */
.review-check { border: 1px solid var(--line, #ddd); border-radius: 8px; padding: .4rem .7rem; margin: .4rem 0; }
.review-check summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.review-check .review-text { flex-basis: 100%; white-space: pre-wrap; font-size: .95em; }
.review-count { background: var(--accent, #1d4ed8); color: #fff; border-radius: 999px; padding: 0 .5em; font-size: .8em; }
.review-sugg { margin-top: .5rem; }
.fb-apply { color: #16a34a; font-weight: 600; }
.fb-ignore { color: #dc2626; font-weight: 600; }
.review-clear { margin: -.5rem 0 1rem; }
button.danger { color: #dc2626; border-color: #dc2626; background: transparent; }
