/* ==========================================================================
   MAT-Family — Design Tokens (monochrome theme)
   Light: black text/icons on white. Dark: white text/icons on black.
   Same signature element as before — the "Day Arc" — just recolored.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500&display=swap');

:root {
  /* Color — light mode: black ink on white paper */
  --ink:        #0D0D0D; /* near-black text/icons */
  --ink-soft:   #6E6E80; /* muted grey secondary text */
  --paper:      #FFFFFF; /* page background */
  --paper-dim:  #F3F3F4; /* card background on paper */
  --gold:       #0D0D0D; /* accent = ink itself (monochrome, no brand hue) */
  --clay:       #D1293D; /* reserved: destructive/urgent only, not decorative */
  --sage:       #4A4A4A; /* reserved: neutral "done/success" grey, not decorative */
  --line:       rgba(13, 13, 13, 0.12);

  /* Type */
  --font-display: 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout */
  --radius: 18px;
  --radius-sm: 10px;
  --gutter: 20px;
  --nav-height: 64px;
  --input-bar-height: 66px;
}

* { box-sizing: border-box; }

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

/* Dark mode — white ink on black paper (the exact inverse of light mode) */
html.dark {
  --paper: #171717;
  --paper-dim: #262626;
  --ink: #ECECEC;
  --ink-soft: #9B9BA5;
  --gold: #ECECEC;
  --clay: #F87171;
  --sage: #B0B0B0;
  --line: rgba(236, 236, 236, 0.14);
}

body {
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- App shell ----------
   Plain block centering (not a flex cross-axis auto-margin) — this is the
   fix for the app rendering flush to one side on wide/desktop viewports. */

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(var(--nav-height) + 12px);
}

.topbar {
  padding: 28px var(--gutter) 4px;
}

.topbar .eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.topbar h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  margin: 4px 0 0;
}

/* ---------- Day Arc (signature element) ---------- */

.day-arc {
  margin: 20px var(--gutter) 8px;
  background: var(--paper-dim);
  border-radius: var(--radius);
  padding: 20px 18px 14px;
}

.day-arc .arc-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.day-arc .arc-label span:first-child {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.day-arc .arc-percent {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
}

.arc-svg { width: 100%; height: auto; display: block; }

.arc-track { stroke: var(--line); stroke-width: 3; fill: none; }
.arc-fill  { stroke: var(--ink); stroke-width: 3; fill: none;
             stroke-linecap: round; transition: stroke-dashoffset .6s ease; }

.arc-node {
  cursor: pointer;
}
.arc-node circle.base {
  fill: var(--paper);
  stroke: var(--line);
  stroke-width: 2;
  transition: fill .25s ease, stroke .25s ease, filter .25s ease;
}
.arc-node:hover circle.base,
.arc-node:focus circle.base {
  stroke: var(--ink);
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--ink) 45%, transparent));
}
.arc-node.done circle.base {
  fill: var(--ink);
  stroke: var(--ink);
}
.arc-node .check {
  fill: var(--paper); /* contrast against the filled ink circle, both themes */
}
.arc-node text {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--ink-soft);
}

/* ---------- Quick links ---------- */

.quick-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px var(--gutter);
}

.quick-links a {
  background: var(--paper-dim);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: border-color .2s ease;
}
.quick-links a:active { border-color: var(--ink); }
.quick-links .icon { font-size: 20px; display: block; margin-bottom: 6px; }

/* ---------- Routine list ---------- */

.section {
  margin: 22px var(--gutter) 0;
}

.section h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 10px;
}

.routine {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}

.routine-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-dim);
}
.routine-row:last-child { border-bottom: none; }

.routine-row .time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  width: 44px;
  flex-shrink: 0;
}

.routine-row .label { flex: 1; font-size: 14px; }

.routine-row.past .label { color: var(--ink-soft); }
.routine-row.now { background: color-mix(in srgb, var(--ink) 8%, var(--paper-dim)); }
.routine-row.now .time { color: var(--ink); font-weight: 600; }

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: var(--nav-height);
  background: var(--paper);
  border-top: 1px solid var(--line);
  z-index: 10;
}

/* CSS Grid with a fixed column count — unlike flex, items can never wrap
   onto a second row here, regardless of content width or viewport size. */
.bottom-nav-inner {
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.bottom-nav a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  font-size: 10.5px;
  color: var(--ink-soft);
}

.bottom-nav a .nav-icon {
  width: 20px;
  height: 20px;
  transition: transform .15s ease;
}

/* LinkedIn-style active tab: bold ink color + a small indicator bar
   under the label, matching the reference screenshot. */
.bottom-nav a.active {
  color: var(--ink);
  font-weight: 600;
}
.bottom-nav a.active .nav-icon { transform: scale(1.08); }
.bottom-nav a.active::after {
  content: '';
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

/* ---------- Sub-page header (back arrow + title) ---------- */

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px var(--gutter) 4px;
}

.page-header .back {
  font-size: 20px;
  line-height: 1;
  padding: 4px;
}

.page-header h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  margin: 0;
}

/* ---------- Subject cards (Homework) ---------- */

.subject-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-dim);
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: box-shadow .2s ease, border-color .2s ease, transform .1s ease;
}

.subject-card + .subject-card { margin-top: 10px; }

.subject-card:hover,
.subject-card:focus-visible {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 14%, transparent);
  outline: none;
}

.subject-card:active { transform: scale(0.99); }

.subject-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: transparent;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.subject-card.done .subject-check {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.subject-info { flex: 1; min-width: 0; }
.subject-info .name {
  font-size: 15px;
  font-weight: 600;
}
.subject-card.done .subject-info .name {
  text-decoration: line-through;
  color: var(--ink-soft);
}

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
/* Urgency kept in a restrained red — the one deliberate exception to the
   monochrome rule, same logic ChatGPT itself uses red only for warnings. */
.badge.due-soon   { border-color: color-mix(in srgb, var(--clay) 50%, var(--line)); color: var(--clay); }
.badge.due-later  { color: var(--ink-soft); }
.badge.done       { color: var(--ink); font-weight: 600; }

.subject-delete {
  color: var(--ink-soft);
  font-size: 16px;
  padding: 8px;
  margin: -8px;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  transition: background .2s ease, color .2s ease;
}
.subject-delete:hover {
  background: color-mix(in srgb, var(--clay) 15%, transparent);
  color: var(--clay);
}

/* ---------- Add form ---------- */

.add-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.add-form input {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.add-form input[name="subject"] { flex: 1; min-width: 0; }
.add-form input[name="due"] { width: 132px; }

.add-form button {
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- AI Tutor chat ---------- */

.chat-page {
  padding-bottom: calc(var(--nav-height) + var(--input-bar-height) + 12px);
}

.chat-intro {
  padding: 4px var(--gutter) 0;
}

.chat-intro h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  margin: 4px 0 2px;
}

.chat-intro p {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0;
}

.prompt-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px var(--gutter) 4px;
  scrollbar-width: none;
}
.prompt-chips::-webkit-scrollbar { display: none; }

.prompt-chip {
  flex-shrink: 0;
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease;
  white-space: nowrap;
  color: var(--ink);
}
.prompt-chip:hover, .prompt-chip:focus-visible {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent);
  outline: none;
}

.chat-log {
  flex: 1;
  padding: 12px var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.45;
}

.msg.ai {
  align-self: flex-start;
  background: var(--paper-dim);
  border-bottom-left-radius: 4px;
}

.msg.user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--paper);
  border-bottom-right-radius: 4px;
}

/* ChatGPT-style "thinking" indicator: a single breathing solid circle,
   ink-colored so it's black on light paper and white on black paper. */
.thinking-indicator {
  align-self: flex-start;
  padding: 10px 14px;
  display: flex;
  align-items: center;
}
.pulse-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  animation: pulseCircle 1.1s ease-in-out infinite;
}
@keyframes pulseCircle {
  0%, 100% { transform: scale(0.72); opacity: 0.45; }
  50%      { transform: scale(1);    opacity: 1;    }
}

/* Fixed, full-width outer bar with a centered inner column — never
   depends on left/right/margin math to find its width. */
.chat-input-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--nav-height);
  width: 100%;
  background: var(--paper);
  border-top: 1px solid var(--line);
  z-index: 9;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.chat-input-bar {
  max-width: 480px;
  margin: 0 auto;
  padding: 10px var(--gutter);
  display: flex;
  gap: 8px;
}

.chat-input-bar input {
  flex: 1;
  min-width: 0;
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-dim);
  color: var(--ink);
}

.chat-input-bar button {
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .2s ease;
}
.chat-input-bar button:hover { opacity: 0.85; }
.chat-input-bar button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Settings: profile switcher & parent lock ---------- */

.profile-now {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-dim);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--line);
}

.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.profile-now-info { flex: 1; min-width: 0; }
.profile-now-info .name { font-weight: 600; font-size: 15px; }
.profile-now-info .role {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s ease, background .2s ease;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { opacity: 0.85; }
.btn-gold { background: var(--ink); color: var(--paper); }
.btn-gold:hover { opacity: 0.85; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink-soft); }
.btn-danger { background: transparent; color: var(--clay); border: 1px solid color-mix(in srgb, var(--clay) 40%, transparent); }

.profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.profile-chip-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px 8px 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.profile-chip-btn:hover {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent);
}
.profile-chip-btn .mini-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--sage); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.profile-chip-btn.is-parent .mini-avatar { background: var(--clay); }
.profile-chip-btn.active { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, var(--paper-dim)); }
.lock-icon { font-size: 11px; opacity: 0.7; }

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.member-row:last-child { border-bottom: none; }
.member-row .member-info { flex: 1; font-size: 14px; }
.member-row .member-info .role-age { color: var(--ink-soft); font-size: 12px; }

.add-member-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.add-member-form input, .add-member-form select {
  font-family: var(--font-body);
  font-size: 13.5px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}
.add-member-form input[name="memberName"] { flex: 1; min-width: 110px; }
.add-member-form input[name="memberAge"] { width: 72px; }

/* Toggle switch (Dark Mode) — also inverts cleanly: black track/white
   knob in light mode, white track/black knob in dark mode. */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper-dim);
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--line);
}
.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: transform .2s ease;
}
.toggle-switch input:checked + .toggle-track { background: var(--ink); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(18px); }

/* Static "coming soon" rows */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  background: var(--paper-dim);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 14px;
}
.settings-row + .settings-row { margin-top: 8px; }
.settings-row .soon {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* PIN modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 13, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--gutter);
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 320px;
}
.modal-box h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 6px;
}
.modal-box p {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 14px;
}
.modal-box input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 20px;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper-dim);
  color: var(--ink);
  margin-bottom: 8px;
}
.modal-error {
  color: var(--clay);
  font-size: 12.5px;
  min-height: 16px;
  margin-bottom: 8px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.modal-actions .btn { flex: 1; }

/* ---------- Accessibility ---------- */

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}