:root {
  --bg: var(--tg-theme-bg-color, #0f1012);
  --bg-soft: var(--tg-theme-secondary-bg-color, #1a1c1f);
  --fg: var(--tg-theme-text-color, #f1f1f3);
  --fg-mute: var(--tg-theme-hint-color, #8b8f96);
  --accent: var(--tg-theme-button-color, #6aa7ff);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #6aa7ff);
  --border: rgba(255,255,255,0.07);
  --card: rgba(255,255,255,0.04);
  --ok: #47c97a;
  --warn: #f0b84a;
  --danger: #e05c5c;
  --radius: 14px;
  --radius-sm: 10px;
  --nav-height: 66px;
  /* Composed height of the fixed chat-form. Used both by .chat-form bottom
   * offset and .chat-scroll bottom padding — keep the two in sync via a
   * single variable so a padding tweak doesn't silently desync them. */
  --chat-form-height: 76px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100vh;
}

/* Room for the fixed bottom nav + iOS home indicator. */
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

#main {
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
}

.view-loading .hero-sub::after { content: " ⏳"; }

/* =============================================================== HERO */

.hero {
  padding: 24px 0 20px;
}
.hero-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.streak-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
}
.streak-badge .streak-num {
  font-size: 22px;
  line-height: 1;
  color: var(--fg);
}
.streak-badge .streak-lbl {
  color: var(--fg-mute);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hero-eye {
  font-size: 30px;
  filter: drop-shadow(0 0 18px rgba(106,167,255,0.25));
}

.hero-title {
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0 6px;
  letter-spacing: -0.01em;
}
.hero-sub {
  color: var(--fg-mute);
  margin: 0 0 16px;
  font-size: 15px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.action {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 14px 12px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  font: inherit;
}
.action .ico { font-size: 22px; }
.action:active { transform: scale(0.98); }
.action:focus-visible,
.secondary-btn:focus-visible,
.primary-btn:focus-visible,
.quick:focus-visible,
.link:focus-visible,
.video-item:focus-visible,
.focus-video:focus-visible,
.cat-item:focus-visible,
.article-item:focus-visible,
.nav-item:focus-visible,
.back-btn:focus-visible,
.chat-send:focus-visible,
.chat-suggest:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.action[data-done="true"] {
  background: color-mix(in srgb, var(--ok) 18%, var(--card));
  border-color: color-mix(in srgb, var(--ok) 35%, var(--border));
}
.action[data-done="true"]::after {
  content: " ✓";
  color: var(--ok);
  font-weight: 700;
}

/* =============================================================== PAGE HERO */

.page-hero {
  padding: 20px 0 10px;
}
.page-title {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.page-sub {
  color: var(--fg-mute);
  margin: 0 0 4px;
  font-size: 14px;
}

/* =============================================================== VIEW + CARDS */

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card.muted { opacity: 0.75; }
.card-eyebrow {
  color: var(--fg-mute);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}
.card-body {
  color: var(--fg);
  font-size: 15px;
  line-height: 1.55;
}
.card-body p { margin: 0 0 10px; }
.card-body p:last-child { margin-bottom: 0; }

/* =============================================================== SCHEDULE LIST */

.sched {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sched li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.sched li:last-child { border-bottom: none; }
.sched .time { color: var(--fg-mute); font-variant-numeric: tabular-nums; }
.sched .badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--fg-mute);
  white-space: nowrap;
}
.sched .badge.done { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.sched .badge.pending { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.sched .badge.off { background: var(--bg-soft); color: var(--fg-mute); }

/* =============================================================== HISTORY STRIP */

.history-strip {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 4px;
  padding: 4px 0 10px;
}
.history-dot {
  aspect-ratio: 1;
  border-radius: 4px;
  background: transparent;
  border: 1px solid var(--border);
  transition: transform .08s;
  min-width: 0;
}
.history-dot.today {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.history-dot.done { background: var(--ok); border-color: var(--ok); }
.history-dot.partial { background: var(--warn); border-color: var(--warn); }
.history-dot.missed { background: transparent; }

.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--fg-mute);
  font-size: 12px;
  margin-top: 6px;
}
.history-legend .legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 1px solid var(--border);
}
.history-legend .legend-dot.done { background: var(--ok); border-color: var(--ok); }
.history-legend .legend-dot.partial { background: var(--warn); border-color: var(--warn); }
.history-legend .legend-dot.missed { background: transparent; }

/* =============================================================== CATEGORIES */

.cat-list { display: flex; flex-direction: column; gap: 10px; }
.cat-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 44px 1fr 14px;
  gap: 12px;
  align-items: center;
  transition: background .15s, transform .08s;
  text-align: left;
  color: var(--fg);
  font: inherit;
}
.cat-item:active { transform: scale(0.995); }
.cat-item .cat-emoji {
  font-size: 28px;
  line-height: 1;
  text-align: center;
}
/* Explicit block so margin-bottom actually applies (these are <span>s). */
.cat-item .cat-title { display: block; font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.cat-item .cat-blurb { display: block; color: var(--fg-mute); font-size: 13px; line-height: 1.4; }
.cat-item .chev { color: var(--fg-mute); font-size: 18px; line-height: 1; }

/* =============================================================== ARTICLE LIST */

.article-list { display: flex; flex-direction: column; gap: 8px; }
.article-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  color: var(--fg);
  font: inherit;
  transition: background .15s;
}
.article-item:active { background: var(--bg-soft); }
.article-item .art-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.article-item .art-sum { color: var(--fg-mute); font-size: 13px; line-height: 1.45; margin-bottom: 6px; }
.article-item .art-meta { color: var(--fg-mute); font-size: 12px; }

/* =============================================================== ARTICLE VIEW */

.article { padding: 4px 2px 16px; }
.article h1 { font-size: 22px; font-weight: 800; line-height: 1.2; margin: 8px 0 14px; }
.article .art-meta-top { color: var(--fg-mute); font-size: 13px; margin-bottom: 18px; }
.article p { margin: 0 0 12px; font-size: 16px; line-height: 1.6; }
.article ul, .article ol { padding-left: 22px; margin: 0 0 12px; }
.article ul li, .article ol li { margin-bottom: 6px; font-size: 16px; line-height: 1.55; }
.article b { color: var(--fg); font-weight: 700; }
.article i { color: var(--fg); }

.back-btn {
  align-self: flex-start;
  background: transparent;
  border: none;
  color: var(--link);
  padding: 8px 4px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 4px;
  font: inherit;
}
.back-btn:active { opacity: 0.6; }

/* =============================================================== QUICK LINKS */

#quickLinks { display: flex; flex-direction: column; gap: 6px; }
.quick {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--fg);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  width: 100%;
}
.quick:last-child { border-bottom: none; }
.quick .chev { color: var(--fg-mute); }

/* =============================================================== SETTINGS */

.kv {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kv li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.kv li:last-child { border-bottom: none; }
.kv .k { color: var(--fg-mute); }
.kv .v { color: var(--fg); font-weight: 600; text-align: right; }

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toggle-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.toggle-row:last-child { border-bottom: none; }
.toggle-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toggle-title {
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
}
.toggle-meta {
  color: var(--fg-mute);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-switch {
  width: 48px;
  height: 28px;
  flex: 0 0 48px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  transition: background .15s ease, border-color .15s ease;
}
.toggle-switch::after {
  content: "";
  display: block;
  width: 22px;
  height: 22px;
  margin: 2px;
  border-radius: 50%;
  background: var(--fg-mute);
  transition: transform .15s ease, background .15s ease;
}
.toggle-input:checked + .toggle-switch {
  background: color-mix(in srgb, var(--accent) 36%, var(--bg-soft));
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
}
.toggle-input:checked + .toggle-switch::after {
  transform: translateX(20px);
  background: var(--accent-fg);
}
.toggle-input:focus-visible + .toggle-switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.toggle-input:disabled + .toggle-switch {
  opacity: 0.6;
}

.cmds {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}
.cmds li { padding: 4px 0; color: var(--fg-mute); }
.cmds code {
  background: var(--bg-soft);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
  color: var(--fg);
  margin-right: 6px;
}

.secondary-btn {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .08s;
  font: inherit;
}
.secondary-btn:active { transform: scale(0.99); }
.secondary-btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}
/* When two .secondary-btn buttons sit stacked inside the same card,
   .stack-top adds the visual gap that used to live as `style="margin-top:10px"`
   inline. Keeps presentation in CSS where it belongs. */
.secondary-btn.stack-top { margin-top: 10px; }
.hint {
  color: var(--fg-mute);
  font-size: 13px;
  margin: 8px 0 0;
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.link:last-child { border-bottom: none; }
.link .chev { color: var(--fg-mute); font-size: 14px; }

/* =============================================================== FOCUS VIDEO (Practice) */

.focus-video {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  font: inherit;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
}
.focus-video .fv-ico { font-size: 20px; flex-shrink: 0; }
.focus-video .fv-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.focus-video .fv-title {
  color: var(--link);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.focus-video .fv-meta {
  color: var(--fg-mute);
  font-size: 12px;
}
.focus-video .chev { color: var(--fg-mute); font-size: 14px; flex-shrink: 0; }

/* =============================================================== SOURCES (videos) */

.sources-section-title {
  margin: 18px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-mute);
}
.video-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.video-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  text-align: left;
  width: 100%;
  cursor: pointer;
  font: inherit;
}
.video-item:last-child { border-bottom: none; }
.video-item .vi-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.video-item .vi-title {
  color: var(--link);
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.video-item .vi-meta {
  color: var(--fg-mute);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.video-item .vi-summary {
  color: var(--fg-mute);
  font-size: 13px;
  line-height: 1.4;
}
.video-item .vi-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.video-item .vi-tag {
  font-size: 11px;
  color: var(--fg-mute);
  background: var(--bg-soft);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* =============================================================== TOAST */

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 20;
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* =============================================================== ERROR */

.error-card {
  border-color: color-mix(in srgb, #e05c5c 40%, var(--border));
  background: color-mix(in srgb, #e05c5c 10%, var(--card));
}

/* =============================================================== MILESTONE MODAL */

.modal-backdrop {
  position: fixed;
  /* `inset: 0` isn't supported in Safari < 14.1; keep the long form as
   * a fallback so the modal still covers the viewport on old clients. */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  inset: 0;
  background: rgba(0,0,0,0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modal-fade-in .24s ease;
}
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 80px rgba(0,0,0,0.5);
  animation: modal-pop .3s cubic-bezier(0.2, 0.8, 0.2, 1.05);
}
@keyframes modal-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.milestone-emoji {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 14px;
  filter: drop-shadow(0 0 40px rgba(106,167,255,0.4));
  animation: milestone-spin 1.2s ease;
}
@keyframes milestone-spin {
  0%   { transform: scale(0) rotate(-180deg); }
  60%  { transform: scale(1.15) rotate(12deg); }
  100% { transform: scale(1) rotate(0); }
}

.milestone-day {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 6px;
}
.milestone-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--fg);
  margin-bottom: 12px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.milestone-body {
  color: var(--fg-mute);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 22px;
}

.primary-btn {
  width: 100%;
  background: var(--accent);
  border: none;
  color: var(--accent-fg);
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s;
  font: inherit;
}
.primary-btn:active { transform: scale(0.98); }

/* =============================================================== ASSISTANT / CHAT */

/* The chat view uses the entire viewport below the hero — message scroll in
 * the middle, input bar pinned above the bottom nav. `#viewAssistant` uses
 * flex column to stretch the scroll region to available space.
 *
 * NOTE: the chat input must sit ABOVE the bottom nav, so `bottom:` is
 * `var(--nav-height) + safe-area-inset`. Keep the two values in sync if
 * either changes.
 */

#viewAssistant {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  background: var(--bg);
  z-index: 5;
}

.chat-head {
  /* Respect the notch on iPhones — otherwise the title slides under the
   * status bar when the Mini App is opened full-screen. */
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.chat-head .page-title { font-size: 20px; margin-bottom: 2px; }
.chat-head .page-sub { font-size: 13px; margin: 0; }

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  /* Bottom padding = chat-form height + bottom nav + safe-area inset.
   * The 3-way add uses --chat-form-height rather than a hard-coded 76px
   * so tweaking the input bar's padding in one place updates both here
   * and `.chat-form bottom`. */
  padding: 16px 14px calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + var(--chat-form-height));
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chat-empty {
  margin: auto 0;
  text-align: center;
  padding: 20px 8px;
  color: var(--fg-mute);
}
.chat-empty-eye {
  font-size: 48px;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 24px rgba(106,167,255,0.3));
}
.chat-empty-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 6px;
}
.chat-empty-sub {
  font-size: 14px;
  line-height: 1.5;
  max-width: 320px;
  margin: 0 auto 14px;
}
.chat-suggests {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
}
.chat-suggest {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background .15s;
}
.chat-suggest:active { background: var(--bg-soft); }

.chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-fg);
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg.assistant.streaming::after {
  content: "▊";
  display: inline-block;
  margin-left: 2px;
  color: var(--fg-mute);
  animation: chat-caret 1s steps(2) infinite;
}
@keyframes chat-caret {
  50% { opacity: 0; }
}
.chat-msg.error {
  background: color-mix(in srgb, var(--danger) 14%, var(--card));
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

/* Inline links produced by the linkifier in chat bubbles. Stays underlined
   and uses the theme accent on both user (light-on-accent) and assistant
   (accent-on-card) bubbles so it's discoverable without a new colour token. */
.chat-msg .chat-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all; /* stop a long YouTube URL from bursting the bubble */
}
.chat-msg.assistant .chat-link {
  color: var(--link);
}
.chat-msg .chat-link:active { opacity: 0.7; }

.chat-form {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--bg) 94%, black);
  border-top: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  z-index: 6;
}
.chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.4;
  border-radius: 20px;
  resize: none;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.chat-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}
.chat-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .08s, opacity .15s;
}
.chat-send:active { transform: scale(0.95); }
.chat-send:disabled {
  opacity: 0.4;
  cursor: default;
}
.chat-send-ico { line-height: 1; }

/* =============================================================== BOTTOM NAV */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--bg) 92%, black);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  gap: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
}
.nav-item {
  flex: 1;
  max-width: 150px;
  background: transparent;
  border: none;
  color: var(--fg-mute);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color .15s ease;
  font: inherit;
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}
.nav-item .nav-ico {
  font-size: 22px;
  line-height: 1;
  transition: transform .15s ease;
}
.nav-item .nav-lbl {
  font-size: 11px;
  font-weight: 600;
}
.nav-item.active {
  color: var(--fg);
}
.nav-item.active .nav-ico {
  transform: translateY(-1px) scale(1.1);
  filter: drop-shadow(0 0 12px rgba(106,167,255,0.35));
}
.nav-item:active {
  background: var(--card);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
