:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dcdfe4;
  --border-strong: #c2c7d0;
  --text: #1c1f24;
  --text-muted: #5c6470;
  --accent: #1f5fa9;
  --accent-hover: #17497f;
  --accent-soft: #e8f0fa;
  --warn: #9a5b00;
  --warn-soft: #fdf3e2;
  --ok: #1f6b45;
  --ok-soft: #e7f4ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1b1f26;
    --surface-2: #232830;
    --border: #333944;
    --border-strong: #454d5a;
    --text: #e6e9ee;
    --text-muted: #9aa3b0;
    --accent: #6ba5e7;
    --accent-hover: #8bbcf1;
    --accent-soft: #1e2a38;
    --warn: #e0a458;
    --warn-soft: #33291a;
    --ok: #6fcf97;
    --ok-soft: #1c2c22;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------------------------------------------- header */

.site-header {
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.site-header h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  letter-spacing: -0.01em;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.lang-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.lang-buttons {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  overflow: hidden;
}

.lang-btn {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 5px 13px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.lang-btn + .lang-btn {
  border-left: 1px solid var(--border-strong);
}

.lang-btn:hover:not(.is-active) {
  color: var(--text);
}

.lang-btn.is-active {
  background: var(--accent);
  color: #fff;
}

.signout {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.signout:hover {
  color: var(--text);
  border-bottom-color: var(--border-strong);
}

.tagline {
  margin: 0;
  max-width: 72ch;
  color: var(--text-muted);
  font-size: 0.94rem;
}

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  padding-top: 24px;
  padding-bottom: 24px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel-title {
  margin: 0 0 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.step {
  margin-top: 22px;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 4px;
  font-size: 1.02rem;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.step-hint {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.87rem;
  max-width: 68ch;
}

/* ----------------------------------------------------------------- forms */

.group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--surface-2);
  overflow: hidden;
}

.group > summary {
  cursor: pointer;
  padding: 11px 14px;
  font-weight: 600;
  font-size: 0.92rem;
  list-style: none;
}

.group > summary::-webkit-details-marker {
  display: none;
}

.group > summary::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.group[open] > summary::before {
  transform: rotate(90deg);
}

.group-body {
  padding: 4px 14px 14px;
}

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field > label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.87rem;
  font-weight: 600;
}

.field .field-hint {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 70ch;
}

input[type="text"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
}

textarea {
  resize: vertical;
  min-height: 78px;
  line-height: 1.5;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --------------------------------------------------------------- buttons */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--accent-soft);
  border-color: var(--border-strong);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.btn-copy {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-copy:hover {
  color: var(--text);
}

/* ---------------------------------------------------------------- status */

.status {
  margin: 12px 0 0;
  min-height: 1.4em;
  font-size: 0.87rem;
  color: var(--text-muted);
}

.status.error {
  color: #b4232a;
}

@media (prefers-color-scheme: dark) {
  .status.error {
    color: #f08a8f;
  }
}

.status.busy::after {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-left: 7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -1px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .status.busy::after {
    animation: none;
  }
}

/* --------------------------------------------------------------- results */

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin-top: 16px;
}

.empty p {
  margin: 0 0 6px;
}

.empty-sub {
  font-size: 0.85rem;
}

.summary {
  margin: 16px 0;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 7px 7px 0;
  font-size: 0.9rem;
}

.questions {
  margin: 16px 0 22px;
  padding: 15px;
  background: var(--warn-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.questions-title {
  margin: 0 0 4px;
  font-size: 1rem;
  color: var(--warn);
}

.question {
  margin-bottom: 14px;
}

.question > label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.89rem;
  font-weight: 600;
}

.question .why {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.section-head h4 {
  margin: 0;
  font-size: 0.92rem;
  flex: 1;
}

.badge {
  font-size: 0.71rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}

.badge-ready {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-needs {
  background: var(--warn-soft);
  color: var(--warn);
}

.section-body {
  padding: 11px 13px;
}

.section-body textarea {
  border: none;
  padding: 0;
  background: transparent;
  min-height: 60px;
  font-size: 0.9rem;
}

.section-comment {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  padding: 18px 20px 32px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.site-footer p {
  margin: 0;
  max-width: 80ch;
}

/* ----------------------------------------------------------------- score */

.score-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 15px;
  margin-top: 16px;
}

.score-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.score-figure {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

#score-value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.score-of {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.score-meta {
  flex: 1;
  min-width: 0;
}

.score-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.score-band {
  font-size: 1rem;
  font-weight: 600;
}

.score-delta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.score-delta.up {
  color: var(--ok);
  font-weight: 600;
}

.score-delta.down {
  color: var(--warn);
  font-weight: 600;
}

.score-bar {
  height: 8px;
  margin: 12px 0 8px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}

.score-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.5s ease;
}

.score-fill.band-early_draft { background: #b4232a; }
.score-fill.band-needs_work { background: #c07a15; }
.score-fill.band-nearly_ready { background: #2f7fbf; }
.score-fill.band-ready { background: #1f6b45; }

@media (prefers-reduced-motion: reduce) {
  .score-fill { transition: none; }
}

.score-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.score-history {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.score-history:empty {
  display: none;
}

.round-chip {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.round-chip.is-current {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.round-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.score-detail {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

.score-detail > summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.score-criteria {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.score-criteria li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 9px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
}

.score-criteria li:last-child {
  border-bottom: none;
}

.verdict-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  align-self: center;
}

.verdict-present { background: var(--ok); }
.verdict-partial { background: var(--warn); }
.verdict-missing { background: var(--border-strong); }

.criterion-note {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.criterion-points {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ----------------------------------------------------------------- login */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.login-intro {
  margin: 0 0 18px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.login-notice {
  margin: 0 0 16px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 0.86rem;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
}

.login-notice.is-error {
  background: var(--warn-soft);
  border-left-color: var(--warn);
  color: var(--warn);
}

.login-card label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.87rem;
  font-weight: 600;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  margin-bottom: 16px;
}

.login-card .btn {
  width: 100%;
}
