/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Bowline brand tokens ──────────────────────────────── */
:root {
  /* Primary brand teal */
  --teal:        #3F8F73;
  --teal-l:      #D9F0E4;
  --teal-m:      #9FCFB4;
  --teal-d:      #1F4F3D;
  --teal-deep:   #0E3D2E;

  /* Secondary palette */
  --lavender:    #7F77DD;
  --lavender-l:  #EEEDFE;
  --lavender-m:  #CECBF6;
  --lavender-d:  #3C3489;
  --peach:       #F0997B;
  --peach-l:     #FAECE7;
  --peach-m:     #F5C4B3;
  --peach-d:     #712B13;
  --amber:       #EF9F27;
  --amber-l:     #FAEEDA;
  --amber-m:     #FAC775;
  --amber-d:     #633806;
  --sky:         #85B7EB;
  --sky-l:       #E6F1FB;
  --sky-m:       #B5D4F4;
  --sky-d:       #0C447C;

  /* Surface + type */
  --text-primary:   #1a1a18;
  --text-secondary: #5f5e5a;
  --text-muted:     #888780;
  --border:         #e8e6df;
  --border-hover:   #d3d1c7;
  --bg-page:        #f7f6f2;
  --bg-card:        #ffffff;
  --font:           'Atkinson Hyperlegible', system-ui, sans-serif;
  --r-sm:           8px;
  --r-md:          12px;
  --r-lg:          18px;
  --r-pill:       999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text-primary:   #f0efe9;
    --text-secondary: #b4b2a9;
    --text-muted:     #888780;
    --border:         rgba(255,255,255,0.12);
    --border-hover:   rgba(255,255,255,0.2);
    --bg-page:        #111110;
    --bg-card:        #1a1a18;
    --teal-l:         #1a3a2c;
    --teal-m:         #2a5d48;
    --teal-d:         #9FCFB4;
    --teal-deep:      #D9F0E4;
    --lavender-l:     #1e1c40;
    --lavender-m:     #3C3489;
    --lavender-d:     #CECBF6;
    --peach-l:        #3d1e14;
    --peach-m:        #712B13;
    --peach-d:        #F5C4B3;
    --amber-l:        #3d2c0a;
    --amber-m:        #854F0B;
    --amber-d:        #FAC775;
    --sky-l:          #0d1e30;
    --sky-m:          #185FA5;
    --sky-d:          #B5D4F4;
  }
}

/* ─── Base ───────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg-page);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
}

/* ─── App shell ──────────────────────────────────────────── */
.app {
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg-card);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--border);
  border-right: 2px solid var(--border);
}

/* ─── Top bar ────────────────────────────────────────────── */
.topbar {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 2px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
  min-height: 80px;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--teal-deep);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.topbar .sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 400;
  line-height: 1.3;
}

/* ─── Bowline brand mark (image) ─────────────────────────── */
.bowline-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 8px;
}

.bowline-mark-lg {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 10px;
}

/* ─── Content area ───────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.25rem 0.5rem;
}

/* ─── Splash screen ──────────────────────────────────────── */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem 2rem;
  text-align: center;
  min-height: calc(100vh - 200px);
}

.splash-lockup {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 100px;
  display: block;
}

.splash-icon {
  width: 110px;
  height: 110px;
  border-radius: 22px;
  margin-bottom: 24px;
}

/* ─── Navigation — 7 items ──────────────────────────────── */
.nav {
  display: flex;
  border-top: 2px solid var(--border);
  background: var(--bg-card);
  padding: 4px 0 2px;
  flex-shrink: 0;
}

.nav button {
  flex: 1;
  padding: 7px 2px 5px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 9px;
  font-family: var(--font);
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color 0.15s;
  letter-spacing: 0.2px;
  min-width: 0;
}

.nav button i { font-size: 20px; }
.nav button.active { color: var(--teal); }
.nav button:hover:not(.active) { color: var(--text-primary); }

/* ─── Screen animation ───────────────────────────────────── */
.screen { animation: fadeIn 0.25s ease; }

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

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.85rem;
}

.card.teal     { border-left: 5px solid var(--teal); }
.card.lavender { border-left: 5px solid var(--lavender); }
.card.peach    { border-left: 5px solid var(--peach); }
.card.amber    { border-left: 5px solid var(--amber); }
.card.sky      { border-left: 5px solid var(--sky); }

.card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.card-main {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}

.card-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ─── Section labels ─────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 1.25rem 0 0.6rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-card);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.15s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  line-height: 1.3;
}

.btn:hover  { background: var(--bg-page); border-color: var(--border-hover); }
.btn:active { transform: scale(0.98); }
.btn i      { font-size: 20px; flex-shrink: 0; }

.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  justify-content: center;
  font-size: 16px;
  padding: 15px;
}
.btn.primary:hover { background: var(--teal-d); border-color: var(--teal-d); }

.btn.lavender  { background: var(--lavender-l); border-color: var(--lavender-m); color: var(--lavender-d); }
.btn.peach     { background: var(--peach-l);    border-color: var(--peach-m);    color: var(--peach-d); }
.btn.sky       { background: var(--sky-l);      border-color: var(--sky-m);      color: var(--sky-d); }
.btn.amber-btn { background: var(--amber-l);    border-color: var(--amber-m);    color: var(--amber-d); }

/* ─── Mood grid ──────────────────────────────────────────── */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.mood-btn {
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.15s;
  text-align: center;
  line-height: 1.3;
}

.mood-btn:hover               { background: var(--bg-page); }
.mood-btn.sel                 { background: var(--teal-l);     border-color: var(--teal);     color: var(--teal-d); }
.mood-btn.foggy.sel           { background: var(--lavender-l); border-color: var(--lavender); color: var(--lavender-d); }
.mood-btn.tired.sel           { background: var(--sky-l);      border-color: var(--sky);      color: var(--sky-d); }
.mood-btn.anxious.sel         { background: var(--amber-l);    border-color: var(--amber);    color: var(--amber-d); }
.mood-btn.over.sel            { background: var(--peach-l);    border-color: var(--peach);    color: var(--peach-d); }

/* ─── Notices ────────────────────────────────────────────── */
.notice {
  border-radius: var(--r-md);
  padding: 1rem 1.1rem;
  font-size: 14px;
  margin-bottom: 0.85rem;
  line-height: 1.7;
  border: 2px solid;
}

.notice.green  { background: var(--teal-l);     border-color: var(--teal-m);     color: var(--teal-d); }
.notice.amber  { background: var(--amber-l);    border-color: var(--amber-m);    color: var(--amber-d); }
.notice.blue   { background: var(--sky-l);      border-color: var(--sky-m);      color: var(--sky-d); }
.notice.purple { background: var(--lavender-l); border-color: var(--lavender-m); color: var(--lavender-d); }
.notice.peach  { background: var(--peach-l);    border-color: var(--peach-m);    color: var(--peach-d); }

/* ─── Task rows ──────────────────────────────────────────── */
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 0.85rem 0;
  border-bottom: 1.5px solid var(--border);
}
.task-row:last-child { border-bottom: none; }

.task-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid var(--border-hover);
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: var(--bg-card);
}
.task-check.done { background: var(--teal); border-color: var(--teal); color: #fff; }

.task-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}
.task-text.done { text-decoration: line-through; color: var(--text-muted); font-weight: 400; }
.task-meta      { font-size: 12px; color: var(--text-muted); margin-top: 3px; font-weight: 400; }

/* ─── Chips ──────────────────────────────────────────────── */
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.chip {
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: all 0.15s;
}
.chip:hover { background: var(--bg-page); }
.chip.sel   { background: var(--teal-l); border-color: var(--teal); color: var(--teal-d); }

/* ─── Tags ───────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
}
.tag.green  { background: var(--teal-l);     color: var(--teal-d); }
.tag.amber  { background: var(--amber-l);    color: var(--amber-d); }
.tag.purple { background: var(--lavender-l); color: var(--lavender-d); }

/* ─── Textarea ───────────────────────────────────────────── */
textarea {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.85rem;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-card);
  resize: vertical;
  min-height: 100px;
  line-height: 1.7;
}
textarea:focus { outline: none; border-color: var(--teal); }

/* ─── AI output ──────────────────────────────────────────── */
.ai-out {
  background: var(--bg-page);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.1rem;
  margin-top: 0.85rem;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.8;
  white-space: pre-wrap;
  font-family: var(--font);
}

/* ─── Progress bar ───────────────────────────────────────── */
.progress-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--teal);
  transition: width 0.4s ease;
}

/* ─── Spinner ────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Support / link cards ───────────────────────────────── */
.link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: all 0.15s;
  cursor: pointer;
}
.link-card:hover { background: var(--bg-page); border-color: var(--border-hover); }

.link-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.link-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.link-sub   { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ─── Accessibility ──────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
