:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-soft: #f9f9fc;
  --text: #1f2430;
  --muted: #687083;
  --border: #dfe3ec;
  --accent: #6d5dfc;
  --accent-soft: #eeeaff;
  --main: #5b66d6;
  --piggyback: #2d9b73;
  --application: #c47f2a;
  --future: #9a6ac7;
  --shadow: 0 10px 30px rgba(31, 36, 48, 0.07);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}
button, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 4vw, 3.15rem); line-height: 1; letter-spacing: -0.04em; }
h2 { margin-bottom: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
h3 { margin-bottom: 8px; font-size: 1rem; line-height: 1.25; }
.subtitle { margin-bottom: 0; color: var(--muted); max-width: 780px; line-height: 1.55; }
.eyebrow { margin-bottom: 5px; text-transform: uppercase; font-weight: 800; letter-spacing: .12em; font-size: .72rem; color: var(--muted); }

.btn, .tab {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 11px;
  padding: 10px 14px;
  min-height: 42px;
}
.btn:hover, .tab:hover { border-color: #b7bfd0; }
.btn:focus-visible, .tab:focus-visible, .project-card:focus-visible, select:focus-visible {
  outline: 3px solid rgba(109, 93, 252, .28);
  outline-offset: 2px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.view { display: none; }
.view.is-active { display: block; }
.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 14px;
}
.section-note { color: var(--muted); max-width: 560px; margin-bottom: 0; text-align: right; font-size: .9rem; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .83rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; }
.legend-dot.main { background: var(--main); }
.legend-dot.piggyback { background: var(--piggyback); }
.legend-dot.application { background: var(--application); }

.map-scroll, .timeline-scroll {
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 9px;
}

.dependency-canvas {
  position: relative;
  min-width: 1250px;
  padding: 26px 26px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    repeating-linear-gradient(90deg, transparent 0 199px, rgba(70,80,105,.035) 200px 201px) border-box;
  box-shadow: var(--shadow);
}

.connector-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 1;
}

.main-label {
  position: relative;
  z-index: 3;
  margin: 13px 0 9px;
  font-size: .71rem;
  letter-spacing: .14em;
  font-weight: 900;
  color: var(--muted);
}

.main-spine {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr) 28px) minmax(0, 1fr);
  align-items: center;
  gap: 4px;
}

.spine-arrow {
  color: #9aa2b2;
  text-align: center;
  font-size: 1.4rem;
}

.branch-row {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 30px;
  min-height: 155px;
  align-items: center;
}
.branch-row-top { margin-bottom: 8px; }
.branch-row-bottom { margin-top: 8px; }

.project-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--panel-soft);
  padding: 15px;
  color: var(--text);
  text-align: left;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, opacity .16s ease;
}
.project-card:hover { transform: translateY(-2px); box-shadow: 0 9px 23px rgba(31,36,48,.09); }
.project-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,93,252,.11); }
.project-card p { color: var(--muted); font-size: .83rem; line-height: 1.42; margin-bottom: 12px; }
.project-card h3 { padding-right: 4px; }
.stage-card { min-height: 142px; background: #fbfbff; }
.stage-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--main);
  border-radius: 15px 0 0 15px;
}
.branch-card { min-height: 128px; }
.storage, .process { border-left: 5px solid var(--piggyback); }
.skin { border-left: 5px solid var(--application); }
.poly { border-left: 5px solid var(--future); }
.project-type { color: var(--muted); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 800; margin-bottom: 6px; }
.stage-number {
  width: 27px; height: 27px; display: grid; place-items: center; border-radius: 999px;
  background: #e9ebff; color: #404aad; font-weight: 900; font-size: .78rem; margin-bottom: 10px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: .7rem;
  font-weight: 800;
  border: 1px solid transparent;
}
.status-active { background: #dff6ec; color: #146347; border-color: #bfe8d7; }
.status-next { background: #e8edff; color: #3548a3; border-color: #d4dcff; }
.status-ready { background: #e6f6f1; color: #256a56; border-color: #cde9e0; }
.status-waiting { background: #fff1d9; color: #805818; border-color: #f1dfbb; }
.status-parked { background: #eceef2; color: #626a78; border-color: #dde0e6; }
.status-done { background: #e3f5de; color: #366f29; border-color: #c9e8c0; }

.detail-panel {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.detail-panel > div:first-child { max-width: 900px; }
.detail-panel > div:first-child p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.detail-grid > div {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.detail-grid p { margin-bottom: 0; font-size: .86rem; line-height: 1.45; }
.detail-label { display: block; color: var(--muted); font-weight: 800; text-transform: uppercase; font-size: .66rem; letter-spacing: .08em; margin-bottom: 5px; }
.detail-bottom {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 22px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.status-editor label { display: block; font-weight: 700; margin-bottom: 7px; font-size: .82rem; }
.status-editor select { width: 100%; min-height: 42px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--panel); color: var(--text); }
.project-checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.check-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 9px; background: var(--panel-soft); font-size: .82rem; line-height: 1.35; }
.check-item input { margin-top: 2px; }
.check-item.is-complete span { text-decoration: line-through; color: var(--muted); }

.timeline {
  min-width: 1200px;
  display: grid;
  grid-template-columns: 210px repeat(10, minmax(88px, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--border);
  box-shadow: var(--shadow);
}
.timeline-cell { background: var(--panel); padding: 11px 10px; min-height: 58px; }
.timeline-head { background: #f1f3f8; font-size: .75rem; font-weight: 800; text-align: center; }
.timeline-row-label { font-weight: 800; font-size: .84rem; display: flex; flex-direction: column; justify-content: center; }
.timeline-row-label small { color: var(--muted); font-weight: 500; margin-top: 3px; }
.timeline-bar { min-height: 58px; display: flex; align-items: center; padding: 8px; font-size: .75rem; line-height: 1.3; font-weight: 750; }
.timeline-bar.main { background: #e7e9ff; color: #35408d; }
.timeline-bar.piggyback { background: #ddf3eb; color: #1f654f; }
.timeline-bar.application { background: #fff0db; color: #87591d; }
.timeline-bar.future { background: #f0e7f8; color: #6c438c; }
.timeline-empty { background: var(--panel); }

.focus-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.focus-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow);
}
.focus-card.primary-focus { border-top: 5px solid var(--main); }
.focus-card.muted-focus { background: #f0f1f4; box-shadow: none; }
.focus-label { display: inline-block; color: var(--muted); font-size: .68rem; font-weight: 900; letter-spacing: .12em; margin-bottom: 10px; }
.focus-card p { color: var(--muted); line-height: 1.55; font-size: .9rem; }
.mini-checklist { display: grid; gap: 7px; }
.mini-checklist .check-item { background: var(--panel-soft); }

footer { color: var(--muted); font-size: .78rem; margin-top: 22px; text-align: center; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-bottom { grid-template-columns: 1fr; }
  .focus-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-note { text-align: left; }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 20px, 1500px); padding-top: 18px; }
  .topbar { flex-direction: column; }
  .topbar-actions, .topbar-actions .btn { width: 100%; }
  .detail-grid, .project-checklist { grid-template-columns: 1fr; }
  .view-tabs { display: grid; grid-template-columns: 1fr; }
  h1 { font-size: 2.15rem; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121419;
    --panel: #1b1e25;
    --panel-soft: #20242c;
    --text: #f0f2f6;
    --muted: #a9b0bf;
    --border: #343945;
    --accent-soft: #302b57;
    --shadow: 0 10px 30px rgba(0,0,0,.18);
  }
  .stage-card { background: #20232c; }
  .stage-number { background: #30365d; color: #d5d9ff; }
  .timeline-head { background: #242934; }
  .timeline-bar.main { background: #2c3150; color: #e0e3ff; }
  .timeline-bar.piggyback { background: #1f3d34; color: #d3f5e8; }
  .timeline-bar.application { background: #463621; color: #ffe7c4; }
  .timeline-bar.future { background: #3b2d48; color: #ecdafa; }
  .status-active { background: #173b30; color: #baf0db; border-color: #285845; }
  .status-next { background: #292e50; color: #d8ddff; border-color: #3a426e; }
  .status-ready { background: #1c3c34; color: #c7eee3; border-color: #31594f; }
  .status-waiting { background: #49371f; color: #ffdfaa; border-color: #664b28; }
  .status-parked { background: #2b2f37; color: #c6cbd5; border-color: #3e434e; }
  .status-done { background: #213a22; color: #c9efc5; border-color: #335534; }
  .focus-card.muted-focus { background: #191c22; }
}

/* Editable planner */
[hidden] { display: none !important; }
input, textarea { font: inherit; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.save-status { color: var(--muted); font-size: .85rem; min-height: 1.2em; }
.is-error, .form-error { color: #ba3434; }
.map-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.map-tools p { flex: 1; margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.map-tools .btn { flex-shrink: 0; }
.map-scroll { height: 570px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.dependency-canvas { min-width: 1100px; padding: 0; border: 0; box-shadow: none; background: radial-gradient(var(--border) 1px, transparent 1px) 0 0 / 20px 20px, var(--panel); }
.movable-card { position: absolute; z-index: 2; width: 240px; height: 206px; padding: 0; overflow: hidden; transition: box-shadow .16s, border-color .16s; }
.movable-card:hover { transform: none; }
.movable-card.is-dragging { z-index: 4; box-shadow: var(--shadow); }
.drag-handle { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0; background: transparent; color: var(--muted); padding: 7px 12px; text-align: right; font-size: .75rem; cursor: grab; touch-action: none; user-select: none; }
.is-dragging .drag-handle { cursor: grabbing; }
.card-select { display: block; width: 100%; height: 171px; border: 0; padding: 12px; background: transparent; color: var(--text); text-align: left; }
.card-select h3 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .95rem; overflow-wrap: anywhere; }
.card-select p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 6px 0 10px; overflow-wrap: anywhere; }
.card-select .project-type { display: block; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #a59aff; outline-offset: 2px; }
.empty-map { padding: 35px; }
.detail-actions { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.danger { color: #b94040; }
.dependency-link { display: block; margin: 3px 0; border: 0; background: transparent; padding: 3px 0; color: var(--accent); text-align: left; text-decoration: underline; font-size: .86rem; }
.focus-title { display: block; background: transparent; border: 0; padding: 0; font-size: 1.1rem; font-weight: 750; color: var(--text); text-align: left; margin: 8px 0 12px; }
.year-control { display: block; margin: 0 0 12px; font-size: .9rem; }
.year-control select { padding: 6px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }
.timeline-bar.independent { background: #dcedf2; color: #195264; }
.timeline-row-label { border: 0; color: var(--text); text-align: left; overflow-wrap: anywhere; }
dialog { color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 24px; width: min(720px, calc(100vw - 24px)); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 80px #0005; }
dialog::backdrop { background: #12141999; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.editor-grid .full { grid-column: 1 / -1; }
.editor-grid label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 650; }
.editor-grid input:not([type=checkbox]), .editor-grid textarea, .editor-grid select { width: 100%; min-height: 42px; border: 1px solid var(--border); border-radius: 8px; padding: 9px; color: var(--text); background: var(--panel-soft); }
.editor-grid textarea { resize: vertical; }
.editor-grid fieldset { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; }
.field-help { color: var(--muted); font-size: .8rem; font-weight: 400; line-height: 1.5; }
.dependency-options { max-height: 210px; overflow-y: auto; display: grid; gap: 5px; }
.dependency-options label { flex-direction: row; font-weight: 400; }
.dialog-footer { margin-top: 18px; display: flex; justify-content: flex-end; }
.form-error:empty { display: none; }
.detail-panel p, .focus-card p { overflow-wrap: anywhere; }
@media (max-width: 620px) { .map-tools { flex-wrap: wrap; } .map-tools p { flex-basis: 100%; } .editor-grid { grid-template-columns: 1fr; } .map-scroll { height: 460px; } .topbar-actions .btn { width: auto; } .topbar-actions { justify-content: flex-start; } }


/* Weekly undergraduate planning */
.weekly-toolbar { display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between; align-items: center; margin: 0 0 18px; }
.week-nav { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.week-nav h3 { margin: 0; font-size: 1.05rem; min-width: 210px; text-align: center; }
.undergrad-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.weekly-stat { padding: 10px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; font-size: .85rem; color: var(--muted); }
.weekly-stat strong { font-size: 1.03rem; color: var(--text); margin-right: 6px; }
.undergrad-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.undergrad-column { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-height: 210px; }
.undergrad-column-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.undergrad-column-heading h3 { margin: 0; font-size: 1.18rem; }
.undergrad-column-heading .btn { padding: 7px 10px; min-height: 35px; }
.weekly-empty { padding: 20px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.weekly-task-list { display: grid; gap: 12px; }
.weekly-task { border: 1px solid var(--border); background: var(--panel-soft); border-radius: 13px; padding: 15px; }
.weekly-task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.weekly-task-title { font-weight: 800; font-size: .97rem; margin-bottom: 7px; line-height: 1.35; overflow-wrap: anywhere; }
.weekly-task-meta { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin: 8px 0 12px; font-size: .76rem; color: var(--muted); }
.weekly-tag { border: 1px solid var(--border); border-radius: 8px; padding: 4px 7px; background: var(--panel); }
.weekly-late { color: #b04b35; border-color: #d59b89; }
.weekly-task-note { color: var(--muted); font-size: .83rem; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; margin: 9px 0; }
.weekly-task-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.weekly-status { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 7px 8px; max-width: 180px; font: inherit; font-size: .79rem; }
.weekly-task-goals { display: grid; gap: 6px; margin: 10px 0; }
.weekly-task-goals .check-item { background: var(--panel); }
.weekly-goal-progress { color: var(--muted); font-size: .75rem; margin: 7px 0 0; }
.weekly-dialog-actions { justify-content: space-between; }
#weeklyGoalDialog { max-width: min(720px, calc(100vw - 30px)); width: 100%; }
#weeklyGoalDialog input, #weeklyGoalDialog select, #weeklyGoalDialog textarea { color: var(--text); background: var(--panel); }
@media (max-width: 800px) {
  .undergrad-columns { grid-template-columns: 1fr; }
  .weekly-toolbar .section-note { text-align: left; }
}

/* Email delivery controls */
.undergrad-email-settings { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 18px; margin: 0 0 18px; }
.undergrad-email-settings h3 { margin: 0 0 5px; }
.undergrad-email-form, .gmail-client-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.undergrad-email-form label, .gmail-client-form label { flex: 1; min-width: min(210px, 100%); font-size: .85rem; font-weight: 650; }
.undergrad-email-form input, .gmail-client-form input { display: block; margin-top: 6px; width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-soft); color: var(--text); font: inherit; }
.gmail-direct-settings { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.gmail-direct-settings summary { cursor: pointer; font-weight: 650; font-size: .89rem; }
.gmail-direct-settings p { margin: 12px 0; line-height: 1.5; }
.undergrad-email-status { min-height: 18px; margin: 9px 0 0; font-size: .84rem; color: var(--muted); }
.undergrad-email-status.is-error { color: #b04b35; }
.undergrad-mail-actions { display: flex; gap: 8px; margin: 3px 0 15px; flex-wrap: wrap; }
.undergrad-mail-actions .btn { font-size: .8rem; min-height: 36px; padding: 8px 11px; }
.undergrad-mail-actions .btn:disabled { opacity: .5; cursor: not-allowed; }
