:root {
  color-scheme: dark;
  --bg: #0c0d0b;
  --surface: #141610;
  --surface-2: #1b1f18;
  --line: #303628;
  --line-soft: rgba(229, 220, 190, 0.13);
  --text: #f3f0e6;
  --muted: #aaa493;
  --subtle: #756f61;
  --accent: #f0b23d;
  --accent-ink: #171004;
  --green: #58d68d;
  --red: #ff6b57;
  --blue: #7fb7ff;
  --radius: 8px;
  --sidebar-width: 278px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    linear-gradient(90deg, rgba(240, 178, 61, 0.04), transparent 34%),
    radial-gradient(circle at top right, rgba(88, 214, 141, 0.06), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: 22px 18px;
  background: rgba(12, 13, 11, 0.92);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid var(--accent);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  height: 42px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: 160ms ease;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(240, 178, 61, 0.08);
}

.admin-nav {
  margin-top: 10px;
  color: #ffb0a6;
}

.sidebar-status {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
}

.sidebar-status strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-shell {
  margin-left: var(--sidebar-width);
  min-height: 100dvh;
  padding: 30px clamp(18px, 3vw, 42px) 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.topbar-actions,
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-label {
  color: var(--muted);
  font-size: 0.9rem;
}

select,
input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f110d;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 178, 61, 0.16);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(280px, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.hero-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(20, 22, 16, 0.88);
}

.hero-panel {
  min-height: 250px;
  padding: clamp(22px, 4vw, 44px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 20px 20px auto auto;
  width: 146px;
  height: 146px;
  border: 1px solid rgba(240, 178, 61, 0.32);
  border-radius: 50%;
  box-shadow: inset 0 0 0 28px rgba(240, 178, 61, 0.03);
}

.hero-panel p {
  color: var(--accent);
  margin-bottom: 12px;
}

.hero-panel h2 {
  max-width: 680px;
  font-size: clamp(2rem, 5vw, 4.9rem);
  line-height: 0.96;
  letter-spacing: 0;
  margin-bottom: 18px;
}

.hero-panel span {
  color: var(--muted);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
}

.metric {
  min-height: 124px;
  padding: 20px;
  background: var(--surface);
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  font-size: 2rem;
}

.workspace {
  display: grid;
  gap: 18px;
}

.two-column {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.62fr);
}

.panel {
  padding: 20px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-head p {
  margin: 6px 0 0;
  font-size: 0.92rem;
}

.primary-button,
.ghost-button,
.apple-button,
.danger-button {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 14px;
  white-space: nowrap;
  transition: 140ms ease;
}

.primary-button {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 750;
}

.ghost-button {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.apple-button {
  color: #111;
  background: #f7f7f7;
  font-weight: 750;
}

.danger-button {
  background: rgba(255, 107, 87, 0.1);
  border-color: rgba(255, 107, 87, 0.55);
  color: #ffb0a6;
}

.primary-button:active,
.ghost-button:active,
.apple-button:active,
.danger-button:active,
.choice-button:active {
  transform: translateY(1px);
}

.progress-lane,
.recommendation-list,
.analysis-summary,
.weak-list,
.question-list,
.lesson-list,
.repeater-list {
  display: grid;
  gap: 10px;
}

.status-row,
.recommendation,
.weak-item,
.question-row,
.lesson-item,
.repeater-item {
  border-top: 1px solid var(--line-soft);
  padding: 14px 0 4px;
}

.status-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.status-row strong {
  font-size: 1.6rem;
}

.quiz-panel {
  min-height: 620px;
}

.quiz-toolbar {
  align-items: center;
}

.quiz-stage {
  border-top: 1px solid var(--line-soft);
  padding-top: 22px;
}

.session-meter {
  height: 8px;
  margin-top: 18px;
  background: #0c0d0b;
  border-radius: 999px;
  overflow: hidden;
}

.session-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.question-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.chip {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.82rem;
}

.question-text {
  font-size: clamp(1.25rem, 2vw, 1.85rem);
  line-height: 1.45;
  max-width: 980px;
  margin-bottom: 22px;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice-button {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #10130e;
  color: var(--text);
  text-align: left;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  line-height: 1.5;
}

.choice-button.selected {
  border-color: var(--accent);
  background: rgba(240, 178, 61, 0.1);
}

.choice-button.correct {
  border-color: var(--green);
}

.choice-button.wrong {
  border-color: var(--red);
}

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

.breakdown {
  margin-top: 20px;
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 16px;
}

.breakdown h3 {
  margin: 0 0 10px;
}

.breakdown ol {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.figure-note {
  border: 1px dashed var(--line);
  color: var(--muted);
  padding: 12px;
  margin-bottom: 14px;
  border-radius: var(--radius);
}

.question-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.question-row p {
  margin: 4px 0 0;
}

.analysis-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analysis-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: #10130e;
}

.analysis-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
}

.analysis-card strong {
  font-size: 2rem;
}

.weak-item {
  display: grid;
  gap: 8px;
}

.bar {
  height: 8px;
  background: #0c0d0b;
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--red);
}

.morse-board {
  min-height: 430px;
}

.morse-display {
  min-height: 156px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: clamp(2.4rem, 8vw, 6rem);
  font-weight: 850;
  letter-spacing: 0.08em;
  background: #0f120d;
}

.morse-controls,
.account-stack,
.repeater-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.morse-controls label,
.account-stack label,
.repeater-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.morse-controls input,
.account-stack input,
.repeater-form input {
  width: 100%;
}

.repeater-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-wide {
  grid-column: 1 / -1;
}

.lesson-item button {
  margin-top: 10px;
}

.search-input {
  min-width: min(320px, 100%);
}

.repeater-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
}

.repeater-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.repeater-item dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 8px 14px;
  color: var(--muted);
}

.repeater-item dd {
  margin: 0;
  color: var(--text);
}

.status-box {
  margin: 0;
  min-height: 200px;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #0f110d;
  color: var(--muted);
  overflow: auto;
}

.empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  padding: 22px;
}

.admin-locked {
  opacity: 0.6;
}

@media (max-width: 960px) {
  .shell-sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
    width: 100%;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 12px;
  }

  .brand {
    min-width: 180px;
  }

  .nav-list {
    display: flex;
    min-width: max-content;
  }

  .nav-item {
    min-width: 72px;
    text-align: center;
    border-left: 0;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius);
  }

  .nav-item.active {
    border-bottom-color: var(--accent);
  }

  .sidebar-status {
    display: none;
  }

  .app-shell {
    margin-left: 0;
  }

  .overview-grid,
  .two-column {
    grid-template-columns: 1fr;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .repeater-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar,
  .panel-head,
  .question-row,
  .repeater-item {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .analysis-summary {
    grid-template-columns: 1fr;
  }

  .repeater-item dl {
    grid-template-columns: max-content 1fr;
  }

  .repeater-form {
    grid-template-columns: 1fr;
  }
}
