:root {
  color-scheme: light;
  --bg: #f6f7f1;
  --surface: #ffffff;
  --surface-strong: #eef3ed;
  --ink: #1b2527;
  --muted: #66706c;
  --line: #dbe1da;
  --teal: #2f6f73;
  --teal-dark: #204f53;
  --gold: #f2c94c;
  --coral: #d86a55;
  --blue: #5379b7;
  --green: #5f8f5f;
  --shadow: 0 18px 45px rgba(39, 65, 67, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121819;
    --surface: #1b2425;
    --surface-strong: #243131;
    --ink: #edf3ef;
    --muted: #a9b5b0;
    --line: #334142;
    --teal: #6db5b4;
    --teal-dark: #a4d6d3;
    --gold: #e7bf54;
    --coral: #e78a75;
    --blue: #88a9df;
    --green: #8dbd82;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overscroll-behavior-y: contain;
  background:
    radial-gradient(circle at 14% 4%, rgba(242, 201, 76, 0.16), transparent 24rem),
    linear-gradient(135deg, #f6f7f1 0%, #edf3f0 100%);
  color: var(--ink);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100svh;
}

.boot-fallback {
  display: grid;
  min-height: 100svh;
  place-items: center;
  gap: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.login {
  display: grid;
  min-height: 100svh;
  padding: 22px;
  place-items: center;
}

.login-panel {
  display: grid;
  width: min(100%, 980px);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.login-hero {
  padding: 32px;
  background: #234f52;
  color: white;
}

.brand-row,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: var(--gold);
  font-weight: 900;
}

.login-hero .brand-mark {
  background: rgba(255, 255, 255, 0.14);
}

.brand-title {
  font-size: 20px;
  font-weight: 760;
}

.login h1 {
  max-width: 12ch;
  margin: 42px 0 18px;
  font-size: clamp(42px, 12vw, 74px);
  line-height: 0.93;
  letter-spacing: 0;
}

.login-copy {
  max-width: 38rem;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 17px;
  line-height: 1.55;
}

.login-form {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 28px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 12px 13px;
  outline: 0;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.14);
}

.primary,
.secondary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  gap: 8px;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 760;
}

.primary {
  background: var(--teal);
  color: white;
}

.secondary {
  background: var(--surface-strong);
  color: var(--teal-dark);
}

.ghost {
  background: transparent;
  color: var(--muted);
}

.demo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.demo-btn {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
}

.demo-btn small {
  color: var(--muted);
}

.error {
  min-height: 20px;
  color: #a84233;
  font-size: 14px;
}

.layout {
  display: grid;
  min-height: 100svh;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 241, 0.92);
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  backdrop-filter: blur(18px);
}

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

.user-chip {
  display: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 16px 16px 88px;
  gap: 16px;
}

.side-nav {
  display: none;
}

.mobile-nav {
  position: fixed;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 10px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  padding: 6px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.nav-btn {
  display: grid;
  place-items: center;
  min-height: 48px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.nav-btn svg {
  width: 19px;
  height: 19px;
  margin-bottom: 2px;
}

.nav-btn.active {
  background: var(--teal);
  color: white;
}

.hero {
  display: grid;
  gap: 16px;
  padding: 8px 0;
}

.hero h1 {
  margin: 0;
  max-width: 16ch;
  font-size: clamp(32px, 8vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.focus-strip {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(47, 111, 115, 0.2);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(47, 111, 115, 0.12), rgba(242, 201, 76, 0.16));
  padding: 14px;
}

.focus-strip div,
.insight-grid div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.focus-strip strong,
.insight-grid strong {
  font-size: 16px;
  line-height: 1.35;
}

.grid {
  display: grid;
  gap: 12px;
}

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

.card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 20px rgba(39, 65, 67, 0.06);
}

.card {
  padding: 15px;
}

.panel {
  overflow: hidden;
}

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

.panel-head h2,
.card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.panel-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.stat {
  display: grid;
  gap: 8px;
}

.stat strong {
  font-size: 30px;
  line-height: 1;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--teal-dark);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 760;
}

.pill.gold {
  background: rgba(242, 201, 76, 0.24);
  color: #715a0c;
}

.pill.coral {
  background: rgba(216, 106, 85, 0.14);
  color: #8c3d30;
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8eee8;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

.list {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 11px;
}

.row-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.row-title {
  font-weight: 780;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
}

.time {
  color: var(--teal-dark);
  font-weight: 800;
}

.chart {
  display: grid;
  gap: 12px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 3fr 30px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.semester {
  color: var(--muted);
}

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-chip {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--teal-dark);
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 760;
}

.choice-chip:active {
  transform: translateY(1px);
}

.split {
  display: grid;
  gap: 12px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.install-note {
  max-width: 22rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.install-welcome {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(47, 111, 115, 0.2);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 12px;
}

.install-welcome span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.install-coach {
  position: fixed;
  right: 12px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 12px;
  z-index: 6;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 13px;
  backdrop-filter: blur(18px);
}

.install-coach div:first-child {
  display: grid;
  gap: 4px;
}

.install-coach span,
.install-note-inline {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.install-coach-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pull-hint {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--teal-dark);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  transition: opacity 160ms ease;
}

.pull-hint.show {
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  body {
    background:
      radial-gradient(circle at 14% 4%, rgba(231, 191, 84, 0.12), transparent 24rem),
      linear-gradient(135deg, #121819 0%, #182121 100%);
  }

  .mobile-nav,
  .topbar,
  .install-coach,
  .card,
  .panel,
  .login-panel {
    background: rgba(27, 36, 37, 0.94);
  }

  .progress {
    background: #2b3738;
  }

  .pill {
    background: #263738;
  }

  .pill.gold {
    color: #f1d377;
  }

  .pill.coral {
    color: #efa08f;
  }
}

@media (min-width: 720px) {
  .login-panel {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .workspace {
    grid-template-columns: 210px 1fr;
    padding: 20px;
  }

  .side-nav {
    position: sticky;
    top: 78px;
    display: grid;
    align-self: start;
    gap: 6px;
  }

  .mobile-nav {
    display: none;
  }

  .user-chip {
    display: block;
  }

  .content {
    min-width: 0;
  }

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

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

  .split {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .focus-strip,
  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .install-coach {
    right: 20px;
    bottom: 20px;
    left: auto;
    width: min(420px, calc(100vw - 40px));
  }
}

@media (min-width: 1040px) {
  .workspace {
    gap: 22px;
  }

  .hero {
    grid-template-columns: 1fr minmax(320px, 0.7fr);
    align-items: end;
  }
}
