/* Tokens */
:root {
  --font: "Amazon Ember", "Helvetica Neue", Roboto, Arial, sans-serif;
  --text: #0f141a;
  --text-secondary: #424650;
  --muted: #656871;
  --bg: #ffffff;
  --bg-layout: #f9f9fa;
  --border: #c6c6cd;
  --border-divider: #ebebf0;
  --blue: #006ce0;
  --blue-dark: #002b66;
  --blue-light: #f0fbff;
  --success: #00802f;
  --success-bg: #effff1;
  --warning: #855900;
  --error: #db0000;
  --error-bg: #fff5f5;
  --top: #0f141a;
  --radius: 16px;
  --radius-control: 8px;
}

/* Base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--bg-layout);
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); text-decoration: underline; }
h1, h2, h3 { margin: 0; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.ok-text { color: var(--success); font-weight: 700; }
.bad-text { color: var(--error); font-weight: 700; }
.error-text { color: var(--error); }

/* Top navigation */
.top {
  position: sticky; top: 0; z-index: 10;
  height: 56px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--top); color: #fff;
}
.wordmark { color: #fff; font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.wordmark:hover { color: #fff; text-decoration: none; }
.top-right { display: flex; align-items: center; gap: 16px; }
.user { color: #dedee3; font-size: 13px; }

/* Layout */
.main { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.page { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; }
.page-title { font-size: 24px; line-height: 30px; font-weight: 700; }

/* Containers */
.container {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 0 1px 1px 1px #e9ebed, 0 6px 36px #0007161a;
  overflow: hidden;
}
.container-header { padding: 12px 20px; border-bottom: 1px solid var(--border-divider); }
.container-header h2 { font-size: 18px; line-height: 22px; font-weight: 700; }
.container-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.container-body.flush { padding: 0; }
.feedback-container { border: 2px solid #e9ebed; box-shadow: none; }
.feedback-container.feedback-correct { border-color: var(--success); }
.feedback-container.feedback-incorrect { border-color: var(--warning); }

/* Key-value pairs */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px 24px; }
.kv-label { color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.kv-value { color: var(--text); }
.score { font-size: 42px; line-height: 48px; font-weight: 300; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 700; cursor: pointer;
  padding: 4px 20px; min-height: 32px;
  border-radius: 20px; border: 2px solid transparent;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-primary:disabled { background: #ebebf0; border-color: #ebebf0; color: #b4b4bb; cursor: default; }
.btn-normal { background: #fff; border-color: var(--blue); color: var(--blue); }
.btn-normal:hover { background: var(--blue-light); border-color: var(--blue-dark); color: var(--blue-dark); }
.btn-link { background: none; color: var(--blue); }
.btn-link:hover { background: var(--blue-light); color: var(--blue-dark); }
.btn-top { background: none; border-color: #8c8c94; color: #fff; padding: 2px 14px; min-height: 28px; }
.btn-top:hover { border-color: #fff; }
.btn-small { padding: 2px 14px; min-height: 28px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Progress */
.progress { height: 4px; background: #dedee3; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); border-radius: 4px; }
.cycle-label { color: var(--text-secondary); margin-bottom: 6px; }

/* Landing */
.mode {
  border: 2px solid var(--blue); background: var(--blue-light);
  border-radius: var(--radius-control); padding: 12px 16px; max-width: 480px;
}
.mode-title { font-weight: 700; }
.mode-desc { color: var(--text-secondary); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 700; color: var(--text-secondary);
  padding: 10px 20px; border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 20px; border-bottom: 1px solid var(--border-divider); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f6f6f9; }
.q-cell { max-width: 460px; }
.container-body.flush > .muted { padding: 16px 20px; }

/* Question */
.q-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.q-count { font-size: 18px; font-weight: 700; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 4px;
  background: #f1f2f3; color: var(--text-secondary); font-size: 12px; font-weight: 700;
}
.q-text { font-size: 16px; line-height: 24px; }
.q-text p { margin: 0 0 12px; }
.hint { color: var(--text-secondary); font-style: italic; margin-top: -8px; }
.options { display: flex; flex-direction: column; gap: 12px; }

/* Option cards */
.option {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px; cursor: pointer;
  border: 2px solid var(--border); border-radius: var(--radius-control); background: #fff;
}
.option:hover:not(.locked) { border-color: var(--blue); background: var(--blue-light); }
.option.selected { border-color: var(--blue); background: var(--blue-light); }
.option.locked { cursor: default; }
.option.is-correct { border-color: var(--success); background: var(--success-bg); }
.option.is-incorrect { border-color: var(--error); background: var(--error-bg); }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option-text { flex: 1; }
.option:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Radio and checkbox controls */
.control {
  flex: none; width: 16px; height: 16px; margin-top: 2px;
  border: 2px solid #8c8c94; background: #fff; position: relative;
}
.control.dot { border-radius: 50%; }
.control.box { border-radius: 4px; }
input:checked + .control { border-color: var(--blue); }
input:checked + .control.dot { border-width: 5px; }
input:checked + .control.box { background: var(--blue); }
input:checked + .control.box::after {
  content: ""; position: absolute; left: 3px; top: 0; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.is-correct input:checked + .control { border-color: var(--success); }
.is-correct input:checked + .control.box { background: var(--success); }
.is-incorrect input:checked + .control { border-color: var(--error); }
.is-incorrect input:checked + .control.box { background: var(--error); }
input:disabled:not(:checked) + .control { border-color: #b4b4bb; background: #ebebf0; }

/* Explanations */
.option-why:empty { display: none; }
.why { margin: 8px 0 0 30px; padding: 0 0 0 12px; border-left: 2px solid var(--border-divider); }
.why p { color: var(--text-secondary); margin: 4px 0 0; }
.why-title { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.why-correct .why-title { color: var(--success); }
.why-incorrect .why-title { color: var(--text-secondary); }
.feedback-slot:empty { display: none; }
.feedback-slot { border-top: 1px solid var(--border-divider); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.result-banner { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; }
.result-banner.ok { color: var(--success); }
.result-banner.bad { color: var(--error); }
.result-banner .muted { font-size: 14px; font-weight: 400; }
.explain-title { font-size: 16px; }
.exam-focus { background: var(--blue-light); border-left: 4px solid var(--blue); border-radius: 4px; padding: 10px 14px; }
.exam-focus p { margin: 4px 0 0; }
.sources ul { margin: 4px 0 0; padding-left: 20px; }
.sources a { word-break: break-all; }
.icon { display: inline-flex; width: 18px; justify-content: center; }

/* Question footer */
.q-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inline-status { flex: 1; text-align: right; color: var(--muted); }

/* Results */
.hero { display: flex; gap: 20px; align-items: flex-start; padding: 8px 0; }
.hero-icon {
  flex: none; width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-light); color: var(--blue); font-size: 30px;
}
.hero .actions { margin-top: 12px; }
.domains { gap: 0; padding: 0; }
.domain { padding: 16px 20px; border-bottom: 1px solid var(--border-divider); display: flex; flex-direction: column; gap: 10px; }
.domain:last-child { border-bottom: none; }
.domain-name { font-weight: 700; font-size: 16px; }
.domain-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* Banner */
.banner-body { display: flex; align-items: center; gap: 24px; padding: 24px 28px; }
.banner-text { flex: 2; display: flex; flex-direction: column; gap: 8px; }
.banner-title { font-size: 24px; line-height: 30px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.banner-icon {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--success); color: #fff; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}
.banner-desc { color: var(--text-secondary); margin: 0; }
.banner-art { flex: 1; position: relative; height: 120px; min-width: 160px; }
.banner-art span { position: absolute; border-radius: 50%; }
.art-a { width: 110px; height: 110px; right: 40px; top: 5px; background: #d1f1ff; }
.art-b { width: 60px; height: 60px; right: 10px; top: 50px; background: #ffe347; }
.art-c { width: 36px; height: 36px; right: 130px; top: 70px; background: #b8e7b8; }
.link-strong { font-weight: 700; }

/* Overview */
.overview-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kv-big { font-size: 20px; line-height: 28px; }
.section-title { font-size: 20px; line-height: 26px; font-weight: 700; }
.start { display: inline-flex; align-items: center; gap: 8px; }
.copied { font-weight: 700; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  font: inherit; font-weight: 700; color: var(--text-secondary); cursor: pointer;
  background: none; border: none; border-bottom: 4px solid transparent; padding: 8px 16px;
}
.tab:hover { color: var(--blue); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

/* Domain cards */
.domain-list { display: flex; flex-direction: column; gap: 16px; }
.task-row { border-top: 1px solid var(--border-divider); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.task-name { font-weight: 700; }

/* Question details */
.filters { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.filter { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.select {
  font: inherit; padding: 4px 8px; min-height: 32px; max-width: 360px;
  border: 2px solid #8c8c94; border-radius: var(--radius-control); background: #fff;
}
.filter-actions { margin-left: auto; }
.q-list { display: flex; flex-direction: column; gap: 8px; }
.q-item { border: 1px solid var(--border); border-radius: var(--radius-control); background: #fff; }
.q-item[open] { border-color: var(--blue); }
.q-item-head {
  cursor: pointer; padding: 12px 16px; list-style: none;
  display: grid; grid-template-columns: auto auto 1fr; gap: 4px 12px; align-items: center;
}
.q-item-head::-webkit-details-marker { display: none; }
.q-item-head::before { content: "▸"; color: var(--muted); grid-row: 1; }
.q-item[open] .q-item-head::before { content: "▾"; }
.q-item-title { font-weight: 700; }
.q-item-status { justify-self: end; grid-column: 4; grid-row: 1; }
.q-item-preview { grid-column: 2 / 5; color: var(--text-secondary); }
.q-item-head .badge { grid-column: 3; justify-self: start; }
.q-item-body { padding: 4px 16px 16px; border-top: 1px solid var(--border-divider); display: flex; flex-direction: column; gap: 12px; }
.option-tags { display: inline-flex; gap: 6px; flex: none; }
.badge-ok { background: var(--success-bg); color: var(--success); }

/* Trend */
.bar-col { width: 40%; }
.trend-bar { height: 10px; background: #ebebf0; border-radius: 5px; overflow: hidden; margin-top: 5px; }
.trend-fill { height: 100%; background: var(--blue); }

/* Loading and errors */
.state { display: flex; align-items: center; gap: 10px; padding: 48px 0; justify-content: center; color: var(--muted); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #dedee3; border-top-color: var(--blue);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.alert { border: 2px solid var(--error); background: var(--error-bg); border-radius: var(--radius-control); padding: 16px 20px; }
.alert p { margin: 6px 0 12px; }

/* Small screens */
@media (max-width: 640px) {
  .main { padding: 20px 12px 48px; }
  .domain-stats { grid-template-columns: repeat(2, 1fr); }
  .table th, .table td { padding: 8px 10px; }
  .user { display: none; }
  .banner-art { display: none; }
  .filter-actions { margin-left: 0; }
}
