/* ====================================================================
   Design system — "The Console"
   Grounded in Niko's own world: mixing desks, tape saturation, VU
   meters. Warm charcoal instead of blue-black, a copper/teal accent
   pair standing in for a meter's warm (activity) and cool (signal)
   lights, a serif for the coach's voice against mono for the machine's
   readouts.
   ==================================================================== */

:root {
  /* ---- Color ---- */
  --ink: #16130e;
  --panel: #201a12;
  --panel-2: #2b2216;
  --panel-3: #362b1a;
  --line: #3d3122;
  --line-soft: #2b2216;
  --paper: #faf7f0;
  --paper-dim: #c7bba3;
  --paper-faint: #98876d;
  --amber: #e6963f;
  --amber-bright: #f4ac5c;
  --amber-soft: rgba(230, 150, 63, 0.16);
  --teal: #4bbfae;
  --teal-soft: rgba(75, 191, 174, 0.16);
  --coral: #e2604f;
  --coral-soft: rgba(226, 96, 79, 0.15);

  /* Back-compat aliases (existing markup/logic) */
  --bg: var(--ink);
  --surface: var(--panel);
  --surface-2: var(--panel-2);
  --border: var(--line);
  --text: var(--paper);
  --text-dim: var(--paper-dim);
  --accent: var(--amber);
  --accent-2: var(--teal);
  --danger: var(--coral);
  --warn: var(--amber);

  /* ---- Type ---- */
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* ---- Radius ---- */
  --radius-sm: 12px;
  --radius: 22px;
  --radius-lg: 30px;

  /* ---- Shadow (warm-tinted, not neutral black) ---- */
  --shadow-sm: 0 2px 10px rgba(9, 7, 4, 0.35);
  --shadow: 0 24px 60px -20px rgba(9, 7, 4, 0.6);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(230, 150, 63, 0.08), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 20%, rgba(75, 191, 174, 0.05), transparent 55%),
    var(--ink);
  min-height: 100vh;
}

::selection {
  background: var(--amber-soft);
  color: var(--paper);
}

*:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: 6px;
}

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px calc(120px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* ---------- Shell / sidebar (desktop-only nav) ----------
   Mobile has no room for a persistent sidebar and keeps the existing
   sub-page-with-a-back-link pattern — .sidebar is display:none until the
   desktop breakpoint. .app's own max-width + margin:0 auto still centers
   it in the remaining space next to the sidebar there (auto margins on a
   non-growing flex item absorb the leftover space either side). */

.shell {
  width: 100%;
}

.sidebar {
  display: none;
}

@media (min-width: 900px) {
  .shell {
    display: flex;
    align-items: flex-start;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    width: 252px;
    padding: 28px 14px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    overflow: hidden;
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.sidebar-collapsed {
    width: 84px;
  }

  .sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 36px;
    padding: 0 10px;
  }

  .sidebar-brand {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    color: var(--paper);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s ease;
  }

  .sidebar-collapsed .sidebar-brand {
    opacity: 0;
    width: 0;
  }

  .sidebar-toggle {
    background: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--paper-dim);
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.15s ease, color 0.15s ease;
  }

  .sidebar-toggle svg {
    width: 16px;
    height: 16px;
  }

  .sidebar-toggle:hover {
    background: var(--panel-2);
    color: var(--amber);
  }

  .sidebar-collapsed .sidebar-toggle {
    transform: rotate(180deg);
  }

  .sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 10px;
    border-radius: var(--radius-sm);
    color: var(--paper-dim);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .sidebar-link:hover {
    background: var(--panel-2);
    color: var(--paper);
  }

  .sidebar-link-active {
    background: var(--amber-soft);
    color: var(--amber);
  }

  .sidebar-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-icon svg {
    width: 100%;
    height: 100%;
  }

  .sidebar-label {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 11px 0;
  }

  .sidebar-collapsed .sidebar-label {
    display: none;
  }

  /* Actions (check-in, recalibrate, more) — pinned to the bottom, visually
     set apart from the routes above via a divider. Desktop-only: mobile
     keeps its own copy of these in the persistent header instead, since
     it has no sidebar to hold them. */
  .sidebar-actions {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .sidebar-action {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 10px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--paper-dim);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    width: 100%;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .sidebar-action:hover {
    background: var(--panel-2);
    color: var(--paper);
  }

  .sidebar-action:disabled {
    opacity: 0.5;
    cursor: default;
  }

  .sidebar-more {
    position: relative;
  }

  .sidebar-more-dropdown {
    position: absolute;
    left: calc(100% + 10px);
    bottom: 0;
    min-width: 200px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 25;
    animation: riseIn 0.18s ease;
  }

  .sidebar-more-dropdown button {
    background: none;
    border: none;
    color: var(--paper);
    font-family: var(--font-body);
    font-size: 14px;
    text-align: left;
    padding: 11px 14px;
    border-radius: 8px;
    cursor: pointer;
    min-height: 40px;
  }

  .sidebar-more-dropdown button:hover {
    background: var(--panel-3);
  }

  .sidebar-collapsed .sidebar-action {
    justify-content: center;
    padding: 11px 0;
  }

}

/* ---------- Buttons (generic — component sections below may override) ---------- */

.btn-primary,
.btn-ghost {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  min-height: 42px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background: var(--amber);
  color: var(--ink);
}

.btn-primary:hover {
  background: var(--amber-bright);
}

.btn-ghost {
  background: transparent;
  color: var(--paper-dim);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  border-color: var(--paper-dim);
  color: var(--paper);
}

/* ---------- Offline banner ---------- */

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--amber);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
}

/* ---------- Loading / empty states ---------- */

.state-message {
  color: var(--paper-faint);
  font-size: 14px;
  padding: 10px 2px;
}

/* ---------- Ambient level-meter signature ---------- */

.auth-meter,
.chat-panel-meter {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.auth-meter span,
.chat-panel-meter span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--amber-bright), var(--teal));
  opacity: 0.75;
  animation: meter-bounce 2.4s ease-in-out infinite;
}

.auth-meter { justify-content: center; margin-bottom: 28px; height: 34px; }
.auth-meter span { height: 34px; }

.chat-panel-meter { height: 14px; }
.chat-panel-meter span { height: 14px; }

.auth-meter span:nth-child(1) { animation-duration: 2.1s; animation-delay: -0.1s; }
.auth-meter span:nth-child(2) { animation-duration: 1.7s; animation-delay: -1.4s; }
.auth-meter span:nth-child(3) { animation-duration: 2.6s; animation-delay: -0.6s; }
.auth-meter span:nth-child(4) { animation-duration: 1.4s; animation-delay: -2s; }
.auth-meter span:nth-child(5) { animation-duration: 2.3s; animation-delay: -0.3s; }
.auth-meter span:nth-child(6) { animation-duration: 1.9s; animation-delay: -1.1s; }
.auth-meter span:nth-child(7) { animation-duration: 2.5s; animation-delay: -1.8s; }

.chat-panel-meter span:nth-child(1) { animation-duration: 1.9s; animation-delay: -0.3s; }
.chat-panel-meter span:nth-child(2) { animation-duration: 1.5s; animation-delay: -1.1s; }
.chat-panel-meter span:nth-child(3) { animation-duration: 2.2s; animation-delay: -0.6s; }
.chat-panel-meter span:nth-child(4) { animation-duration: 1.7s; animation-delay: -1.6s; }
.chat-panel-meter span:nth-child(5) { animation-duration: 2s; animation-delay: -0.1s; }

@keyframes meter-bounce {
  0%, 100% { transform: scaleY(0.3); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 0.95; }
}

/* ---------- Auth gate ---------- */

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  max-width: 380px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-loading {
  color: var(--paper-dim);
  font-family: var(--font-mono);
  font-size: 14px;
}

.auth-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-eyebrow {
  margin: 0 0 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber);
}

.auth-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--paper);
}

.auth-subtitle {
  margin: 0 0 32px;
  color: var(--paper-dim);
  font-size: 16px;
  line-height: 1.5;
}

.auth-signin-btn {
  padding: 14px 30px;
  font-size: 15px;
  min-height: 52px;
}

.auth-error {
  margin: 16px 0 0;
  color: var(--coral);
  font-size: 13.5px;
}

/* ---------- Header ---------- */

.header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding-top: 4px;
}

.text-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--paper-dim);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 10px 14px;
  min-height: 40px;
  border-radius: 999px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.text-btn:hover {
  color: var(--amber);
  border-color: var(--line);
  background: var(--panel-2);
}

.text-btn-danger {
  color: var(--coral);
  opacity: 0.8;
}

.text-btn-danger:hover {
  color: var(--coral);
  opacity: 1;
}

.more-menu {
  position: relative;
}

.more-menu-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 170px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 25;
  animation: riseIn 0.18s ease;
}

.more-menu-dropdown button {
  background: none;
  border: none;
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 14px;
  text-align: left;
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 40px;
}

.more-menu-dropdown button:hover {
  background: var(--panel-3);
}

.more-menu-dropdown .more-menu-danger {
  color: var(--coral);
}

/* ---------- Mobile nav drawer ---------- */
/* Self-contained (not reusing .sidebar-* classes), since those are styled
   only inside the desktop min-width:900px media query — the sidebar itself
   is display:none below that, so its nav items have no mobile styling. */

#hamburgerBtn {
  display: flex;
  align-items: center;
  justify-content: center;
}

#hamburgerBtn svg {
  width: 18px;
  height: 18px;
}

.nav-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 13, 11, 0.6);
  z-index: 60;
  animation: fadeIn 0.2s ease;
}

.nav-drawer {
  width: min(260px, 78vw);
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  animation: navDrawerSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes navDrawerSlideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.nav-drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 28px;
  padding: 0 10px;
}

.nav-drawer-brand {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--paper);
}

.nav-drawer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-drawer-link {
  display: block;
  padding: 13px 14px;
  border-radius: 10px;
  color: var(--paper-dim);
  text-decoration: none;
  font-size: 15px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-drawer-link:hover {
  background: var(--panel-2);
  color: var(--paper);
}

.nav-drawer-link-active {
  background: var(--amber-soft);
  color: var(--amber);
}

@media (min-width: 900px) {
  .nav-drawer-backdrop {
    display: none !important;
  }
}

.data-error {
  margin: 4px 0 0;
  padding: 12px 16px;
  background: var(--coral-soft);
  border: 1px solid var(--coral);
  border-radius: var(--radius-sm);
  color: var(--coral);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.data-error-dismiss {
  background: none;
  border: none;
  color: var(--coral);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--paper-dim);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.greeting {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--paper);
}

/* ---------- Home hero: greeting + lesson/quote, centered ---------- */

.home-hero {
  text-align: center;
  padding: 24px 12px 8px;
}

.home-hero .eyebrow {
  margin-bottom: 10px;
}

.home-overview-link {
  display: flex;
  justify-content: center;
}

/* ---------- Hero line: a lesson or a quote, under the greeting ---------- */

.hero-line {
  max-width: 620px;
  margin: 4px auto 0;
  padding: 4px 8px;
  text-align: center;
}

.hero-line-text {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 21px;
  line-height: 1.45;
  color: var(--paper-dim);
  letter-spacing: -0.005em;
}

.hero-line-lesson .hero-line-text {
  font-style: normal;
  font-weight: 500;
  color: var(--paper);
}

.icon-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--paper);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--panel-3);
  border-color: var(--amber);
}

.icon-btn:active {
  transform: rotate(180deg);
}

/* ---------- Section labels (shared) ---------- */

.section-eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--paper-faint);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* ---------- Views / navigation ---------- */

.view {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.view-all-link {
  color: var(--teal);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.view-all-link:hover {
  text-decoration: underline;
}

.subpage-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.subpage-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  flex: 1;
}

.back-link {
  color: var(--paper-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: none;
  flex-shrink: 0;
}

.back-link:hover {
  color: var(--amber);
}

.subpage-hint {
  margin: -20px 0 0;
  color: var(--paper-faint);
  font-size: 13.5px;
}

.mini-empty-link {
  color: var(--teal);
  text-decoration: none;
}

.mini-empty-link:hover {
  text-decoration: underline;
}

/* ---------- Priority band (headline) ---------- */

.priority-band {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.priority-band-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.priority-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line-soft);
}

.priority-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 4px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: padding-left 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.25s ease;
}

.priority-item:hover {
  padding-left: 12px;
  background: linear-gradient(90deg, var(--amber-soft), transparent 70%);
}

.priority-rank {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--amber);
  width: 28px;
  flex-shrink: 0;
}

.priority-rank::before {
  content: "0";
}

.priority-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  color: var(--paper);
  letter-spacing: -0.005em;
}

/* ---------- Cards ---------- */

.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-header h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--paper-faint);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.add-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--paper-dim);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.add-btn:hover {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
}

.priority-item,
.goal-item,
.todo-item {
  cursor: pointer;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 9, 5, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  animation: riseIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-wide {
  max-width: 680px;
}

.brief-hint {
  margin: 0 0 20px;
  color: var(--paper-dim);
  font-size: 13.5px;
  line-height: 1.6;
}

#briefText {
  min-height: 320px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

.field-group input[type="file"] {
  min-height: auto;
  padding: 10px;
  background: var(--panel);
  font-size: 13px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--paper-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
}

.modal-close:hover {
  color: var(--paper);
}

.modal-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.field-group-checkbox {
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.field-group-checkbox input {
  min-height: auto;
  width: 20px;
  height: 20px;
}

.field-group label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--paper-faint);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-group input,
.field-group select,
.field-group textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--paper);
  font-size: 15px;
  font-family: var(--font-body);
  min-height: 46px;
}

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

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--teal);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  gap: 10px;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.modal-delete-btn {
  color: var(--coral);
  border-color: var(--coral);
}

/* ---------- Chat panel ("The Console") ---------- */

.chat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.chat-panel-head-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* The Chat sub-page's console — same component, just given the whole
   page instead of living in a fixed-height preview under other content.
   body.chat-route (toggled by renderView() in js/app.js) pins the page to
   the viewport height so only .chat-log scrolls internally, always landing
   on the latest message instead of the whole page growing with history. */
body.chat-route {
  overflow: hidden;
  height: 100dvh;
}

body.chat-route .app {
  height: 100dvh;
  padding-bottom: 20px;
}

body.chat-route #view-chat {
  flex: 1;
  min-height: 0;
}

.chat-panel-full {
  flex: 1;
  min-height: 0;
}

.chat-panel-full .chat-log {
  flex: 1;
  min-height: 0;
  max-height: none;
}

/* ---------- Daily check-in ---------- */

.checkin-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  animation: fadeIn 0.25s ease;
}

.checkin-banner-text {
  margin: 0;
  font-size: 14.5px;
}

.checkin-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.checkin-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checkin-dot {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--paper-faint);
  border: 1px solid var(--line);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.checkin-dot-covered {
  background: var(--teal-soft);
  color: var(--teal);
  border-color: var(--teal);
}

.checkin-end-row {
  display: flex;
  justify-content: center;
}

.checkin-end-btn {
  padding: 7px 16px;
  font-size: 12.5px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
}

.chat-bubble {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

.chat-assistant {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: var(--paper);
}

.chat-user {
  background: var(--teal);
  color: var(--ink);
  font-weight: 500;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-thinking {
  display: flex;
  gap: 4px;
  align-items: center;
  color: var(--paper-faint);
  background: transparent;
  border-color: transparent;
  padding: 13px 4px;
}

.chat-thinking::before,
.chat-thinking::after {
  content: "";
}

.chat-thinking {
  font-size: 0;
}

.chat-thinking::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 12px 0 0 var(--amber), 24px 0 0 var(--amber);
  animation: pulse-dots 1.2s ease-in-out infinite;
}

@keyframes pulse-dots {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-input-row {
  display: flex;
  gap: 10px;
}

.chat-input-row input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  color: var(--paper);
  font-size: 15px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s ease;
}

.chat-input-row input:focus {
  border-color: var(--teal);
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--amber);
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}

.send-btn:hover {
  background: var(--amber-bright);
  transform: translateX(1px);
}

/* ---------- Goals ---------- */

.goal-group {
  margin-bottom: 26px;
}

.goal-group:last-child {
  margin-bottom: 0;
}

.goal-category {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.goal-item {
  margin: 0 -10px 16px;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.goal-item:hover {
  background: var(--panel-2);
}

.goal-item:last-child {
  margin-bottom: 0;
}

.goal-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14.5px;
}

.goal-title {
  font-weight: 500;
}

.goal-item-right {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.goal-item-right .star-btn {
  margin-left: 0;
}

.goal-percent {
  color: var(--paper-faint);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.progress-track {
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--teal));
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Segmented "level meter" ticks overlaid on the track — reads as
   discrete meter blocks rather than a flat gradient bar. */
.progress-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 7px,
    var(--ink) 7px,
    var(--ink) 9px
  );
  pointer-events: none;
}

/* ---------- To-dos ---------- */

.todo-group {
  margin-bottom: 22px;
}

.todo-group:last-child {
  margin-bottom: 0;
}

.todo-bucket-label {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--paper-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  transition: background 0.15s ease;
}

.todo-item:hover {
  background: var(--panel-3);
}

.todo-checkbox {
  position: relative;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.todo-checkbox input {
  opacity: 0;
  width: 26px;
  height: 26px;
  margin: 0;
  cursor: pointer;
}

.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-radius: 8px;
  pointer-events: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.todo-checkbox input:checked ~ .checkmark {
  background: var(--amber);
  border-color: var(--amber);
}

.todo-title {
  flex: 1;
  font-size: 14.5px;
}

.todo-priority {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: 999px;
  flex-shrink: 0;
}

.priority-high {
  background: var(--coral-soft);
  color: var(--coral);
}

.priority-med {
  background: var(--amber-soft);
  color: var(--amber);
}

.priority-low {
  background: var(--teal-soft);
  color: var(--teal);
}

/* ---------- Lessons ---------- */

.lesson-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lesson-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 14.5px;
}

.lesson-title {
  line-height: 1.5;
}

.lesson-item,
.resolution-item {
  cursor: pointer;
  transition: background 0.15s ease;
}

.lesson-item:hover,
.resolution-item:hover {
  background: var(--panel-3);
}

/* ---------- Agenda (Google Calendar) ---------- */

.agenda-widget {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.agenda-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agenda-section {
  margin-bottom: 32px;
}

.agenda-section:last-child {
  margin-bottom: 0;
}

.agenda-section .section-eyebrow {
  margin-bottom: 14px;
}

.agenda-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agenda-item {
  display: flex;
  align-items: baseline;
  gap: 14px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14.5px;
}

.agenda-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber);
  flex-shrink: 0;
  min-width: 68px;
}

.agenda-title {
  color: var(--paper);
}

.agenda-group {
  margin-bottom: 20px;
}

.agenda-group:last-child {
  margin-bottom: 0;
}

.agenda-day-label {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- Resolutions ---------- */

.resolution-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.resolution-item {
  display: flex;
  align-items: center;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 14.5px;
}

/* ---------- Star toggle ---------- */

.star-btn {
  background: none;
  border: none;
  color: var(--paper-faint);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
  flex-shrink: 0;
  transition: color 0.15s ease, transform 0.15s ease;
}

.star-btn:hover {
  color: var(--amber);
  transform: scale(1.1);
}

.star-btn-active {
  color: var(--amber);
}

/* ---------- Mic button ---------- */

.mic-btn {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--amber);
  box-shadow: 0 8px 28px rgba(230, 150, 63, 0.4), 0 0 0 1px var(--line-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
  animation: pulse 3s ease-in-out infinite;
}

.mic-btn:active {
  transform: translateX(-50%) scale(0.94);
}

.mic-icon {
  font-size: 20px;
  color: var(--ink);
}

.mic-btn.mic-unsupported {
  opacity: 0.5;
  animation: none;
}

.mic-btn.mic-listening {
  background: var(--coral);
  box-shadow: 0 8px 28px rgba(226, 96, 79, 0.55), 0 0 0 1px var(--line-soft);
  animation: pulse-listening 1s ease-in-out infinite;
}

@keyframes pulse-listening {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.08); }
}

.mic-btn.mic-speaking {
  background: var(--teal);
  box-shadow: 0 8px 28px rgba(75, 191, 174, 0.55), 0 0 0 1px var(--line-soft);
  animation: pulse-speaking 0.9s ease-in-out infinite;
}

.mic-btn.mic-speaking .mic-icon {
  font-size: 17px;
}

@keyframes pulse-speaking {
  0%, 100% { box-shadow: 0 8px 28px rgba(75, 191, 174, 0.5), 0 0 0 1px var(--line-soft); }
  50% { box-shadow: 0 8px 34px rgba(75, 191, 174, 0.85), 0 0 0 1px var(--line-soft); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 28px rgba(230, 150, 63, 0.35), 0 0 0 1px var(--line-soft); }
  50% { box-shadow: 0 8px 34px rgba(230, 150, 63, 0.6), 0 0 0 1px var(--line-soft); }
}

.bottom-spacer {
  height: 40px;
}

/* ==================== Reduced motion ==================== */

@media (prefers-reduced-motion: reduce) {
  .auth-meter span,
  .header-meter span,
  .chat-panel-meter span,
  .mic-btn,
  .mic-btn.mic-listening,
  .mic-btn.mic-speaking,
  .chat-thinking::before,
  .chat-bubble,
  .checkin-banner,
  .modal,
  .modal-overlay {
    animation: none !important;
  }

  .auth-meter span,
  .header-meter span,
  .chat-panel-meter span {
    transform: scaleY(0.7);
    opacity: 0.8;
  }
}

/* ==================== Desktop ==================== */

@media (min-width: 900px) {
  .app {
    max-width: 1240px;
    padding: 64px 48px calc(150px + env(safe-area-inset-bottom));
    gap: 56px;
  }

  .header {
    gap: 16px;
  }

  /* Desktop's sidebar owns check-in/recalibrate/more now — hide the
     mobile header's copy of the same actions so they don't appear twice. */
  .header-top {
    display: none;
  }

  .greeting {
    font-size: 50px;
  }

  .eyebrow {
    font-size: 13.5px;
  }

  .home-hero {
    padding: 40px 12px 16px;
  }

  .hero-line {
    max-width: 760px;
    margin-top: 12px;
    padding: 8px 8px 4px;
  }

  .hero-line-text {
    font-size: 27px;
  }

  .icon-btn {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }

  .priority-band {
    gap: 22px;
  }

  .priority-list {
    flex-direction: row;
    border-top: none;
    gap: 20px;
  }

  .priority-item {
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 26px 24px;
    border: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
  }

  .priority-item:hover {
    padding-left: 24px;
    border-color: var(--amber);
    background: linear-gradient(160deg, var(--amber-soft), var(--panel) 60%);
    transform: translateY(-3px);
  }

  .priority-rank {
    font-size: 17px;
  }

  .priority-title {
    font-size: 21px;
  }

  /* Goals wide, To-dos wide, Lessons + Resolutions share the third
     column — reflects that they're lighter-weight than the other two. */
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 1fr;
    grid-template-rows: auto auto;
    gap: 24px;
  }

  .dashboard-grid .card:nth-child(1) {
    grid-row: 1 / 3;
  }

  .dashboard-grid .card:nth-child(2) {
    grid-row: 1 / 3;
  }

  .card {
    padding: 30px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .card:hover {
    border-color: #4a3c26;
  }

  .card-header {
    margin-bottom: 22px;
  }

  .add-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
  }

  .todo-item {
    padding: 15px 18px;
  }

  .goal-group {
    margin-bottom: 30px;
  }

  .goal-item {
    padding: 12px;
    margin: 0 -12px 18px;
  }

  .todo-list {
    gap: 10px;
  }

  .todo-group {
    margin-bottom: 26px;
  }

  /* The dashboard grid stretches wide, but a wall-to-wall chat panel at
     1240px reads badly — give it its own centered, readable column. */
  .chat-panel {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 26px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .agenda-widget {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 28px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .chat-log {
    max-height: 380px;
  }

  .chat-bubble {
    font-size: 15px;
    padding: 14px 18px;
  }

  .mic-btn {
    width: 76px;
    height: 76px;
  }

  .mic-icon {
    font-size: 25px;
  }

  .modal {
    max-width: 500px;
    padding: 32px;
    border-radius: var(--radius-lg);
  }

  .modal-wide {
    max-width: 800px;
  }
}
