/* ═══════════════════════════════════════════════════
   WINTER ARC '26  —  Dark Theme
════════════════════════════════════════════════════ */

:root {
  --bg: #080808;
  --card: #0d1117;
  --card2: #141b24;
  --border: #1a2332;
  --orange: #38bdf8;
  --orange2: #7dd3fc;
  --orange-glow: rgba(56,189,248,0.12);
  --text: #e2eef7;
  --muted: #4a6070;
  --sub: #7a99b0;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #eab308;
  --header-h: 56px;
  --nav-h: 68px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
html { background: #080808; }
body { background: transparent; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Inputs base ── */
input, textarea, select {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { border-color: var(--orange); }
input[type="number"]::-webkit-inner-spin-button { opacity: 0.5; }
textarea { resize: vertical; }
input:disabled, textarea:disabled { opacity: 0.4; cursor: not-allowed; }

/* ══════════════════════════════════════════════════
   LOGIN / SETUP SCREENS
══════════════════════════════════════════════════ */

#snow-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

#login-screen, #setup-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, rgba(5,18,48,0.88) 0%, rgba(8,8,8,0.72) 65%);
  position: relative;
  z-index: 1;
}

.login-card, .setup-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 28px;
  text-align: center;
  position: relative;
  z-index: 2;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.login-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 16px;
  color: var(--orange);
}

.login-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 6px; }
.login-sub { color: var(--sub); font-size: 13px; margin-bottom: 24px; }

.login-card form, .setup-card form { text-align: left; }
.login-card input { margin-bottom: 12px; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 8px; min-height: 20px; }

.label-hint { font-size: 12px; color: var(--muted); margin: 4px 0 12px; }

/* ══════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════ */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  z-index: 1;
}

/* Header */
#app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.header-day {
  font-size: 11px;
  font-weight: 600;
  color: var(--orange);
  letter-spacing: 1px;
  text-transform: uppercase;
  background: var(--orange-glow);
  padding: 3px 8px;
  border-radius: 20px;
}

#header-title {
  font-size: 16px;
  font-weight: 600;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

#header-right { display: flex; align-items: center; gap: 8px; }

#btn-settings {
  background: none;
  border: none;
  color: var(--sub);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
#btn-settings:hover { color: var(--text); }

.ro-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--sub);
  padding: 2px 7px;
  border-radius: 4px;
}

/* Main scrollable area */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: var(--nav-h);
}

/* Pages */
.page { display: none; padding: 16px; animation: fadeIn 0.2s ease; }
.page.active { display: block; }

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

/* Bottom Nav */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  z-index: 20;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 4px;
  border-radius: 10px;
  transition: color 0.15s;
  font-size: 10px;
  font-weight: 500;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--orange); }
.nav-btn:hover { color: var(--text); }

/* ══════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════ */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sub);
  margin-bottom: 14px;
}

/* ══════════════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════════════ */

/* Arc Progress Card */
.arc-card { background: linear-gradient(135deg, #0d1117 0%, #071828 100%); border-color: #1a3050; }

.arc-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.arc-day-label { font-size: 18px; font-weight: 700; }
.arc-pct { font-size: 24px; font-weight: 800; color: var(--orange); }

.prog-outer {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.prog-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange2));
  border-radius: 99px;
  transition: width 0.5s ease;
}

.arc-dates { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.metric-card:hover { border-color: var(--orange); }

.metric-val { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 4px; }
.metric-key { font-size: 12px; color: var(--sub); margin-bottom: 2px; }
.metric-sub { font-size: 11px; color: var(--muted); }

/* Goals List */
.goals-list { display: flex; flex-direction: column; gap: 12px; }

.goal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 4px 0;
}

.goal-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: all 0.2s;
}
.goal-dot.done { background: var(--success); border-color: var(--success); }
.goal-dot.done::after { content: ''; display: block; width: 6px; height: 10px; border: 2px solid #fff; border-left: none; border-top: none; transform: rotate(45deg) translate(-1px, -1px); margin: 1px auto; }
.goal-dot.partial { background: var(--orange-glow); border-color: var(--orange); }

.goal-info { flex: 1; }
.goal-name { font-size: 14px; font-weight: 500; }
.goal-status { font-size: 12px; color: var(--sub); margin-top: 2px; }
.goal-tap { font-size: 10px; color: var(--muted); }

/* Subgoals */
.goal-group { margin-bottom: 8px; }
.goal-group .goal-row { cursor: default; }
.subgoals {
  margin-left: 9px;
  padding-left: 20px;
  border-left: 2px solid var(--border);
  margin-top: 6px;
  margin-bottom: 4px;
}
.subgoal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--sub);
  cursor: pointer;
  transition: color 0.15s;
  user-select: none;
}
.subgoal-row:last-child { border-bottom: none; }
.subgoal-row.done { color: var(--text); }
.sub-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: all 0.2s;
}
.sub-dot.done { background: var(--success); border-color: var(--success); }

/* Weight card on dashboard */
.weight-entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.weight-current { font-size: 28px; font-weight: 800; line-height: 1; }
.weight-sub { font-size: 12px; color: var(--sub); margin-top: 4px; }
.weight-input-group { display: flex; align-items: center; gap: 8px; }
.weight-input-group .inp-unit { width: 110px; }

/* Today Checklist */
.today-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.today-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--sub);
}
.today-item.done { color: var(--text); }
.today-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}
.today-item.done .today-dot { background: var(--success); }

/* Score Area */
.score-big {
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  margin-bottom: 4px;
}
.score-label { text-align: center; font-size: 13px; color: var(--sub); margin-bottom: 16px; }

.score-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.score-cat {
  background: var(--card2);
  border-radius: 10px;
  padding: 10px 12px;
}
.score-cat-name { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.score-cat-val { font-size: 20px; font-weight: 700; }

/* ══════════════════════════════════════════════════
   DAILY LOG
══════════════════════════════════════════════════ */

.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}
.date-nav button {
  background: none;
  border: none;
  color: var(--orange);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}
.date-nav button:disabled { color: var(--muted); cursor: default; }
#log-date-label { font-weight: 600; font-size: 15px; }

.warn-banner {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--warn);
  margin-bottom: 12px;
}

.info-banner {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #818cf8;
  margin-bottom: 12px;
  text-align: center;
}

.log-section { margin-bottom: 10px; }
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--orange);
  margin-bottom: 12px;
}

/* Form Row */
.fr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.fr:last-child { border-bottom: none; padding-bottom: 0; }
.fr label { font-size: 14px; color: var(--text); flex: 1; }

.toggle-fr { min-height: 42px; }

.inp-unit { display: flex; align-items: center; gap: 6px; width: 120px; }
.inp-unit input { width: 80px; text-align: right; padding: 8px 10px; }
.unit { font-size: 12px; color: var(--muted); white-space: nowrap; }

.time-inp { width: 120px; text-align: center; }

/* Toggle */
.tog {
  width: 48px;
  height: 26px;
  background: var(--card2);
  border: 2px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.tog.active { background: var(--orange); border-color: var(--orange); }
.tog.disabled { cursor: not-allowed; opacity: 0.4; }

.tog-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.tog.active .tog-thumb { transform: translateX(22px); background: #fff; }

/* Form groups (setup/settings) */
.fg { margin-bottom: 14px; }
.fg label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; font-weight: 500; }

.save-btn { margin-top: 6px; }

/* ══════════════════════════════════════════════════
   WEEKLY REVIEW
══════════════════════════════════════════════════ */

.week-score-hero {
  text-align: center;
  padding: 24px 16px 16px;
}
.week-score-num {
  font-size: 80px;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, var(--orange), var(--orange2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.week-score-denom { font-size: 28px; color: var(--muted); }
.week-score-label { font-size: 13px; color: var(--sub); margin-top: 6px; }

.score-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.sb-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.sb-cat { font-size: 11px; color: var(--sub); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.sb-score { font-size: 22px; font-weight: 800; }
.sb-max { font-size: 12px; color: var(--muted); }
.sb-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 8px; }
.sb-bar-fill { height: 100%; border-radius: 2px; background: var(--orange); transition: width 0.4s; }

/* Weekly table */
.week-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.week-table th { text-align: left; padding: 8px 6px; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.week-table td { padding: 10px 6px; border-bottom: 1px solid var(--border); }
.week-table tr:last-child td { border-bottom: none; }
.w-check { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--success); }
.w-cross { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); opacity: 0.6; }
.w-na { color: var(--muted); font-size: 11px; }

/* ══════════════════════════════════════════════════
   PROGRESS CHARTS
══════════════════════════════════════════════════ */

.sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.stab {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--sub);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.stab.active { background: var(--orange-glow); border-color: var(--orange); color: var(--orange); }

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.chart-title { font-size: 13px; font-weight: 600; color: var(--sub); margin-bottom: 14px; }
.chart-wrap { position: relative; height: 200px; }

.stat-row { display: flex; justify-content: space-between; margin-top: 14px; }
.stat-item { text-align: center; }
.stat-val { font-size: 20px; font-weight: 700; }
.stat-key { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ══════════════════════════════════════════════════
   INFO PAGE (Contract / Rules)
══════════════════════════════════════════════════ */

/* Contract */
.contract-doc {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 20px;
}
.contract-header { text-align: center; margin-bottom: 24px; }
.contract-title { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.contract-dates { font-size: 12px; color: var(--sub); }

.contract-section { margin-bottom: 20px; }
.contract-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--orange);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.contract-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
  line-height: 1.5;
}
.contract-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  margin-top: 6px;
  flex-shrink: 0;
}

.contract-sign {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sign-name { font-size: 18px; font-weight: 700; }
.sign-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Rules */
.rules-section { margin-bottom: 14px; }
.rule-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card2);
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 14px;
  align-items: flex-start;
  line-height: 1.5;
}
.rule-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--orange);
  min-width: 22px;
  margin-top: 2px;
}

/* Day Plan / Schedule */
.schedule-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  align-items: flex-start;
}
.schedule-row:last-child { border-bottom: none; }
.schedule-time { color: var(--orange); font-size: 12px; font-weight: 600; min-width: 90px; margin-top: 2px; }

/* ══════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s;
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
  margin-bottom: 16px;
}
.modal-hdr h3 { font-size: 18px; font-weight: 700; }
.modal-hdr button {
  background: none;
  border: none;
  color: var(--sub);
  font-size: 18px;
  cursor: pointer;
}

.modal-body { padding: 0 20px 28px; }

/* ══════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════ */

.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-danger {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-full { width: 100%; display: block; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ══════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  z-index: 200;
  white-space: nowrap;
  animation: toastIn 0.2s ease;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ══════════════════════════════════════════════════
   UTILS
══════════════════════════════════════════════════ */

.hidden { display: none !important; }

/* Read-only mode hides write-only elements */
body.readonly .write-only { display: none !important; }

/* Desktop cap */
@media (min-width: 480px) {
  #app, .modal-card { max-width: 480px; margin: 0 auto; }
  #bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .toast { max-width: 380px; }
}
