:root {
  color-scheme: light;

  /* Surface */
  --bg:         oklch(0.970 0.005 145);
  --panel:      oklch(1.000 0.000 0);
  --panel-2:    oklch(0.985 0.003 145);

  /* Lines */
  --line:       oklch(0.908 0.012 155);
  --line-strong:oklch(0.845 0.016 155);

  /* Text */
  --text:       oklch(0.200 0.023 155);
  --muted:      oklch(0.490 0.019 155);
  --subtle:     oklch(0.627 0.016 155);

  /* Accent */
  --accent:       oklch(0.542 0.088 140);
  --accent-dark:  oklch(0.468 0.088 140);
  --accent-soft:  oklch(0.953 0.025 145);
  --accent-line:  oklch(0.870 0.040 145);

  /* Semantic */
  --warning: oklch(0.568 0.112 78);
  --danger:  oklch(0.518 0.122 25);

  /* Elevation */
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.05);
  --shadow:    0 1px 3px oklch(0 0 0 / 0.06), 0 1px 2px -1px oklch(0 0 0 / 0.04);

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t: 160ms;

  /* Dark sidebar palette */
  --ink:        oklch(0.14 0.028 145);
  --ink-2:      oklch(0.19 0.030 145);
  --ink-3:      oklch(0.23 0.032 145);
  --ink-line:   oklch(0.24 0.030 145);
  --ink-text:   oklch(0.93 0.008 145);
  --ink-muted:  oklch(0.54 0.022 145);
  --ink-subtle: oklch(0.40 0.018 145);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.is-hidden {
  display: none !important;
}

/* ─── Layout ─── */

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

/* ─── Sidebar (dark) ─── */

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  height: 100vh;
  padding: 1.5rem 1rem;
  background: var(--ink);
  border-right: 1px solid var(--ink-line);
  overflow-y: auto;
}

.brand {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  align-items: center;
  gap: 0.8rem;
  min-height: 2.75rem;
  padding: 0 0.25rem;
}

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

.brand strong {
  color: var(--ink-text);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand small {
  margin-top: 0.1rem;
  color: var(--ink-muted);
  font-size: 0.7rem;
}

.brand-mark,
.nav-icon,
.step-badge {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--accent);
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: 9px;
}

.brand-mark svg {
  width: 1.3rem;
  height: 1.3rem;
}

/* Nav */

.module-nav {
  display: grid;
  gap: 0.2rem;
}

.module-link {
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  min-height: 4rem;
  padding: 0.7rem 0.65rem;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background var(--t) var(--ease),
              border-color var(--t) var(--ease),
              color var(--t) var(--ease);
}

.module-link strong,
.module-link small {
  display: block;
}

.module-link strong {
  color: oklch(0.80 0.010 145);
  font-size: 0.875rem;
  font-weight: 600;
}

.module-link small {
  margin-top: 0.08rem;
  color: var(--ink-subtle);
  font-size: 0.72rem;
}

.module-link:hover,
.module-link:focus-visible {
  background: var(--ink-2);
  border-color: var(--ink-3);
  outline: none;
}

.module-link.active {
  background: var(--ink-2);
  border-color: oklch(0.32 0.045 145);
  outline: none;
}

.module-link.active .module-link strong,
.module-link.active strong {
  color: var(--ink-text);
}

.nav-icon {
  width: 2.1rem;
  height: 2.1rem;
  color: var(--ink-subtle);
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  border-radius: 7px;
  transition: color var(--t) var(--ease),
              background var(--t) var(--ease),
              border-color var(--t) var(--ease);
}

.module-link.active .nav-icon {
  color: var(--accent);
  background: oklch(0.20 0.040 145);
  border-color: oklch(0.32 0.050 145);
}

.nav-icon svg {
  width: 1rem;
  height: 1rem;
}

/* Side info panel */

.side-panel {
  margin-top: auto;
  padding: 1rem;
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  border-radius: 8px;
}

.side-label {
  margin: 0 0 0.2rem;
  color: var(--ink-subtle);
  font-size: 0.7rem;
  font-weight: 600;
}

.side-panel strong {
  display: block;
  color: var(--ink-text);
  font-size: 0.9rem;
  font-weight: 700;
}

.side-panel p:not(.side-label) {
  margin: 0.5rem 0 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.side-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--ink-line);
}

.side-stats span {
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 700;
}

.side-stats small {
  color: var(--ink-subtle);
  font-size: 0.75rem;
}

/* ─── Main content ─── */

.main-content {
  min-width: 0;
  padding: 1.75rem 2rem 2.5rem;
}

/* Topbar */

.topbar {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) auto minmax(18rem, auto);
  gap: 1.25rem;
  align-items: center;
  max-width: 82rem;
  margin: 0 auto 1.5rem;
}

.topbar-left {
  min-width: 0;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.22;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: 1.3rem;
  font-weight: 700;
}

h2 {
  font-size: 1rem;
  font-weight: 700;
}

h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

/* Channel switch */

.channel-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem;
  background: oklch(1.000 0.000 0);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.channel-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0 0.85rem;
  color: var(--muted);
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
  transition: color var(--t) var(--ease),
              background var(--t) var(--ease);
}

.channel-switch a:hover,
.channel-switch a:focus-visible {
  color: var(--text);
  background: var(--panel-2);
  outline: none;
}

.channel-switch a.active {
  color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

/* Topbar actions */

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  min-width: 0;
}

.user-chip,
.admin-entry,
.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: oklch(1.000 0.000 0);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: color var(--t) var(--ease),
              background var(--t) var(--ease),
              border-color var(--t) var(--ease);
}

.user-chip {
  gap: 0.5rem;
  min-height: 2.35rem;
  max-width: 14rem;
  padding: 0 0.7rem 0 0.3rem;
}

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--accent-soft);
  border-radius: 6px;
}

.user-name {
  min-width: 0;
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-entry {
  gap: 0.4rem;
  min-height: 2.35rem;
  padding: 0 0.75rem;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
}

.admin-entry svg {
  width: 1rem;
  height: 1rem;
}

.icon-button {
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
}

.icon-button:hover,
.icon-button:focus-visible,
.text-button:hover,
.text-button:focus-visible,
.admin-entry:hover,
.admin-entry:focus-visible,
.user-chip:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
  outline: none;
}

/* ─── Ops overview ─── */

.ops-grid,
.workspace-layout {
  max-width: 82rem;
  margin: 0 auto;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.metric-card,
.content-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.status-dot,
.dot {
  width: 0.45rem;
  height: 0.45rem;
  background: var(--accent);
  border-radius: 999px;
  flex: 0 0 auto;
}

/* Metric cards */

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 8.5rem;
  padding: 1.4rem 1.5rem;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1.5rem;
  right: 1.5rem;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
  opacity: 0.5;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.metric-card strong {
  display: block;
  color: var(--text);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-top: 0.6rem;
}

.metric-card small {
  margin-top: auto;
  padding-top: 0.85rem;
  color: var(--subtle);
  font-size: 0.75rem;
}

/* ─── Workspace ─── */

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.38fr);
  gap: 1rem;
  margin-top: 1rem;
}

.content-panel {
  min-width: 0;
  padding: 1.25rem;
}

.compact-panel {
  grid-row: span 2;
}

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

.section-heading.stacked {
  align-items: flex-start;
}

.text-button {
  gap: 0.4rem;
  min-height: 2.1rem;
  padding: 0 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.text-button svg {
  width: 0.9rem;
  height: 0.9rem;
}

/* Resource rows */

.resource-list,
.course-track {
  display: grid;
  gap: 0.65rem;
}

.resource-row {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  min-height: 4.5rem;
  padding: 0.85rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color var(--t) var(--ease),
              box-shadow var(--t) var(--ease);
}

.resource-row:hover,
.resource-row:focus-visible {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  outline: none;
}

.resource-type {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 1.75rem;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--accent-soft);
  border-radius: 5px;
  letter-spacing: 0.02em;
}

.resource-row strong,
.notice-list strong,
.track-node strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
}

.resource-row p,
.notice-list p,
.track-node p {
  margin: 0.18rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.row-state {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
  padding: 0 0.55rem;
  color: var(--subtle);
  font-size: 0.72rem;
  font-weight: 600;
  background: oklch(1.000 0.000 0);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.row-state.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

/* Course track */

.track-node {
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr);
  gap: 0.85rem;
  align-items: center;
  min-height: 4.25rem;
  padding: 0.85rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color var(--t) var(--ease);
}

.track-node span {
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  color: var(--subtle);
  font-size: 0.75rem;
  font-weight: 700;
  background: oklch(1.000 0.000 0);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.track-node.done span,
.track-node.current span {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.track-node.current {
  border-color: var(--line-strong);
}

/* Notice list */

.notice-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.notice-list li {
  display: grid;
  grid-template-columns: 0.55rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.notice-list li:first-child {
  padding-top: 0;
}

.notice-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.dot {
  margin-top: 0.4rem;
  flex: 0 0 auto;
}

.dot.blue {
  background: var(--accent);
}

.dot.yellow {
  background: var(--warning);
}

/* ─── Legacy: .eyebrow → neutral label ─── */
.eyebrow {
  display: none;
}

/* ─── Responsive ─── */

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .channel-switch,
  .topbar-actions {
    justify-self: start;
  }
}

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

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

  .module-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .module-link {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 0.75rem 0.6rem;
  }

  .side-panel {
    display: none;
  }

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

  .compact-panel {
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: 1rem;
  }

  .brand small {
    white-space: normal;
  }

  .module-nav {
    grid-template-columns: 1fr;
  }

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

  .channel-switch,
  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .channel-switch a {
    flex: 1 1 0;
  }

  .primary-panel,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .resource-row {
    grid-template-columns: 2.75rem minmax(0, 1fr);
  }

  .row-state {
    grid-column: 2;
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
