:root {
  color-scheme: light;
  --bg: #f5f2eb;
  --panel: #fffdf8;
  --panel-strong: #fbf4e6;
  --ink: #20231f;
  --muted: #696f68;
  --line: #ddd3c1;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #d8eee9;
  --gold: #b7791f;
  --red: #b42318;
  --green: #13865b;
  --shadow: 0 24px 70px rgba(53, 43, 25, 0.12);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--ink);
  color: #fffdf8;
  font: 800 18px/1 JetBrains Mono, monospace;
}

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

.brand small {
  margin-top: 3px;
  color: var(--muted);
}

.kicker {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.score-card,
.topic-panel,
.detail-panel,
.schedule-panel,
.metrics-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.score-card {
  padding: 18px;
}

.score-card strong {
  display: block;
  margin-top: 6px;
  font: 800 42px/1 JetBrains Mono, monospace;
}

.score-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  height: 11px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece3d3;
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #13a07f);
  transition: width 220ms ease;
}

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

.area-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.area-button:hover,
.area-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.area-button strong {
  display: block;
  font-size: 13px;
}

.area-button small,
.area-button span {
  color: var(--muted);
  font: 700 12px/1 JetBrains Mono, monospace;
}

.sidebar-tools {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar,
.panel-head,
.status-row,
.detail-actions,
.topbar-actions,
.filters {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.topbar-actions {
  gap: 10px;
}

.target-control {
  display: grid;
  gap: 5px;
  min-width: 118px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.target-control input,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
}

.target-control input {
  height: 41px;
  padding: 0 12px;
  font-family: JetBrains Mono, monospace;
}

.primary-button,
.ghost-button,
.danger-button,
.filter,
.status-chip {
  min-height: 41px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.filter,
.status-chip {
  background: #fffdf8;
  color: var(--ink);
}

.danger-button {
  border-color: rgba(180, 35, 24, 0.24);
  background: #fff2ef;
  color: var(--red);
}

.file-button {
  display: grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metrics-grid article {
  padding: 16px;
}

.metrics-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics-grid strong {
  display: block;
  margin-top: 8px;
  font: 800 30px/1 JetBrains Mono, monospace;
}

.planner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 18px;
}

.topic-panel,
.detail-panel,
.schedule-panel {
  padding: 18px;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.filters {
  flex-wrap: wrap;
  gap: 7px;
}

.filter {
  min-height: 34px;
  padding: 0 11px;
  color: var(--muted);
  font-size: 12px;
}

.filter.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.topic-list {
  display: grid;
  gap: 10px;
  max-height: 63vh;
  overflow: auto;
  padding-right: 4px;
}

.topic-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.topic-row:hover,
.topic-row.selected {
  border-color: var(--accent);
  background: #f8fffc;
}

.topic-check {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: transparent;
  font-weight: 900;
}

.topic-row.done .topic-check {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.topic-body strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
}

.topic-body p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag,
.code-pill {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font: 700 11px/1 JetBrains Mono, monospace;
}

.tag.high {
  background: #fff0d4;
  color: var(--gold);
}

.tag.review {
  background: #fff2ef;
  color: var(--red);
}

.topic-metric {
  min-width: 52px;
  text-align: right;
  font: 800 12px/1 JetBrains Mono, monospace;
  color: var(--muted);
}

.detail-panel {
  min-height: 520px;
}

.empty-detail {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 480px;
  text-align: center;
}

.empty-detail p {
  max-width: 310px;
  color: var(--muted);
}

.detail-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--accent);
  font-size: 26px;
}

.hidden {
  display: none;
}

.detail-heading {
  margin-bottom: 18px;
}

.detail-heading h2 {
  margin-top: 10px;
  line-height: 1.22;
}

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

.status-row {
  gap: 8px;
  margin-bottom: 16px;
}

.status-chip {
  flex: 1;
  min-height: 38px;
  padding: 0 9px;
  font-size: 12px;
}

.status-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select {
  height: 42px;
  padding: 0 11px;
}

.field textarea {
  min-height: 128px;
  resize: vertical;
  padding: 11px;
  line-height: 1.45;
}

.range-label,
.target-hint {
  color: var(--muted);
  font: 700 12px/1 JetBrains Mono, monospace;
}

.detail-actions {
  gap: 8px;
}

.detail-actions button {
  flex: 1;
}

.schedule-panel {
  margin-top: 18px;
}

.suggested-plan {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.suggested-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.suggested-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font: 800 11px/1 JetBrains Mono, monospace;
}

.suggested-card strong {
  display: block;
  line-height: 1.3;
}

.suggested-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .planner-grid,
  .metrics-grid,
  .suggested-plan {
    grid-template-columns: 1fr;
  }

  .topic-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .filters,
  .status-row,
  .detail-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topic-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .topic-metric {
    grid-column: 2;
    text-align: left;
  }
}
