:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f2f5f9;
  --ink: #111827;
  --muted: #4b5563;
  --subtle: #6b7280;
  --line: #d9dde4;
  --line-strong: #aeb7c4;
  --accent: #1f6feb;
  --accent-soft: #edf4ff;
  --danger: #b42318;
  --ok: #047857;
  --shadow: 0 18px 48px rgba(17, 24, 39, 0.08);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Aptos, "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.26);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.12rem;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 4vw, 2.45rem);
  line-height: 1.06;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.94rem;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.muted,
.section-heading span {
  color: var(--muted);
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.progress-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: var(--surface-soft);
}

.progress-grid strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
}

.progress-grid span {
  display: block;
  margin-top: 4px;
  color: var(--subtle);
  font-size: 0.75rem;
}

.on-deck {
  display: grid;
  gap: 6px;
}

.on-deck-button,
.lesson-button,
.mini-lesson {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.on-deck-button {
  min-height: 64px;
  padding: 12px;
  border-color: rgba(31, 111, 235, 0.34);
  background: var(--accent-soft);
}

.on-deck-button:disabled {
  cursor: default;
  border-color: var(--line);
  background: var(--surface-soft);
}

.on-deck-button strong,
.on-deck-button span,
.lesson-button strong,
.lesson-button span,
.mini-lesson strong,
.mini-lesson span,
.mini-lesson small {
  display: block;
}

.on-deck-button span,
.lesson-button span,
.mini-lesson span,
.mini-lesson small {
  margin-top: 3px;
  color: var(--subtle);
  font-size: 0.78rem;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.filter-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.filter-button.active {
  border-color: rgba(31, 111, 235, 0.4);
  background: var(--accent);
  color: #fff;
}

.lesson-nav {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.lesson-button {
  min-height: 58px;
  padding: 11px 12px;
  transition: border-color 150ms ease, background 150ms ease;
}

.lesson-button:hover,
.mini-lesson:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.lesson-button.active {
  border-color: rgba(31, 111, 235, 0.5);
  background: var(--accent-soft);
}

.lesson-button.complete strong::after {
  content: " done";
  color: var(--ok);
  font-size: 0.74rem;
  font-weight: 760;
  text-transform: uppercase;
}

.sidebar-footer,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sidebar-footer {
  margin-top: auto;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 40px;
  padding: 0 13px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 760;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.ghost-button.danger {
  color: var(--danger);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.full-width {
  width: 100%;
}

.main-pane {
  min-width: 0;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.topbar,
.workspace,
.log-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 118px;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.current-copy {
  min-width: 0;
}

.current-copy .muted {
  margin: 10px 0 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 720px;
  overflow: hidden;
}

.reader-panel {
  min-width: 0;
  min-height: 720px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.reader-panel iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 720px;
  border: 0;
  background: #fff;
}

.reader-fallback {
  padding: 28px;
}

.coach-panel {
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 16px;
  background: #fbfcfe;
}

.coach-panel section {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.coach-panel section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill.current {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-pill.done {
  background: #ecfdf3;
  color: var(--ok);
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  color: var(--ink);
  background: var(--surface);
}

.mini-library {
  display: grid;
  gap: 8px;
}

.mini-lesson {
  padding: 10px;
}

.mini-lesson span {
  color: var(--accent);
  font-weight: 760;
  text-transform: uppercase;
}

.log-section {
  padding: 18px;
}

.learning-log {
  display: grid;
  gap: 10px;
}

.log-entry {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.log-entry strong,
.log-entry span {
  display: block;
}

.log-entry span {
  margin-top: 2px;
  color: var(--subtle);
  font-size: 0.82rem;
}

.log-entry p {
  margin: 8px 0 0;
  color: var(--muted);
}

.empty-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lesson-nav {
    max-height: 280px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .reader-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 700px) {
  .main-pane {
    padding: 14px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    flex: 1;
  }

  .workspace,
  .reader-panel,
  .reader-panel iframe {
    min-height: 620px;
  }
}
