:root {
  --bg: #f3efe6;
  --surface: #fffcf7;
  --ink: #1c1916;
  --muted: #5e574e;
  --line: #e3dacd;
  --line-strong: #cfc4b4;
  --accent: #1f6b4a;
  --accent-soft: #e5f4ec;
  --danger: #8d342c;
  --shadow: 0 18px 50px rgba(48, 36, 18, 0.08);
  --serif: "Newsreader", Georgia, serif;
  --sans: "Figtree", "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, #efe2cc 0%, transparent 55%),
    radial-gradient(700px 380px at -10% 0%, #e4efe8 0%, transparent 50%),
    var(--bg);
}

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

#app { min-height: 100vh; }

.page {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.page-main {
  flex: 1;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: 56px;
  height: 100vh;
  height: 100dvh;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 10px;
  background: rgba(255, 252, 247, 0.96);
  border-right: 1px solid var(--line);
  overflow: hidden;
  z-index: 12;
  transition: width 200ms ease;
}

.sidebar.is-open { width: 248px; }

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.sidebar-mark {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: #f3efe6;
  font-family: var(--serif);
  font-size: 16px;
}

.sidebar-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.sidebar:not(.is-open) .sidebar-title,
.sidebar:not(.is-open) .sidebar-nav,
.sidebar:not(.is-open) .sidebar-mark { display: none; }

.sidebar:not(.is-open) .sidebar-top { justify-content: center; }

.sidebar:not(.is-open) .sidebar-toggle { margin-left: 0; }

.sidebar-toggle {
  flex: none;
  width: 32px;
  height: 32px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-user {
  margin: 0;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar:not(.is-open) .sidebar-foot { display: none; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.auth-brand {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.auth-card h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.auth-card .quiet { margin: 0 0 4px; }

.auth-card label { margin: 0; }

.auth-switch {
  align-self: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}

.auth-switch:hover { color: var(--ink); }

.auth-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-mode {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 650;
  color: var(--muted);
}

.auth-mode.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #f6f1e8;
}

.side-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
}

.side-link:hover { background: #f7f3ec; }

.side-link.is-on { background: #f3ece3; }

.side-label {
  min-width: 0;
  white-space: nowrap;
}

.side-count {
  flex: none;
  color: var(--muted);
  font-size: 13px;
}

.shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 252, 247, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.site-header-inner {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-name {
  display: block;
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -0.03em;
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.05;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.review {
  width: min(980px, calc(100% - 32px));
  margin: 22px auto 0;
}

.review-inner {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 28px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 26px;
  box-shadow: var(--shadow);
}

.donut-wrap {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 0 auto;
}

.donut {
  display: block;
  width: 168px;
  height: 168px;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.donut-center strong {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 560;
  letter-spacing: -0.04em;
  line-height: 1;
}

.donut-center strong.is-wide {
  font-size: 32px;
}

.chart-rows {
  display: grid;
  gap: 8px;
}

.chart-row {
  display: grid;
  grid-template-columns: 12px minmax(120px, 160px) 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 8px 10px;
  text-align: left;
}

.chart-row.is-on {
  background: #f7f3ec;
}

.row-swatch {
  width: 12px;
  height: 12px;
  border-radius: 99px;
}

.row-all .row-swatch,
.row-all .row-fill { background: #ddd4c8; }
.row-ready .row-swatch,
.row-ready .row-fill { background: #e7d3bc; }
.row-awaiting .row-swatch,
.row-awaiting .row-fill { background: #c5daf6; }
.row-passed .row-swatch,
.row-passed .row-fill { background: #c5e6d4; }

.row-label {
  font-size: 14px;
  font-weight: 600;
}

.row-track {
  height: 10px;
  background: #f4f0e8;
  border-radius: 99px;
  overflow: hidden;
}

.row-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.row-meta {
  min-width: 92px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.pager-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.due {
  margin: 10px 0 0;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0 18px;
}

.stat {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px 12px;
}

.stat strong {
  display: block;
  font-size: 22px;
  letter-spacing: -0.04em;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat.is-on {
  background: var(--surface);
  border-color: var(--line);
}

.list { margin: 0; }

.sheet-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: auto;
}

.sheet-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.sheet-toolbar-title { justify-content: flex-start; }

.sheet-toolbar-split {
  justify-content: space-between;
  align-items: center;
}

.sheet-heading {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 560;
  letter-spacing: -0.03em;
}

.dialog-new { width: min(640px, 100%); }

.dialog .new-assessment {
  padding: 0;
  border-bottom: 0;
}

.dialog .new-grid { grid-template-columns: 1fr 1fr; }

.dialog .new-assessment h2 { font-size: 32px; }

.new-assessment h2 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 560;
  letter-spacing: -0.03em;
}

.new-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 12px;
}

.new-assessment label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.new-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.sheet-empty {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.4;
}

.sheet th,
.sheet td {
  padding: 13px 11px;
  text-align: left;
  vertical-align: middle;
  background: transparent;
  border: 0;
}

.sheet th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.sheet td { border-bottom: 1px solid #f0ebe3; }

.sheet tbody tr:last-child td { border-bottom: 0; }

.sheet tbody tr { cursor: pointer; }

.sheet tbody tr:hover td { background: #f7f3ec; }

.sheet tbody tr.is-new td { background: #f3faf6; }

.sheet-name { font-weight: 650; white-space: nowrap; }
.sheet-actions { width: 1%; text-align: right; white-space: nowrap; }

.sheet-nowrap { white-space: nowrap; }

.sheet-email {
  color: var(--muted);
  white-space: nowrap;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.chip-ready { background: #f3ece3; color: #5c5348; }
.chip-awaiting { background: #e7f0fb; color: #2a558f; }
.chip-passed { background: #e5f6ed; color: #1b6b45; }

.email, .quiet, .note {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.note { font-style: italic; }

.btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  color: inherit;
}

.btn:hover { border-color: var(--ink); }

.btn-primary {
  background: var(--ink);
  color: #f6f1e8;
  border-color: var(--ink);
}

.btn-primary:hover { background: #2a251f; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding-inline: 8px;
}

.btn-danger { color: var(--danger); }

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn:focus-visible,
.stat:focus-visible,
.choice:focus-visible,
.chart-row:focus-visible,
.sheet tbody tr:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  padding: 28px 20px;
  text-align: center;
  background: rgba(255, 252, 247, 0.55);
}

.empty h2 { margin: 0 0 6px; font-size: 20px; }
.empty p { margin: 0; color: var(--muted); }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 22, 0.38);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.dialog {
  width: min(460px, 100%);
  background: var(--surface);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.dialog-settings { width: min(520px, 100%); }

.dialog h2 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 560;
  margin: 0 0 6px;
  letter-spacing: -0.03em;
}

.dialog p { margin: 0 0 16px; color: var(--muted); }

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

input, textarea, select {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.hint {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

textarea { min-height: 110px; resize: vertical; }

.form-error {
  color: var(--danger);
  font-size: 14px;
  margin: 0 0 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.link-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg);
  border-radius: 12px;
  padding: 8px 8px 8px 12px;
  margin-bottom: 14px;
}

.link-box code {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.page-card h1 {
  font-family: var(--serif);
  font-size: clamp(36px, 6vw, 52px);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin: 8px 0 4px;
  font-weight: 560;
}

.page.is-fit {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: row;
}

.page.is-fit .page-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.page.is-fit .site-header { position: static; flex: none; }

.page.is-fit .shell {
  flex: 1;
  min-height: 0;
  width: min(1440px, calc(100% - 16px));
  padding: 8px 0;
  display: flex;
  flex-direction: column;
}

.assess {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 8px;
  overflow: hidden;
}

.assess-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
}

.assess-who { min-width: 0; }

.assess h1 {
  font-size: 22px;
  line-height: 1.1;
  margin: 0;
}

.assess .email {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assess .choices {
  margin: 0;
  grid-template-columns: repeat(3, max-content);
}

.assess .choice { padding: 6px 10px; white-space: nowrap; }

.assess .process {
  flex: 1;
  min-height: 0;
  margin: 8px 0 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 0.9fr) auto;
  gap: 8px;
  align-items: stretch;
}

.assess-meta {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px 8px;
}

.assess label { margin: 0; font-size: 11px; }

.assess input,
.assess select,
.assess .time-field { margin-top: 2px; }

.assess .time-field input { margin-top: 0; }

.assess .now-btn { padding: 6px 8px; font-size: 12px; }

.assess .question {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  overflow: hidden;
}

.assess .question h3 { font-size: 13px; flex: none; }

.fixed-selection,
.fixed-steps {
  flex: none;
  min-height: 0;
  margin: 0;
  background: #fff;
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.3;
}

.fixed-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.fixed-selection p { margin: 2px 0 0; }

.fixed-steps {
  padding-left: 1.5em;
}

.assess .question-steps .fixed-steps {
  flex: 1;
  overflow: auto;
}

.assess .question-kind { margin: 0; font-size: 12px; }

.assess .question label {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.assess .question textarea {
  flex: 1;
  min-height: 0;
  margin-top: 2px;
  resize: none;
  padding: 6px 8px;
}

.assess textarea::placeholder {
  color: #a3988c;
  opacity: 1;
}

.assess .question-code {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto minmax(0, 1fr);
  column-gap: 10px;
}

.assess .question-code h3,
.assess .question-code .question-kind { grid-column: 1 / -1; }

.assess .process-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.assess .process-actions label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
}

.assess .process-actions input { margin: 0; }

.process {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin: 8px 0 8px;
}

.process .wide { grid-column: 1 / -1; }

.process-actions {
  grid-column: 1 / -1;
}

.question {
  background: #f7f4ee;
  border-radius: 16px;
  padding: 14px 16px 2px;
}

.question h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.question-kind {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.question textarea { min-height: 88px; }

.question .code-text {
  min-height: 160px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.field-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.time-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.time-field input { margin-top: 0; min-width: 0; }

.now-btn {
  flex: none;
  padding: 8px 12px;
}

.choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 20px;
}

.choice {
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
}

.choice small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  margin-top: 4px;
}

.choice.is-selected {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.section-label {
  margin: 22px 0 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.foot {
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
}

.missing {
  max-width: 520px;
  margin: 12vh auto;
  text-align: center;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #f6f1e8;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 30;
}

#toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .page.is-fit { height: auto; overflow: visible; }
  .page.is-fit .shell { display: block; width: min(980px, calc(100% - 32px)); padding: 16px 0 40px; }
  .assess { overflow: visible; }
  .assess .process { display: grid; grid-template-columns: 1fr; grid-template-rows: none; }
  .assess-meta,
  .assess .question-code { grid-template-columns: 1fr; }
  .assess-head,
  .assess .process-actions { display: block; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:first-child { grid-column: 1 / -1; }
  .site-header-inner { flex-direction: column; align-items: stretch; padding: 16px 0; min-height: 0; }
  .review-inner { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 12px 1fr auto; }
  .row-track { grid-column: 1 / -1; }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; justify-content: center; }
  .choices { grid-template-columns: 1fr; }
  .process { grid-template-columns: 1fr; }
  .dialog .new-grid,
  .new-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
