:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --text: #1d2321;
  --muted: #66706b;
  --border: #dedcd4;
  --accent: #356859;
  --accent-text: #ffffff;
  --accent-soft: #e2eee9;
  --star: #e0a526;
  --danger: #b4412f;
  --warn-bg: #fbf1d9;
  --warn-text: #6c4d07;
  --ok: #2c7a4b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1c211f;
    --surface-2: #242a27;
    --text: #e6ebe8;
    --muted: #9aa49f;
    --border: #323a36;
    --accent: #6fb39c;
    --accent-text: #0f1513;
    --accent-soft: #23352f;
    --star: #f0b93a;
    --danger: #e07a68;
    --warn-bg: #3a3017;
    --warn-text: #f1d996;
    --ok: #79c99a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .8rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
.inline { display: inline; margin: 0; }
code { font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.pre { white-space: pre-wrap; }
.ok-text { color: var(--ok); }
.error-text { color: var(--danger); }
.danger-text { color: var(--danger); }

/* шапка */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: .35rem .7rem; border-radius: 999px; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); }
.count { font-size: .8em; color: var(--muted); }
.logout { margin: 0; }
.banner { background: var(--warn-bg); color: var(--warn-text); font-size: .9rem; text-align: center; padding: .45rem 16px; }

.container { max-width: 1120px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

/* формы */
.field { display: block; border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.field > span, .field > legend, .field > label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .35rem; padding: 0; }
input[type="text"], input:not([type]), input[type="password"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem .75rem;
}
textarea { resize: vertical; min-height: 5rem; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .segmented input:focus-visible + span {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.hint { display: block; color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.check { display: flex; gap: .5rem; align-items: center; margin: .4rem 0 .8rem; }

.segmented { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: .4rem .8rem; border-radius: 8px; cursor: pointer; font-size: .92rem; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.stars { display: inline-flex; flex-direction: row-reverse; align-items: center; gap: 2px; }
.stars input { position: absolute; opacity: 0; }
.stars label { font-size: 1.7rem; line-height: 1; color: var(--border); cursor: pointer; padding: 0 1px; }
.stars input:checked ~ label, .stars label:hover, .stars label:hover ~ label { color: var(--star); }
.stars input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 4px; }
.clear-stars { order: -1; margin-left: .8rem; font-size: .85rem; }
.stars-static { color: var(--star); letter-spacing: 1px; }
.stars-static .dim { color: var(--border); }

details.more summary, details.card summary { cursor: pointer; color: var(--muted); margin-bottom: .6rem; }
details.card summary { list-style-position: inside; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
  padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; min-height: 2.6rem; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.actions form { margin: 0; }
.settings > .actions { margin: 0 0 1rem; }
.small { font-size: .85rem; }

.notice { border-radius: 10px; padding: .7rem 1rem; margin: 0 0 1rem; }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice.ok { background: var(--accent-soft); }
.notice.error { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--text); }

/* новый отзыв */
.compose { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1rem; align-items: start; }
.result { min-height: 22rem; position: sticky; top: 4.5rem; }
.empty h2 { margin-top: .2rem; }
.empty p { color: var(--muted); }
.steps { list-style: none; margin: 0 0 1rem; padding: 0; font-size: .92rem; }
.steps li { display: flex; flex-wrap: wrap; gap: 0 .55rem; align-items: baseline; padding: .2rem 0; color: var(--muted); }
.steps li::before { content: "✓"; color: var(--ok); width: 1rem; flex: none; }
.steps li.active { color: var(--text); }
.steps li.active::before { content: ""; width: .8rem; height: .8rem; border: 2px solid var(--accent); border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; align-self: center; }
.steps li.bad::before { content: "↻"; color: var(--warn-text); }
.steps li.warn::before { content: "!"; color: var(--warn-text); font-weight: 700; }
.steps li .issues { flex-basis: 100%; padding-left: 1.55rem; font-size: .85rem; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .steps li.active::before { animation: none; } }

.review-text { white-space: pre-wrap; font-size: 1.08rem; line-height: 1.65; background: var(--surface-2); border-radius: 12px; padding: 1rem 1.1rem; margin: .4rem 0 0; }
.meta { font-size: .88rem; color: var(--muted); margin-top: .8rem; }
.meta summary { cursor: pointer; }
.issue-list { margin: .5rem 0 0; padding-left: 1.2rem; font-size: .9rem; }
.issue-list li { margin-bottom: .35rem; }
.issue-list q { color: var(--muted); }

/* архив */
.search { display: flex; gap: .5rem; margin: 1rem 0; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.list-item { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; color: var(--text); text-decoration: none; }
a.list-item:hover { border-color: var(--accent); }
.list-item.static { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.list-item.static p { margin: 0; }
.samples { margin-top: 1rem; }
.list-meta { display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: baseline; }
.excerpt { margin: .35rem 0 0; color: var(--muted); }
.tag { font-size: .75rem; padding: .1rem .45rem; border-radius: 999px; background: var(--surface-2); }
.tag.warn { background: var(--warn-bg); color: var(--warn-text); }
.back { text-decoration: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.plain { padding-left: 1.2rem; margin: .3rem 0; }

/* настройки */
.choices { display: grid; gap: .4rem; margin-bottom: 1rem; }
.choices.compact { margin: .2rem 0 1rem 1.6rem; }
.choice { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: .3rem; }
.choice small { color: var(--muted); }

/* вход */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }

@media (max-width: 820px) {
  .topbar { position: static; }
  .topbar-inner { flex-wrap: nowrap; gap: .6rem; }
  .nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .nav a { white-space: nowrap; padding: .35rem .55rem; }
  .compose { grid-template-columns: 1fr; }
  .result { position: static; min-height: 0; }
  .row, .grid2 { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: .4rem; }
  h1 { font-size: 1.4rem; }
  .card { padding: 1rem; }
}

.compose-options { display: grid; grid-template-columns: minmax(6.5rem, 1fr) minmax(0, 2fr); gap: .75rem; }
.compose-more { margin-bottom: 1rem; }
.compose-more[open] summary { margin-bottom: 1rem; }
.form-error { margin: .6rem 0 0; }
.field textarea[aria-invalid="true"] { border-color: var(--danger); }
.example-label { font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: .4rem; padding: .15rem .45rem; }
.result { position: static; scroll-margin-top: 5rem; }
.result > h2 { font-size: 1.4rem; }
.job-history { margin: 0 0 1.15rem; }
.job-status { display: flex; justify-content: space-between; align-items: baseline; gap: .7rem; }
#jobProgress { display: block; width: 100%; height: .45rem; margin: .5rem 0; accent-color: var(--accent); }
#jobInfo, #jobStep { margin: .35rem 0; }
#jobStep:empty, .job-actions:not(:has(button:not([hidden]))) { display: none; }
.job-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.batch-items { list-style: none; padding: 0; margin: 1rem 0 0; }
.batch-items > li { border-top: 1px solid var(--border); }
.batch-item summary { padding: .8rem 0; cursor: pointer; }
.batch-item summary .tag { margin-left: .5rem; }
.batch-item[open] { padding-bottom: .9rem; }
.batch-item .review-text { margin-top: 0; overflow-wrap: anywhere; }
.batch-item .actions { margin-top: .65rem; }
.batch-item .notice { margin: .5rem 0; }
@media (max-width: 420px) {
  .compose-options { grid-template-columns: 1fr; gap: 0; }
  .topbar-inner { flex-wrap: wrap; justify-content: space-between; gap: .3rem; }
  .nav { order: 1; flex-basis: 100%; }
}
