:root {
  --bg: #0f1419;
  --panel: #161d24;
  --panel-2: #1d262f;
  --border: #2a3440;
  --text: #e6edf3;
  --muted: #8b97a5;
  --accent: #7fd1ff;
  --accent-2: #4ea3de;
  --done: #6ee7a8;
  --missed: #e06c75;
  --today: #ffd166;
  --future: #3a464f;
  --gap: 14px;
  --hover: #243140;
  --border-hover: #3a464f;
  --row-border: rgba(255,255,255,.04);
  --week-gap: rgba(255,255,255,.08);
  --shadow: rgba(0,0,0,.28);
  --shadow-card: rgba(0,0,0,.25);
  --input-bg: var(--bg);
  --placeholder: #5d6873;
  --primary-fg: #07121d;
  --badge-running-fg: #0f1419;
  --danger-border: #5a2f33;
  --danger-hover: #3a1d20;
  --missed-bg: rgba(224, 108, 117, .25);
  --accent-bg: rgba(127, 209, 255, .1);
  --accent-ring: rgba(127,209,255,.12);
  --accent-ring-2: rgba(127,209,255,.1);
  --date-scheme: dark;
  --date-picker-filter: invert(.7);
  --week-met-bg: rgba(110, 231, 168, .12);
  --week-met-border: rgba(110, 231, 168, .3);
  --week-met-done: var(--done);
  --week-missed-bg: rgba(224, 108, 117, .1);
  --week-missed-border: rgba(224, 108, 117, .25);
  --week-missed-done: var(--done);
}

:root[data-theme="light"] {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --border: #d4dae3;
  --text: #1a2330;
  --muted: #6b7785;
  --accent: #2a8fd0;
  --accent-2: #1f7ab8;
  --done: #2ea766;
  --missed: #d64545;
  --today: #e09200;
  --future: #dde3eb;
  --hover: #e2e8f0;
  --border-hover: #b8c2d0;
  --row-border: rgba(0,0,0,.06);
  --week-gap: rgba(0,0,0,.1);
  --shadow: rgba(0,0,0,.08);
  --shadow-card: rgba(0,0,0,.08);
  --input-bg: #f5f7fa;
  --placeholder: #98a4b2;
  --primary-fg: #ffffff;
  --badge-running-fg: #ffffff;
  --danger-border: #e0b0b0;
  --danger-hover: #f8e0e0;
  --missed-bg: rgba(214, 69, 69, .18);
  --accent-bg: rgba(42, 143, 208, .1);
  --accent-ring: rgba(42,143,208,.15);
  --accent-ring-2: rgba(42,143,208,.1);
  --date-scheme: light;
  --date-picker-filter: none;
  --week-met-bg: rgba(46, 167, 102, .1);
  --week-met-border: rgba(46, 167, 102, .25);
  --week-met-done: var(--done);
  --week-missed-bg: rgba(214, 69, 69, .08);
  --week-missed-border: rgba(214, 69, 69, .2);
  --week-missed-done: var(--done);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--accent); font-size: 22px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 600; letter-spacing: .3px; }

.actions { display: flex; gap: 8px; align-items: center; }

/* username + logout grouped together */
.nav-user-row { display: flex; gap: 8px; align-items: center; margin-left: 6px; }

/* theme toggle + burger on the right edge */
.nav-right { display: flex; gap: 8px; align-items: center; }

/* theme toggle button */
.btn-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.btn-theme:hover { background: var(--hover); }
.btn-theme svg { width: 18px; height: 18px; }
:root[data-theme="light"] .btn-theme .icon-sun { display: none; }
:root:not([data-theme="light"]) .btn-theme .icon-moon { display: none; }

/* burger button — hidden on desktop, shown on mobile */
.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}
.burger span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  border-radius: 1px;
  background: var(--text);
  transition: transform .2s, opacity .2s;
}
.burger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover { background: var(--hover); }
button:active { transform: translateY(1px); }
button.primary {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: var(--primary-fg);
  font-weight: 600;
}
button.primary:hover { background: var(--accent); border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger { color: var(--missed); border-color: var(--danger-border); }
button.danger:hover { background: var(--danger-hover); }
button.tiny { padding: 4px 8px; font-size: 13px; }

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 22px 60px;
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 18px;
  border-top: 1px solid var(--border);
}

/* Empty / hero */
.hero {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.hero h2 { color: var(--text); margin-bottom: 8px; }
.hero p { max-width: 520px; margin: 0 auto 22px; line-height: 1.5; }

/* Arc header */
.arc-head {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 22px;
}
.arc-head .title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.arc-head h2 { margin: 0; font-size: 24px; }
.arc-head .dates { color: var(--muted); font-size: 14px; }
.arc-head .countdown { color: var(--today); font-weight: 600; }
.arc-head .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}
.arc-head .meta b { color: var(--text); }

/* active (currently running) arc head */
.arc-head-active {
  border-color: var(--done);
  box-shadow: 0 0 0 1px var(--done), 0 8px 32px rgba(110,231,168,.1);
}.arc-head-active h2 { color: var(--done); }
.arc-head-active .muted { color: var(--done); font-weight: 500; }

/* locked arc head */
.arc-head-locked {
  border-color: var(--muted);
  opacity: .8;
}
.badge.locked {
  color: var(--muted);
  border-color: var(--muted);
  background: var(--week-gap);
}
.participants { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--text);
}

/* Challenge card */
.challenge {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 18px;
  min-width: 0;
  overflow: hidden;
}
.challenge-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 4px;
}
.challenge-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.challenge-header .challenge-meta {
  margin-bottom: 0;
  flex-shrink: 0;
}
.challenge-desc {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 10px;
  line-height: 1.45;
}
.challenge-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.challenge-meta .target {
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  height: 26px;
}
.btn-today {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-today:hover { background: var(--hover); color: var(--accent); border-color: var(--accent); }
.btn-today svg { width: 14px; height: 14px; }
.streak-badge {
  color: var(--today);
  background: rgba(255,209,102,.12);
  padding: 2px 8px;
  border-radius: 6px;
}
.hint-desktop { display: inline; }
.day-row .streak {
  font-size: 11px;
  color: var(--today);
  white-space: nowrap;
}

/* Day grid — single scroll container for all rows */
.day-grid {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 70vh;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.day-grid::-webkit-scrollbar { height: 8px; }
.day-grid::-webkit-scrollbar-track { background: transparent; }
.day-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.day-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--row-border);
  background: var(--panel);
  width: max-content;
  min-width: 100%;
}
.day-row:last-child { border-bottom: none; }
.day-row .name {
  flex: 0 0 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  padding-right: 12px;
  position: sticky;
  left: 0;
  top: 0;
  z-index: 5;
  background: var(--panel);
  border-right: 1px solid var(--border);
  margin-top: -6px;
  padding-top: 6px;
  padding-bottom: 6px;
  height: auto;
  min-height: 44px;
}
.day-row .name .name-text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.day {
  flex: 0 0 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  position: relative;
}
.day:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.day.done {
  background: var(--done);
  border-color: var(--done);
}
.day.missed {
  background: var(--missed-bg);
  border-color: var(--danger-border);
}
.day.week-met {
  background: var(--week-met-bg);
  border-color: var(--week-met-border);
}
.day.week-met.done {
  background: var(--week-met-done);
  border-color: var(--week-met-done);
}
.day.week-missed {
  background: var(--week-missed-bg);
  border-color: var(--week-missed-border);
}
.day.week-missed.done {
  background: var(--week-missed-done);
  border-color: var(--week-missed-done);
}
.day.future {
  background: var(--future);
  border-color: var(--future);
  cursor: default;
}
.day.today {
  box-shadow: inset 0 0 0 2px var(--today);
}
.day.today.done { box-shadow: inset 0 0 0 2px var(--done); }

/* week separator between groups of 7 days */
.week-gap {
  flex: 0 0 28px;
  height: 32px;
  width: 28px;
  margin: 0 2px;
  position: relative;
  flex-shrink: 0;
}
.week-gap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--week-gap);
  border-radius: 1px;
}

/* collapsed "show older days" box */
.day-expand {
  flex: 0 0 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  user-select: none;
  position: sticky;
  left: 146px;
  top: 0;
  z-index: 5;
  margin-top: -6px;
  padding-top: 6px;
  padding-bottom: 6px;
  height: auto;
  min-height: 44px;
  transition: border-color .15s, color .15s, background .15s;
}
.day-expand:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--panel-2);
}

/* expanded "hide older days" box */
.day-collapse {
  flex: 0 0 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  position: sticky;
  left: 146px;
  top: 0;
  z-index: 5;
  margin-top: -6px;
  padding-top: 6px;
  padding-bottom: 6px;
  height: auto;
  min-height: 44px;
  transition: border-color .15s, color .15s, background .15s;
}
.day-collapse:hover {
  background: var(--accent);
  color: var(--primary-fg);
}

/* spacer in axis row to align with toggle button (see definition below) */

/* Date axis under grid */
.axis {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  background: var(--panel);
  width: max-content;
  min-width: 100%;
}
.axis .name {
  flex: 0 0 140px;
  padding-right: 12px;
  position: sticky;
  left: 0;
  top: 0;
  z-index: 5;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.axis .tick { flex: 0 0 32px; text-align: center; }
.axis .week-gap-tick {
  flex: 0 0 28px;
  width: 28px;
  margin: 0 2px;
  text-align: center;
  color: var(--muted);
}
.axis .week-gap-tick small {
  font-size: 9px;
  font-weight: 600;
}
.day-toggle-spacer {
  flex: 0 0 32px;
  height: 32px;
  position: sticky;
  left: 146px;
  top: 0;
  z-index: 5;
}

/* Legend */
.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  margin-top: 14px;
}
.legend .sw {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid var(--border);
}
.legend .sw.done { background: var(--done); border-color: var(--done); }
.legend .sw.missed { background: var(--missed-bg); border-color: var(--danger-border); }
.legend .sw.future { background: var(--future); border-color: var(--future); }
.legend .sw.today { background: var(--panel-2); border-color: var(--today); }

/* Forms */
.form-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 840px;
  margin: 0 auto;
  box-shadow: 0 8px 32px var(--shadow);
}
.form-section {
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; margin-bottom: 16px; }
.form-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  margin: 0 0 16px;
  font-weight: 600;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  letter-spacing: .02em;
  font-weight: 500;
}
.field small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
}
.field-value {
  padding: 10px 0;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder, .field textarea::placeholder { color: var(--placeholder); }
.field input:hover, .field textarea:hover, .field select:hover { border-color: var(--border-hover); }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: var(--panel-2);
}
/* date inputs: adapt to theme */
.field input[type="date"] {
  color-scheme: var(--date-scheme);
}
.field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: var(--date-picker-filter, invert(.7));
  cursor: pointer;
}
.field textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.row2 { display: flex; gap: 14px; }
.row2 .field { flex: 1; }
.row3 { display: flex; gap: 14px; }
.row3 .field { flex: 1; }

/* challenge grid: 2 columns on wide screens */
.challenge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* profile: 3-column form layout */
.profile-card { max-width: 1100px; }
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  margin-top: 28px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}
.profile-col {
  padding: 0 28px;
  border-right: 1px solid var(--border);
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.profile-col:first-child { padding-left: 0; }
.profile-col:last-child { padding-right: 0; border-right: none; }

.entry-list { display: flex; flex-direction: column; gap: 10px; }
.entry {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  transition: border-color .15s;
}
.entry:hover { border-color: var(--border-hover); }
.entry:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring-2); }
.entry input, .entry textarea {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  transition: border-color .15s, background .15s;
}
.entry input:hover { border-color: var(--border); }
.entry input:focus {
  outline: none;
  border-color: var(--accent-2);
  background: var(--panel-2);
}
.entry input { flex: 1; min-width: 0; }
.entry select {
  flex: 0 0 220px;
  padding: 7px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s;
}
.entry select:hover { border-color: var(--border-hover); }
.entry select:focus { outline: none; border-color: var(--accent); }
.entry button { flex-shrink: 0; }
.entry .grip { color: var(--muted); font-size: 12px; }

.subform-actions { margin-top: 12px; }

/* challenge entry: stacked title row + description */
.entry-challenge { flex-direction: column; align-items: stretch; gap: 10px; }
.entry-challenge .challenge-row { display: flex; gap: 10px; align-items: center; }
.entry-challenge .interval-group {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.entry-challenge .interval-group input { width: 64px; text-align: center; }
.entry-challenge .interval-group .muted { font-size: 12px; white-space: nowrap; }
.entry-challenge textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
  resize: vertical;
  min-height: 52px;
  line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
.entry-challenge textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring-2);
}

.form-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* Arc list */
.arc-list { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.arc-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.arc-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--shadow-card);
}
.arc-card:active { transform: translateY(0); }
.arc-card .info h3 { margin: 0 0 6px; font-size: 20px; }
.arc-card .info .sub { color: var(--muted); font-size: 14px; }
.arc-card .badges { display: flex; gap: 8px; }
.badge {
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.current { color: var(--done); border-color: var(--done); }
.badge.upcoming { color: var(--accent); border-color: var(--accent); }
.badge.past { color: var(--muted); }
.arc-card .ctrls { display: flex; gap: 8px; flex-shrink: 0; }

/* active (currently running) arc cards */
.arc-card-active {
  border-color: var(--done);
  box-shadow: 0 0 0 1px var(--done), 0 6px 24px rgba(110,231,168,.12);
  position: relative;
}
.arc-card-active::before {
  content: "";
  position: absolute;
  left: 0; top: 18px; bottom: 18px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--done);
}
.arc-card-active .info h3 { color: var(--done); }

/* pulsing "running" badge */
.badge.running {
  background: var(--done);
  color: var(--badge-running-fg);
  border-color: var(--done);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge.running::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--badge-running-fg);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title h2 { margin: 0; font-size: 20px; }

.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- auth ---------- */
.auth-card {
  max-width: 360px;
  margin: 48px auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
.auth-card h2 { margin: 0 0 18px; font-size: 22px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.auth-card input {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.auth-card input:focus { outline: none; border-color: var(--accent); }
.auth-card .primary { width: 100%; margin-top: 6px; }
.auth-error { color: var(--missed); font-size: 13px; min-height: 18px; margin: 4px 0; }
.auth-card .toggle-field { margin-bottom: 14px; }
.auth-card .toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0;
  font-size: 13px;
  color: var(--text);
}
.auth-card .toggle-switch input { display: none; }
.toggle-track {
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background .2s;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform .2s;
}
.auth-card .toggle-switch input:checked + .toggle-track {
  background: var(--accent-2);
}
.auth-card .toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: var(--primary-fg);
}
.auth-switch { text-align: center; color: var(--muted); font-size: 13px; margin-top: 16px; }
.auth-switch a { color: var(--accent); cursor: pointer; }

.user-name {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  align-self: center;
  transition: background .15s, border-color .15s, transform .05s;
}
.user-name:hover { background: var(--hover); }
.user-name:active { transform: translateY(1px); }

.chip small { color: var(--muted); font-size: 11px; }

/* ---------- admin: users table ---------- */
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.users-table th, .users-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.users-table th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.users-table td small { color: var(--muted); }
.users-table .row-ctrls { display: flex; gap: 6px; }
.users-table .row-ctrls button:disabled { opacity: .4; cursor: not-allowed; }
.admin-users-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 8px 16px; }
.form-card select {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.form-card input[readonly] { opacity: .6; }

/* ---------- mobile responsive ---------- */

/* Tablet and below */
@media (max-width: 768px) {
  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }
  .brand h1 { font-size: 17px; }
  .brand-mark { font-size: 18px; }

  /* burger nav: hide inline buttons, show burger */
  .burger { display: flex; }
  .actions {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    border-top: 1px solid var(--border);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
    z-index: 9;
  }
  .actions.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .actions button {
    width: 100%;
    text-align: left;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px 18px;
    font-size: 14px;
  }
  .actions button.primary {
    border-bottom: 1px solid var(--border);
  }
  .actions > button:last-of-type {
    border-bottom: none;
  }
  /* username + logout in one row */
  .actions .nav-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-top: 1px solid var(--border);
  }
  .actions .nav-user-row .user-name {
    width: auto;
    flex-shrink: 0;
    min-width: 0;
    margin-right: auto;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    height: 38px;
    display: inline-flex;
    align-items: center;
  }
  .actions .nav-user-row .user-name:hover { background: var(--hover); }
  .actions .nav-user-row button {
    width: auto;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    height: 38px;
  }

  button { padding: 6px 10px; font-size: 13px; }
  button.tiny { padding: 3px 6px; font-size: 12px; }

  main {
    padding: 16px 14px 50px;
  }

  .arc-head { padding: 16px 18px; }
  .arc-head h2 { font-size: 20px; }
  .arc-head .dates { font-size: 13px; }
  .arc-head .meta { gap: 12px; font-size: 12px; }

  .challenge { padding: 14px 16px; }
  .challenge-title { font-size: 15px; }
  .hint-desktop { display: none; }
  .streak-badge { display: none; }

  .form-card { padding: 20px 18px; max-width: 100%; }
  .form-section { margin-bottom: 20px; padding-bottom: 18px; }
  .row2 { flex-direction: column; gap: 0; }
  .row3 { flex-direction: column; gap: 0; }
  .challenge-grid { grid-template-columns: 1fr; }
  .profile-card { max-width: 100%; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-col { padding: 0; border-right: none; }
  .arc-list { grid-template-columns: 1fr; }

  .arc-card {
    flex-wrap: wrap;
    padding: 16px 18px;
    gap: 10px;
  }
  .arc-card .info h3 { font-size: 18px; }
  .arc-card .badges { order: 2; }

  .entry select { flex: 0 0 160px; }

  .users-table { font-size: 13px; }
  .users-table th, .users-table td { padding: 8px 10px; }
}

/* Phone */
@media (max-width: 480px) {
  .topbar {
    padding: 10px 12px;
    gap: 6px;
  }
  .brand h1 { font-size: 20px; }
  .brand-mark { font-size: 20px; }
  button { padding: 5px 8px; font-size: 12px; }
  button.tiny { padding: 3px 5px; font-size: 11px; }
  .user-name {
    font-size: 12px;
    padding: 5px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .actions .nav-user-row button {
    padding: 5px 10px;
    font-size: 12px;
    height: 34px;
  }
  .actions .nav-user-row .user-name {
    height: 34px;
  }
  .btn-theme {
    width: 34px;
    height: 34px;
  }

  main {
    padding: 12px 10px 40px;
  }

  .hero { padding: 40px 16px; }
  .hero h2 { font-size: 18px; }
  .hero p { font-size: 13px; }

  .arc-head { padding: 14px 16px; border-radius: 12px; }
  .arc-head h2 { font-size: 18px; }
  .arc-head .title-row { gap: 6px; }
  .arc-head .ctrls { gap: 4px; }
  .arc-head .dates { font-size: 12px; }
  .arc-head .meta { gap: 10px; font-size: 11px; margin-top: 10px; }

  .challenge { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; }
  .challenge-title { font-size: 14px; }
  .challenge-desc { font-size: 12px; }
  .challenge-meta { font-size: 11px; gap: 10px; }

  /* Day grid: narrow name column, smaller cells */
  .day-row .name {
    flex: 0 0 90px;
    font-size: 13px;
    padding-right: 8px;
  }
  .day-expand, .day-collapse {
    left: 96px;
  }
  .axis .name {
    flex: 0 0 90px;
    padding-right: 8px;
  }
  .day-toggle-spacer { left: 96px; }
  .day {
    flex: 0 0 28px;
    height: 28px;
    border-radius: 5px;
  }
  .week-gap { height: 28px; }
  .axis .tick { flex: 0 0 28px; }
  .day-grid::-webkit-scrollbar { height: 6px; }

  .form-card {
    padding: 16px 14px;
    border-radius: 12px;
  }
  .form-section h3 { font-size: 12px; }
  .field input, .field textarea, .field select { padding: 9px 10px; font-size: 14px; }
  .entry { padding: 7px 9px; gap: 8px; }
  .entry select { flex: 0 0 130px; font-size: 13px; }
  .entry-challenge .interval-group input { width: 52px; }
  .form-footer { gap: 8px; }

  .arc-card {
    padding: 14px 16px;
    border-radius: 12px;
  }
  .arc-card .info h3 { font-size: 16px; }
  .arc-card .info .sub { font-size: 12px; }
  .badge { font-size: 11px; padding: 3px 8px; }

  .section-title h2 { font-size: 17px; }

  .auth-card {
    margin: 24px auto;
    padding: 20px;
  }

  /* Users table: scroll horizontally on phones */
  .admin-users-wrap { padding: 4px 8px; overflow-x: auto; }
  .users-table { min-width: 560px; }

  .legend { gap: 12px; font-size: 11px; }
  .legend .sw { width: 14px; height: 14px; }

  .foot { font-size: 11px; padding: 14px; }
}
