/* Will Maxing design system: dark only, subtle pink glow, mobile first. */

:root {
  color-scheme: dark;
  --bg: #0a0910;
  --pink: 255, 79, 163;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-3: rgba(255, 255, 255, 0.11);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f1f7;
  --muted: #9b95a8;
  --accent: #ff4fa3;
  --accent-strong: #ff2f93;
  --on-accent: #17060f;
  --danger: #ff5c7a;
  --success: #46e2a5;
  --radius: 18px;
  --radius-sm: 12px;
  --tab-bar-space: calc(5.5rem + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* The pink glow lives on a fixed layer so it stays put while scrolling (and works on iOS Safari). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(90% 55% at 50% -5%, rgba(var(--pink), 0.10), transparent 70%),
    linear-gradient(180deg, rgba(var(--pink), 0.05), rgba(var(--pink), 0) 55%);
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.75rem; letter-spacing: -0.01em; }
.icon { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.25em; flex-shrink: 0; }
.page-title { display: flex; align-items: center; gap: 0.6rem; }
.page-title .icon { width: 1.1em; height: 1.1em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.center { text-align: center; }
.lead { font-size: 1.05rem; color: var(--muted); }
small { font-size: 0.85rem; }

/* Pages fill the viewport with a 20px gutter (plus device safe areas); page headers sit in the corners.
   Page bodies that should not stretch on wide screens are wrapped in .content or .narrow. */
.page {
  padding: calc(20px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 2rem max(20px, env(safe-area-inset-left));
}
body.has-tab-bar .page { padding-bottom: var(--tab-bar-space); }
.content { max-width: 720px; margin: 0 auto; }
.narrow { max-width: 560px; margin: 0 auto; }

/* Page header: title top-left, actions top-right */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-heading { font-size: 1.85rem; margin: 0; letter-spacing: -0.03em; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.page-actions .btn-sm { padding: 0.45rem 0.8rem; font-size: 0.85rem; }
@media (max-width: 480px) {
  .page-heading { font-size: 1.5rem; }
  .page-actions { gap: 0.4rem; }
  .page-actions .btn-sm { padding: 0.4rem 0.65rem; font-size: 0.8rem; min-height: 36px; }
}

/* Bottom capsule tab bar */
.tab-bar {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(22, 18, 30, 0.78);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}
.tab:hover, .tab-active { color: #fff; }
.tab-icon { display: inline-flex; }
.tab-icon .icon { width: 20px; height: 20px; display: block; }
/* With four or more tabs a phone can't fit the labels, so the bar goes icon-only there (items stay static). */
@media (max-width: 480px) {
  .tab-bar:has(> .tab:nth-of-type(4)) .tab-label { display: none; }
  .tab-bar:has(> .tab:nth-of-type(4)) .tab { padding: 0.6rem 0.95rem; }
}
/* The selection capsule: a single element that slides under the active tab (see tab_bar_controller.js). */
.tab-indicator {
  position: absolute;
  top: 0.35rem;
  left: 0;
  height: calc(100% - 0.7rem);
  width: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1), width 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  .tab-indicator { transition: none; }
}

/* Cards and sections */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.auth-card { max-width: 420px; margin: 1.5rem auto; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-color: rgba(var(--pink), 0.35); background: rgba(var(--pink), 0.08); }
.banner .muted { display: block; }
.empty-state { text-align: center; padding: 2.5rem 1.25rem; }

/* Forms */
.stack > * + * { margin-top: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-inline { flex-direction: row; align-items: center; gap: 0.75rem; }
label { font-weight: 600; font-size: 0.95rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  font: inherit; padding: 0.7rem 0.85rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); width: 100%; min-height: 44px;
}
select { width: auto; }
input:not([type="submit"]):focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
input::placeholder { color: rgba(155, 149, 168, 0.7); }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; margin-bottom: 0.5rem; padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 700; padding: 0.7rem 1.2rem;
  min-height: 44px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; text-decoration: none; text-align: center;
  line-height: 1.2; transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 24px rgba(var(--pink), 0.25); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-danger { background: rgba(255, 92, 122, 0.15); color: var(--danger); border-color: rgba(255, 92, 122, 0.4); }
.btn-danger:hover { background: rgba(255, 92, 122, 0.25); }
.btn-link { background: none; border: 0; color: var(--muted); padding: 0.5rem; text-decoration: underline; font-weight: 500; min-height: 0; box-shadow: none; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.9rem; min-height: 36px; }
.inline-form { display: inline; }
.actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.actions.center { justify-content: center; }

/* Toasts: flash messages float over the page at the top, then dismiss themselves */
.toasts {
  position: fixed; top: calc(16px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: 0.5rem; width: min(calc(100vw - 40px), 480px); pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer; padding: 0.8rem 1rem; border-radius: var(--radius-sm); font-weight: 500;
  background: rgba(22, 18, 30, 0.92); border: 1px solid var(--border-strong); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: toast-in 250ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.toast-notice { border-color: rgba(70, 226, 165, 0.5); }
.toast-alert { border-color: rgba(255, 92, 122, 0.5); }
.toast.is-leaving { animation: toast-out 250ms ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-16px); } }
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.is-leaving { animation: none; }
}
.form-errors { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid rgba(255, 92, 122, 0.4); background: rgba(255, 92, 122, 0.1); }
.form-errors ul { margin: 0; padding-left: 1.2rem; }
.form-error { color: var(--danger); margin: 0.75rem 0 0; }

.divider { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); margin: 1.25rem 0; font-size: 0.9rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* Landing */
.hero { text-align: center; padding: 2.5rem 0 2rem; }
.hero h1 { font-size: 2.2rem; letter-spacing: -0.03em; }
.hero h1 span { background: linear-gradient(90deg, #ff7ac0, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }

/* Feature and option cards */
.feature-grid, .option-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 600px) { .feature-grid, .option-grid { grid-template-columns: repeat(2, 1fr); } }
.option-grid-3 { grid-template-columns: repeat(3, 1fr); }
.feature-card { margin-bottom: 0; }
.feature-card-link { display: block; text-decoration: none; color: inherit; transition: border-color 0.15s ease, background 0.15s ease; }
.feature-card-link:hover { border-color: rgba(var(--pink), 0.5); background: var(--surface-2); }
.feature-icon { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 14px; background: var(--surface-3); margin-bottom: 0.75rem; }
.feature-icon .icon { width: 24px; height: 24px; }

.option-card {
  display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.9rem 1rem; border: 1px solid var(--border-strong);
  border-radius: var(--radius); cursor: pointer; background: var(--surface); font-weight: normal; min-width: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.option-card:has(input:checked) { border-color: var(--accent); background: rgba(var(--pink), 0.10); }
/* The native checkbox / radio is hidden (but still focusable); the highlighted card shows the selection. */
.option-card { position: relative; }
.option-card input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.option-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.option-grid-3 .option-card { flex-direction: column; align-items: center; text-align: center; gap: 0.35rem; padding: 0.8rem 0.5rem; }
.option-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.option-grid-3 .option-body { align-items: center; }
.option-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-3); margin-bottom: 0.25rem; }
.option-icon .icon { width: 20px; height: 20px; }
.option-title { font-weight: 700; }
.option-desc { font-size: 0.85rem; }

.chip-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.95rem; min-height: 40px; }
.chip:has(input:checked) { border-color: var(--accent); background: rgba(var(--pink), 0.14); }
.chip input { accent-color: var(--accent); margin: 0; }

/* Stats and tables */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.25rem; }
@media (min-width: 600px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat { text-align: center; padding: 0.9rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.stat-value { display: block; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { display: block; color: var(--muted); font-size: 0.8rem; }

.table-wrap { overflow-x: auto; margin: 0 -0.25rem; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.row-correct td:last-child { color: var(--success); font-weight: 700; }
.row-incorrect td:last-child { color: var(--danger); font-weight: 700; }
.row-incorrect td:nth-child(3) { color: var(--danger); }

/* Round in progress */
.question-card { text-align: center; padding: 1.5rem 1.25rem; }
.question-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.9rem; margin-bottom: 0.6rem; }
.timer { font-variant-numeric: tabular-nums; }
.progress { width: 100%; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-3); }
.progress-fill { height: 100%; width: 0; border-radius: 3px; background: var(--accent); box-shadow: 0 0 10px rgba(var(--pink), 0.6); transition: width 450ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.question-text { font-size: 2.8rem; font-weight: 800; margin: 2rem 0; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.answer-form { display: flex; flex-direction: column; gap: 0.75rem; align-items: stretch; margin-bottom: 1rem; }
.answer-input { font-size: 1.6rem; text-align: center; min-height: 56px; }
@media (min-width: 600px) {
  .answer-form { flex-direction: row; justify-content: center; }
  .answer-input { max-width: 220px; }
}

/* Results */
.result-hero { text-align: center; padding: 1.75rem 1.25rem; border-color: rgba(var(--pink), 0.3); background: rgba(var(--pink), 0.06); }
.score { font-size: 3.6rem; font-weight: 900; line-height: 1; margin-bottom: 0.5rem; letter-spacing: -0.03em; }
.score-total { font-size: 1.5rem; color: var(--muted); font-weight: 700; }
.rank { font-size: 1.2rem; margin-bottom: 0.25rem; }
.rank strong { color: var(--accent); }

/* Profile */
.profile-grid { display: grid; gap: 1rem; }
.profile-grid .card { margin-bottom: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.card-header h2 { margin: 0; }
.details { display: grid; gap: 0.6rem; margin: 0; }
.details div { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--border); }
.details div:last-child { border-bottom: 0; padding-bottom: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.page-actions form { display: inline; }

/* Calculations: start screen */
.start-hero { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 52vh; }
/* A circular Start button inside a 1px ring; on hover, rings ripple outwards from the button's edge. */
.start-ring { --ring-gap: 14px; position: relative; display: inline-block; padding: var(--ring-gap); border: 1px solid var(--accent); border-radius: 50%; transition: border-color 0.2s ease; }
.start-ring::before, .start-ring::after {
  content: ""; position: absolute; inset: var(--ring-gap); border-radius: 50%; border: 1px solid var(--accent);
  opacity: 0; pointer-events: none;
}
/* While hovering, the static ring gives way to rings that ripple out from the button's edge. */
.start-ring:hover { border-color: transparent; }
.start-ring:hover::before, .start-ring:hover::after { animation: start-ripple 1.8s ease-out infinite; }
.start-ring:hover::after { animation-delay: 0.9s; }
@keyframes start-ripple {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.75); opacity: 0; }
}
.btn-start {
  display: flex; align-items: center; justify-content: center; width: 168px; height: 168px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--on-accent); font: inherit; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.01em;
  cursor: pointer; box-shadow: 0 10px 40px rgba(var(--pink), 0.35); transition: transform 0.15s ease, background 0.15s ease;
}
.btn-start:hover { background: var(--accent-strong); }
.btn-start:active { transform: scale(0.97); }
.btn-start:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) {
  .start-ring:hover::before, .start-ring:hover::after { animation: none; }
}
.round-meta { margin-bottom: 1rem; }
.level-summary { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin: 0.25rem 0 1rem; }
.level-pill { padding: 0.35rem 0.8rem; border-radius: 999px; background: var(--surface-3); font-size: 0.9rem; color: var(--muted); }
.level-pill strong { color: var(--text); }
.stat-grid-2 { grid-template-columns: repeat(2, 1fr); }
.drawer h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 1.5rem 0 0.5rem; }

/* Side drawers (stats, custom training) */
.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.55); opacity: 0; pointer-events: none; transition: opacity 250ms ease; }
.drawer-backdrop.is-visible { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: min(440px, 100vw);
  padding: calc(1rem + env(safe-area-inset-top)) 1.25rem calc(2rem + env(safe-area-inset-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #110f18; border-left: 1px solid var(--border-strong);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
  transform: translateX(100%); visibility: hidden;
  transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 300ms;
}
.drawer.is-open { transform: translateX(0); visibility: visible; transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0s; }
.drawer:focus { outline: none; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.drawer-header h2 { margin: 0; font-size: 1.3rem; }
.drawer-close { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.drawer-close:hover { background: var(--surface-3); }
body.drawer-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer.is-open, .drawer-backdrop { transition: none; }
}

/* Memory queue: digits in columns, then empty columns to type them back */
.sequence-form { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.sequence-form .btn { min-width: 200px; }
.sequence-form .digit-row { margin: 0.5rem 0 1rem; }
.digit-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin: 1.5rem 0; }
.digit-box {
  display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 60px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.digit-row input.digit-input { width: 48px; height: 60px; min-height: 0; padding: 0; text-align: center; font-size: 1.6rem; font-weight: 700; }
.digit-box-wrong { border-color: var(--danger); color: var(--danger); background: rgba(255, 92, 122, 0.12); }
.digit-row-sm { margin: 0.35rem 0 0; justify-content: flex-start; gap: 0.35rem; }
.digit-row-sm .digit-box { width: 34px; height: 42px; font-size: 1.15rem; }
.digit-compare { display: grid; gap: 0.75rem; }
.digits-cell { font-variant-numeric: tabular-nums; letter-spacing: 0.05em; }
@media (max-width: 480px) {
  .digit-row { gap: 0.4rem; }
  .digit-box, .digit-row input.digit-input { width: 40px; height: 52px; font-size: 1.4rem; }
  .digit-row-sm .digit-box { width: 30px; height: 38px; font-size: 1rem; }
}

/* Daily goals */
.page-subtitle { margin: 0.2rem 0 0; }
.goal-summary { margin: 0 0 0.9rem; color: var(--muted); font-weight: 600; }
.goal-summary-done { color: var(--success); }
.day-off-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.25rem; }
.goal-list { display: grid; gap: 0.75rem; }
.goal-card { position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.goal-tap-form { position: relative; z-index: 1; display: flex; width: 100%; transition: width 280ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.goal-tap {
  position: relative; display: flex; align-items: center; gap: 0.9rem; width: 100%; text-align: left; padding: 0.9rem 1rem;
  border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.goal-tap:hover { background: var(--surface-2); }
.goal-tap:active { transform: scale(0.99); }
.goal-card-done .goal-tap { border-color: rgba(70, 226, 165, 0.6); background: rgba(70, 226, 165, 0.08); }
/* Every tap fires one fast, thick border ring outwards from the row (goal_card_controller.js spawns a
   .goal-pulse in the .goal-slot wrapper, so rings outlive the card swap and rapid taps stack).
   --pulse-color runs yellow to green with progress; --pulse-over (0 at 100%, 1 at 200%+) makes the
   ring start thicker and travel farther. Nothing shows at rest. */
.goal-slot { position: relative; }
.goal-pulse {
  position: absolute; inset: -2px; z-index: 2; border-radius: var(--radius); border: 3px solid var(--pulse-color, var(--success));
  pointer-events: none; animation: goal-pulse 550ms ease-out forwards;
}
@keyframes goal-pulse {
  0% { inset: -2px; border-radius: var(--radius); border-width: calc(3px + 3px * var(--pulse-over, 0)); opacity: 1; }
  100% { inset: calc(-16px - 12px * var(--pulse-over, 0)); border-radius: calc(var(--radius) + 16px); border-width: 1px; opacity: 0; }
}
.goal-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.goal-main { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.goal-desc { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.goal-progress { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.goal-card-done .goal-progress { color: var(--success); font-weight: 700; }
.goal-bar { display: block; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.goal-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 450ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.goal-card-done .goal-bar-fill { background: var(--success); }
.goal-step { font-size: 0.8rem; }

/* Completion badge: the percentage keeps counting past 100%; done badges turn green. */
.goal-percent {
  flex-shrink: 0; width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}
.goal-percent.is-complete { background: var(--success); color: #062b1c; border-color: transparent; }

/* The minus button hides behind the card; a long press slides it out to the right. */
.goal-minus-form {
  position: absolute; top: 0; bottom: 0; right: 0; z-index: 0; width: 52px; display: flex;
  transform: translateX(-100%); opacity: 0;
  transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 200ms ease;
}
.goal-card.is-revealed .goal-tap-form { width: calc(100% - 62px); }
.goal-card.is-revealed .goal-minus-form { transform: translateX(0); opacity: 1; }
.goal-card.no-transition, .goal-card.no-transition * { transition: none !important; }
.goal-minus {
  width: 100%; height: 100%; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 1.5rem; cursor: pointer; transition: background 0.15s ease;
}
.goal-minus:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.goal-minus:disabled { opacity: 0.35; cursor: default; }
@media (prefers-reduced-motion: reduce) {
  .goal-pulse { display: none; }
  .goal-tap-form, .goal-minus-form { transition: none; }
}
.weekday-row { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.weekday-pill {
  position: relative; flex: 1; text-align: center; padding: 0.55rem 0.2rem; border-radius: 999px; border: 1px solid var(--border-strong);
  color: var(--muted); font-weight: 600; font-size: 0.85rem; white-space: nowrap; cursor: pointer;
}
.weekday-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.weekday-pill:has(input:checked) { background: rgba(var(--pink), 0.16); border-color: var(--accent); color: #fff; }
.weekday-pill:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.goal-config-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.goal-config { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.goal-config .muted { display: block; font-size: 0.9rem; }
.goal-config .actions { flex-shrink: 0; flex-wrap: nowrap; }
.toggle { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 500; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.field-row { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .field-row { grid-template-columns: 1fr 1fr 1fr; } }

/* Daily goals history grid */
.stat-of { font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.history-wrap { margin: 0; }
.history th, .history td { padding: 0.3rem 0.2rem; text-align: center; white-space: nowrap; }
.history tbody th { text-align: left; font-weight: 600; font-size: 0.85rem; color: var(--text); text-transform: none; letter-spacing: 0; max-width: 110px; overflow: hidden; text-overflow: ellipsis; padding-right: 0.6rem; position: sticky; left: 0; background: #110f18; }
.history thead th { text-transform: none; letter-spacing: 0; }
.history-day { line-height: 1.1; }
.history-day.is-today .history-date { color: var(--accent); }
.history-weekday { display: block; font-size: 0.65rem; color: var(--muted); }
.history-date { display: block; font-size: 0.75rem; font-weight: 700; }
.history-cell {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 5px;
  background: var(--surface-3); font-size: 0.7rem; font-weight: 800; color: #062b1c;
}
.history-cell[style*="--fill"] { background: hsl(calc(50 + 100 * var(--fill)) 85% 55% / calc(0.18 + 0.82 * var(--fill))); }
.history-cell.is-complete { background: var(--success); }
.history-cell.is-achieved { background: var(--success); }
.history-cell.is-missed { background: rgba(255, 92, 122, 0.35); }
.history-cell.is-off { background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); }
.history-cell.is-none { background: transparent; }
.history-legend { font-size: 0.85rem; margin-top: 0.75rem; }

/* Friends */
.people { list-style: none; margin: 0; padding: 0; }
.person { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.person:last-child { border-bottom: 0; padding-bottom: 0; }
.person .muted { display: block; font-size: 0.9rem; }
.person .actions { flex-shrink: 0; flex-wrap: nowrap; }
.person-summary { padding: 0.9rem 0; border-bottom: 1px solid var(--border); }
.person-summary:last-child { border-bottom: 0; }
.person-summary strong { display: block; margin-bottom: 0.4rem; }
.person-summary .details { gap: 0.35rem; }
.person-summary .details div { padding-bottom: 0.35rem; }

/* Email verification reminder */
.verify-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.75rem 1rem; margin-bottom: 1rem; border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--pink), 0.4); background: rgba(var(--pink), 0.08); font-size: 0.95rem;
}
.verify-banner form { display: inline; }


/* Daily goals: "Active on" popup in the goal form, and the Upcoming drawer */
.weekday-popup { position: relative; }
.weekday-popup summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; min-height: 44px; padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); font-weight: 600; }
.weekday-popup summary::-webkit-details-marker { display: none; }
.weekday-popup[open] summary { border-color: var(--accent); }
.weekday-popup-panel { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); padding: 0.9rem; border-radius: var(--radius); border: 1px solid var(--border-strong); background: #16121e; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5); }
.weekday-popup-panel .weekday-row { margin-bottom: 0.75rem; }
.upcoming-day { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.upcoming-day h3 { margin: 0 0 0.35rem; font-size: 1rem; display: flex; justify-content: space-between; gap: 0.5rem; }
.upcoming-day h3 .muted { font-weight: 500; font-size: 0.9rem; }
.upcoming-day p { margin: 0; }
.upcoming-goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }

/* Brand lockup above the auth cards */
.brand { display: flex; justify-content: center; align-items: center; gap: 0.55rem; margin: 2.5rem 0 0.25rem; font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; box-shadow: 0 6px 18px rgba(var(--pink), 0.35); }
