:root {
  --bg-page: #F7F8FA;
  --bg-white: #FFFFFF;
  --bg-subtle: #F1F3F6;
  --bg-hover: #F4F6F9;

  --ink-1: #101418;
  --ink-2: #4A5564;
  --ink-3: #7A8699;

  --line: #E2E6EC;
  --line-strong: #CBD2DC;

  --brand: #0F6B4A;
  --brand-hover: #0B553B;
  --brand-soft: #ECF8F3;
  --brand-border: #B5E2CF;

  --amber: #B45309;
  --amber-soft: #FEF7EB;
  --amber-border: #F5D7A1;

  --danger: #B91C1C;
  --danger-soft: #FEF2F2;
  --danger-border: #FECACA;

  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--ink-1);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.topbar {
  background: var(--bg-white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand);
  color: #FFFFFF;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-1);
  line-height: 1.2;
}

.brand-tag {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}

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

.preset-group {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--line);
}

.preset-btn {
  height: 28px;
  padding: 0 11px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.preset-btn:hover {
  color: var(--ink-1);
}

.preset-btn.active {
  background: var(--bg-white);
  color: var(--ink-1);
  box-shadow: 0 1px 3px rgba(16, 20, 24, 0.08);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-white);
  color: var(--ink-1);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-3);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--ink-1);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  justify-content: center;
}

/* Main Workspace */
.workspace {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

/* Cards */
.card {
  background: var(--bg-white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(16, 20, 24, 0.03);
}

.card-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-1);
  letter-spacing: -0.01em;
}

.card-meta {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}

.card-body {
  padding: 18px 20px 20px;
}

/* Capacity Card */
.capacity-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.capacity-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink-1);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.capacity-unit {
  font-size: 14px;
  color: var(--ink-3);
  margin-left: 4px;
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 2.5px solid #FFFFFF;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.range-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 2.5px solid #FFFFFF;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.schedule-prefs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}

.inline-field input,
.inline-field select {
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-1);
  background: var(--bg-white);
}

/* Collapsible Add Topic Drawer inside Topics Card */
.add-drawer {
  padding: 16px 20px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--line);
}

.add-drawer[hidden] {
  display: none;
}

.topic-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-full {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--bg-white);
  color: var(--ink-1);
  font-family: var(--font-sans);
  font-size: 13px;
}

.input-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.input:focus {
  outline: none;
  border-color: var(--brand);
}

.form-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}

.checkbox-label input {
  accent-color: var(--brand);
}

/* Clean Topic List */
.topic-list {
  display: flex;
  flex-direction: column;
}

.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px 13px 17px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  transition: background-color 0.12s ease;
}

.topic-row:last-child {
  border-bottom: none;
}

.topic-row.is-selected {
  border-left-color: var(--brand);
  background: #FAFEFC;
}

.topic-row.is-skipped {
  opacity: 0.6;
}

.topic-row:hover {
  opacity: 1;
  background: var(--bg-hover);
}

.topic-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-1);
}

.topic-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.topic-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.must-toggle {
  height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--bg-white);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.must-toggle.active {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand);
}

.delete-btn {
  opacity: 0.45;
}

.topic-row:hover .delete-btn {
  opacity: 1;
}

/* Unified 3-Metric Summary Strip */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--bg-white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(16, 20, 24, 0.03);
  overflow: hidden;
}

.summary-cell {
  padding: 18px 22px;
  border-right: 1px solid var(--line);
}

.summary-cell:last-child {
  border-right: none;
}

.summary-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.summary-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink-1);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.summary-value.brand {
  color: var(--brand);
}

.summary-sub {
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink-2);
}

/* Tabs */
.tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}

.tab-group {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 8px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--ink-1);
}

.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.tab-panel {
  display: none;
  padding: 22px 24px 24px;
}

.tab-panel.active {
  display: block;
}

/* Clean Comparison Block */
.compare-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.compare-row {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-page);
}

.compare-row.is-dp {
  background: var(--brand-soft);
  border-color: var(--brand-border);
}

.compare-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.compare-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-1);
}

.compare-score {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  background: rgba(16, 20, 24, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-fill.dp {
  background: var(--brand);
}

.progress-fill.greedy {
  background: var(--amber);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--bg-white);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-1);
}

.topic-chip span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.insight-line {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: -12px;
  margin-bottom: 22px;
}

/* Study Schedule Timeline */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.timeline {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.timeline-row {
  display: grid;
  grid-template-columns: 155px minmax(0, 1fr) 90px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--line);
}

.timeline-row:last-child {
  border-bottom: none;
}

.timeline-row.is-break {
  background: var(--bg-page);
  padding: 8px 16px;
  font-size: 12px;
  color: var(--ink-3);
}

.timeline-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.timeline-topic {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-1);
}

.timeline-sub {
  font-size: 12px;
  color: var(--ink-3);
}

.timeline-marks {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brand);
}

/* DP Table Visualizer */
.dp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.dp-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--ink-2);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-swatch.take {
  background: var(--brand-soft);
  border: 1.5px solid var(--brand);
}

.legend-swatch.skip {
  background: var(--amber-soft);
  border: 1.5px solid var(--amber);
}

.dp-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.dp-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.dp-table th,
.dp-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 9px;
  text-align: center;
  min-width: 42px;
}

.dp-table th {
  background: var(--bg-subtle);
  color: var(--ink-2);
  font-weight: 700;
}

.dp-table th.row-label {
  text-align: left;
  min-width: 155px;
  background: var(--bg-page);
  color: var(--ink-1);
  font-family: var(--font-sans);
  font-weight: 600;
}

.dp-table td {
  background: var(--bg-white);
  color: var(--ink-2);
  cursor: pointer;
}

.dp-table td:hover {
  background: var(--bg-hover);
}

.dp-table td.path-take {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  outline: 1.5px solid var(--brand);
  outline-offset: -1.5px;
}

.dp-table td.path-skip {
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 600;
  outline: 1.5px solid var(--amber);
  outline-offset: -1.5px;
}

.dp-table td.active-step {
  box-shadow: inset 0 0 0 2px var(--ink-1);
}

.trace-log {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  font-size: 12.5px;
  color: var(--ink-2);
}

.trace-steps {
  margin: 8px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Algorithm Reference */
.formula-block {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: #0B1D17;
  color: #ECFDF5;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
}

.ref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.ref-box {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-page);
}

.ref-box h4 {
  margin: 0 0 8px;
  font-size: 13.5px;
  font-weight: 700;
}

.ref-box ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.alert-warning {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 12.5px;
  margin-bottom: 14px;
}

.empty-state {
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .summary-strip {
    grid-template-columns: 1fr;
  }
  .summary-cell {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .summary-cell:last-child {
    border-bottom: none;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }
  .ref-grid {
    grid-template-columns: 1fr;
  }
  .timeline-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .timeline-marks {
    text-align: left;
  }
}
