:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #15181d;
  --muted: #5b6270;
  --border: #e2e5ea;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --good: #1a7f4b;
  --ok: #a66300;
  --bad: #c0362c;
  --good-bg: #e7f5ee;
  --bad-bg: #fdecea;
  --chip: #eef1f6;
  --mark: #fff0b3;
  --mark-text: #15181d;
  --ring-bg: #e8ebf0;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2a2f38;
    --accent: #6d8dff;
    --accent-text: #0f1115;
    --good: #4cc38a;
    --ok: #f0a63a;
    --bad: #ff7b6e;
    --good-bg: #15291f;
    --bad-bg: #2e1817;
    --chip: #232832;
    --mark: #5a4a12;
    --mark-text: #fff6d6;
    --ring-bg: #262b34;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --text: #e8eaee;
  --muted: #9aa1ad;
  --border: #2a2f38;
  --accent: #6d8dff;
  --accent-text: #0f1115;
  --good: #4cc38a;
  --ok: #f0a63a;
  --bad: #ff7b6e;
  --good-bg: #15291f;
  --bad-bg: #2e1817;
  --chip: #232832;
  --mark: #5a4a12;
  --mark-text: #fff6d6;
  --ring-bg: #262b34;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 16px 40px; }

.top h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; }
.sub { margin: 0 0 8px; color: var(--muted); max-width: 680px; }
.privacy { margin: 0; font-size: 13px; color: var(--good); display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }

.inputs {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field { display: flex; flex-direction: column; min-width: 0; }
.field label { font-weight: 600; margin-bottom: 6px; }
textarea {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  box-shadow: var(--shadow);
}
textarea:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
button {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid var(--border);
}
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.primary:hover { filter: brightness(1.08); }
.ghost { background: transparent; color: var(--text); }
.ghost:hover { background: var(--chip); }

.error { grid-column: 1 / -1; margin: 0; color: var(--bad); font-weight: 600; }

.results { margin-top: 28px; display: grid; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h3 { margin: 0 0 6px; font-size: 17px; display: flex; align-items: baseline; gap: 8px; }
.count { font-size: 13px; font-weight: 600; color: var(--muted); }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.hint.small { font-size: 13px; margin: 14px 0 8px; }
.empty { margin: 0; color: var(--good); font-weight: 600; }
.warn { color: var(--ok); font-size: 14px; margin: 8px 0 0; }

.score-card { display: flex; align-items: center; gap: 24px; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 12; }
.ring-bg { stroke: var(--ring-bg); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.ring-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.ring-num small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 2px; align-self: flex-end; margin-bottom: 44px; }
.score-text { min-width: 0; }
.score-text p { margin: 0; }
.label { font-size: 20px; font-weight: 700; margin-bottom: 4px !important; }
.label.good { color: var(--good); }
.label.ok { color: var(--ok); }
.label.bad { color: var(--bad); }
.stats { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: var(--muted); }
.stats strong { color: var(--text); }

.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 11px;
  border-radius: 999px;
  background: var(--chip);
  font-size: 14px;
  max-width: 100%;
}
.chip.have { background: var(--good-bg); padding-right: 11px; }
.chip.need { background: var(--bad-bg); }
.chip .tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.chip .tag.req { color: var(--bad); }
.chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 6px;
  font-size: 16px;
  line-height: 1;
  border-radius: 50%;
}
.chip button:hover { color: var(--text); background: var(--border); }
.chips.muted .chip { opacity: 0.75; }

.items { margin: 0; padding-left: 22px; display: grid; gap: 12px; }
.items li { padding-left: 4px; }
.items .quote { display: block; }
.items mark { background: var(--mark); color: var(--mark-text); border-radius: 3px; padding: 0 2px; }
.items .fix { display: block; margin-top: 3px; font-size: 14px; color: var(--muted); }
.items .fix strong { color: var(--text); }
.items .where { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }

.tips { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

.foot { margin-top: 28px; color: var(--muted); font-size: 13px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 720px) {
  .wrap { padding: 20px 16px 32px; }
  .inputs { grid-template-columns: 1fr; }
  textarea { min-height: 200px; }
  .score-card { flex-direction: column; align-items: flex-start; gap: 14px; }
  .actions { flex-direction: column; align-items: stretch; }
  .buttons { justify-content: stretch; }
  .buttons button { flex: 1; }
}
