/* Dayly visual refinement.
 *
 * This file deliberately sits last in the cascade. It strengthens hierarchy
 * and finish without changing the app's component model or interaction logic.
 */

:root {
  --bg: #090b10;
  --surface-1: #12151b;
  --surface-2: #191d25;
  --surface-3: #222834;
  --border: rgba(255, 255, 255, 0.065);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f6f7fb;
  --text-secondary: #a6adba;
  --text-tertiary: #687080;
  --accent: #5b92ff;
  --accent-hover: #78a6ff;
  --accent-soft: rgba(91, 146, 255, 0.13);
  --success: #50d890;
  --track: rgba(255, 255, 255, 0.075);
  --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.2), 0 18px 50px rgba(0, 0, 0, 0.14);
}

:root[data-theme='light'] {
  --bg: #f4f6fa;
  --surface-1: #ffffff;
  --surface-2: #f2f4f8;
  --surface-3: #e8ebf1;
  --border: rgba(14, 23, 40, 0.065);
  --border-strong: rgba(14, 23, 40, 0.12);
  --text: #111722;
  --text-secondary: #5b6473;
  --text-tertiary: #9299a6;
  --accent: #356fe0;
  --accent-hover: #285fc9;
  --accent-soft: rgba(53, 111, 224, 0.1);
  --track: rgba(14, 23, 40, 0.08);
  --shadow-card: 0 1px 2px rgba(20, 31, 50, 0.04), 0 18px 42px rgba(20, 31, 50, 0.055);
}

html { background: var(--bg); }

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 560px at 72% -10%, rgba(74, 127, 239, 0.07), transparent 62%),
    var(--bg);
}

/* Authentication */
.auth-gate {
  isolation: isolate;
  background:
    radial-gradient(700px 480px at 10% 20%, rgba(63, 112, 216, 0.15), transparent 68%),
    radial-gradient(620px 500px at 88% 78%, rgba(44, 184, 126, 0.085), transparent 70%),
    var(--bg);
}

.auth-gate::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.2;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 84%);
}

.auth-gate__glow { opacity: 0.34; }

.auth-gate__inner {
  max-width: 1080px;
  gap: clamp(3rem, 8vw, 7rem);
}

.auth-gate__pitch { max-width: 560px; }

.wordmark {
  margin-bottom: var(--space-10);
  gap: var(--space-3);
}

.wordmark__mark { width: 34px; height: 34px; }
.wordmark__text { font-size: 1.45rem; }

.auth-gate__eyebrow {
  margin-bottom: var(--space-4);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-gate__headline {
  max-width: 620px;
  font-size: clamp(2.75rem, 5.8vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.auth-gate__sub {
  max-width: 46ch;
  font-size: 1.05rem;
  line-height: 1.65;
}

.auth-gate__points { gap: var(--space-4); }
.auth-gate__points li { color: #b6bdc9; }

.auth-gate__point-dot {
  width: 8px;
  height: 8px;
  box-shadow: 0 0 16px currentColor;
}

.auth-gate__privacy {
  margin-top: var(--space-8);
  color: var(--text-tertiary);
  font-size: var(--text-caption);
}

.auth-gate__panel {
  position: relative;
  max-width: 430px;
  padding: 2.15rem 1.65rem;
  background: rgba(18, 21, 27, 0.82);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,.035);
}

.auth-gate__panel::before {
  content: '';
  position: absolute;
  inset: 0 15% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(108, 158, 255, .7), transparent);
}

/* App shell */
.rail {
  width: 218px;
  padding: var(--space-6) var(--space-3);
  background: rgba(12, 15, 20, 0.74);
  border-right-color: var(--border);
  backdrop-filter: blur(22px);
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3) var(--space-8);
  font-size: 1.25rem;
}

.rail__brand-mark { width: 27px; height: 27px; flex: none; }

.rail__link {
  position: relative;
  min-height: 46px;
  padding: 0 var(--space-3);
  border-radius: 11px;
  color: #858d9b;
}

.rail__link:hover { background: rgba(255, 255, 255, 0.04); }

.rail__link[aria-current='page'] {
  background: linear-gradient(90deg, rgba(91, 146, 255, 0.15), rgba(91, 146, 255, 0.07));
  color: #a9c5ff;
}

.rail__link[aria-current='page']::before {
  content: '';
  position: absolute;
  left: -12px;
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(91, 146, 255, 0.45);
}

.container { max-width: 1140px; }

/* Headers and dashboard */
.page-header,
.today-hero { padding-top: clamp(2rem, 5vw, 3.7rem); }

.page-header__eyebrow {
  color: var(--accent);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.page-header__title {
  margin-top: var(--space-1);
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  letter-spacing: -0.055em;
}

.today-hero__date { color: var(--text-tertiary); }

.today-hero__ring {
  filter: drop-shadow(0 10px 24px rgba(76, 141, 255, 0.12));
}

.today-hero__pct { font-size: 1.95rem; }

.insight {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(91, 146, 255, 0.14);
  background: linear-gradient(110deg, rgba(91, 146, 255, 0.12), rgba(91, 146, 255, 0.035));
}

.insight::after {
  content: '';
  position: absolute;
  inset: auto -40px -60px auto;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(91, 146, 255, 0.06);
}

.stat-row { gap: var(--space-4); }

.stat-tile {
  position: relative;
  overflow: hidden;
  min-height: 104px;
  justify-content: center;
  padding: var(--space-5);
  border: 1px solid var(--border);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}

.stat-tile::after {
  content: '';
  position: absolute;
  inset: auto 16px 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .45;
}

.stat-tile__value { font-size: 1.85rem; }
.stat-tile__label { letter-spacing: .02em; }

/* Cards */
.card {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out);
}

@media (hover: hover) {
  .card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: 0 2px 2px rgba(0,0,0,.16), 0 24px 55px rgba(0,0,0,.18);
  }
}

.card--feature {
  background:
    radial-gradient(560px 180px at 6% -5%, rgba(91,146,255,.11), transparent 68%),
    var(--surface-1);
  border-color: rgba(91, 146, 255, 0.11);
}

.card__title {
  font-size: .72rem;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.btn--primary {
  box-shadow: 0 8px 20px rgba(76, 141, 255, 0.2), inset 0 1px rgba(255,255,255,.16);
}

.btn--secondary { border: 1px solid var(--border); }

.btn--secondary:hover {
  border-color: rgba(91, 146, 255, 0.2);
  background: color-mix(in srgb, var(--surface-3) 86%, var(--accent));
}

.bar { background: rgba(255, 255, 255, 0.055); }
.bar__fill { box-shadow: 0 0 14px color-mix(in srgb, currentColor 32%, transparent); }

.nutrition-hero__value .metric__value--display {
  font-size: clamp(3.15rem, 8vw, 4.25rem);
  letter-spacing: -0.065em;
}

.mini-ring svg { filter: drop-shadow(0 4px 9px rgba(0,0,0,.18)); }

.meal-list__item,
.habit-row,
.act-item {
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-out);
}

.meal-list__item { padding: var(--space-2); margin-inline: calc(var(--space-2) * -1); }
.meal-list__item:hover,
.habit-row:hover,
.act-item:hover { background: rgba(255,255,255,.025); }

.habit-row { padding-inline: var(--space-2); margin-inline: calc(var(--space-2) * -1); }

.habit-check:not(.is-on):hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.habit-check.is-on { box-shadow: 0 5px 14px rgba(76, 141, 255, .2); }

.water-pip {
  height: 34px;
  border: 1px solid rgba(255,255,255,.025);
}

.water-pip.is-filled {
  background: linear-gradient(180deg, #69d0fa, var(--metric-water));
  box-shadow: 0 6px 16px rgba(79, 195, 247, .13);
}

.left-metric,
.left-habit,
.goal-progress {
  border: 1px solid var(--border);
}

.left-habit:hover {
  border-color: rgba(91,146,255,.32);
  background: var(--accent-soft);
}

.day-done {
  background: linear-gradient(110deg, var(--success-soft), rgba(61,220,132,.035));
  border: 1px solid rgba(61, 220, 132, .15);
}

/* History, progress and settings */
.cal-cell {
  border: 1px solid transparent;
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

.cal-cell:hover { background: var(--surface-2); border-color: var(--border); }
.cal-cell.is-selected { box-shadow: 0 0 0 1px var(--accent), 0 8px 20px rgba(76,141,255,.12); }

.chart { filter: drop-shadow(0 8px 16px rgba(61, 220, 132, .07)); }

.settings-group {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.set-link:hover { background: rgba(255,255,255,.025); }

.sheet__panel {
  border: 1px solid var(--border-strong);
  box-shadow: 0 34px 100px rgba(0,0,0,.56);
}

.input {
  border: 1px solid transparent;
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.input:hover { border-color: var(--border-strong); }
.input:focus { border-color: var(--accent); }

/* Mobile */
@media (max-width: 639px) {
  .auth-gate { place-items: start center; padding: 1.35rem; }
  .auth-gate__inner { gap: var(--space-8); }
  .auth-gate__pitch { padding-top: var(--space-4); }
  .auth-gate__headline { font-size: clamp(2.55rem, 13vw, 3.45rem); }
  .auth-gate__sub { margin-bottom: var(--space-6); }
  .auth-gate__points { display: none; }
  .auth-gate__privacy { display: none; }
  .auth-gate__panel { padding: var(--space-6) var(--space-4); }

  .today-hero { padding-top: var(--space-8); }
  .today-hero__ring svg { width: 102px; height: 102px; }
  .stat-tile { min-height: 92px; padding: var(--space-4); }
  .nutrition-hero__value .metric__value--display { font-size: 3.2rem; }
  .macro-rings { gap: var(--space-3); }
}

@media (min-width: 1024px) {
  .main { padding-inline: var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  .card { transform: none !important; }
}
