/* =========================================================
   Leveler — design tokens
   Rank accent colors are set purely via CSS custom properties
   on <html data-rank="..."> so the whole UI re-themes instantly
   with zero JS style writes and zero animation cost.
   ========================================================= */

:root {
  --bg: #06060a;
  /* Glass/system-window surfaces: translucent so the ambient rank-glow
     layer (.bg-fx) reads through them, per the transparent system-UI spec. */
  --panel: rgba(19, 19, 27, 0.60);
  --panel-2: rgba(26, 26, 36, 0.52);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f2f4fb;
  --text-dim: #a3a8ba;
  --text-faint: #6b7080;
  --danger: #f36a6a;
  --success: #34d399;

  --font-display: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-body: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SFMono-Regular", "Roboto Mono", Menlo, Consolas, monospace;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --panel-blur: 20px;

  /* Rank tokens — default E Rank (overridden per [data-rank]).
     --accent-3 is a secondary highlight used to richen the gradient on
     the higher ranks; it defaults to --accent so lower ranks render
     exactly as a clean two-tone gradient.
     Rank palette (fixed, do not add/rename ranks):
       E Blue · D Cyan · C Green · B Yellow · A Red · S Purple ·
       National White · Monarch Gold+Black */
  --accent: #4d8dff; --accent-2: #2f5fe0;
  --accent-3: var(--accent);
  --accent-soft: rgba(77, 141, 255, 0.14);
  --accent-glow: rgba(77, 141, 255, 0.42);
}

html[data-rank="D"] {
  --accent: #22d3ee; --accent-2: #06a3c2;
  --accent-soft: rgba(34, 211, 238, 0.14); --accent-glow: rgba(34, 211, 238, 0.44);
}
html[data-rank="C"] {
  --accent: #34d399; --accent-2: #0ea86f;
  --accent-soft: rgba(52, 211, 153, 0.14); --accent-glow: rgba(52, 211, 153, 0.44);
}
html[data-rank="B"] {
  --accent: #facc15; --accent-2: #d19a06;
  --accent-soft: rgba(250, 204, 21, 0.15); --accent-glow: rgba(250, 204, 21, 0.48);
}
html[data-rank="A"] {
  --accent: #ff5252; --accent-2: #c81e1e;
  --accent-soft: rgba(255, 82, 82, 0.16); --accent-glow: rgba(255, 82, 82, 0.5);
}
html[data-rank="S"] {
  /* The one, consistent S-Rank purple accent. */
  --accent: #a855f7; --accent-2: #7e22ce;
  --accent-soft: rgba(168, 85, 247, 0.17); --accent-glow: rgba(168, 85, 247, 0.52);
}
html[data-rank="National"] {
  --bg: #08080c;
  --accent: #f5f5fb; --accent-2: #c7c7d8;
  --accent-3: #ffffff;
  --accent-soft: rgba(245, 245, 251, 0.14); --accent-glow: rgba(245, 245, 251, 0.5);
  --panel: rgba(28, 28, 36, 0.58); --panel-2: rgba(36, 36, 46, 0.5);
  --panel-border: rgba(255, 255, 255, 0.18);
}
html[data-rank="Monarch"] {
  /* Premium Gold + Black — the darkest, most luxurious theme in the app.
     Metallic gold accents against a near-black backdrop, gradient dips
     into a deep black-bronze so it reads rich rather than bright/cartoonish. */
  --bg: #030201;
  --accent: #d4af37; --accent-2: #96751f;
  --accent-3: #120d04;
  --accent-soft: rgba(212, 175, 55, 0.16); --accent-glow: rgba(212, 175, 55, 0.58);
  --panel: rgba(15, 12, 5, 0.72); --panel-2: rgba(21, 17, 7, 0.62);
  --panel-border: rgba(212, 175, 55, 0.26);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  transition: background-color 0.6s var(--ease);
}

/* ---------- Ambient system-UI background (cinematic depth layer) ----------
   Fixed, behind everything (.app is normal-flow so it paints above this
   negative z-index layer with no extra stacking-context work needed).
   Pure CSS: a couple of soft rank-tinted glows, a faint schematic grid,
   a slow diagonal scan sweep, and a handful of floating particles — all
   transform/opacity animations only, so this stays cheap on battery and
   frame time. prefers-reduced-motion (below) turns every animation off. */
.bg-fx {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(640px 460px at 10% -8%, var(--accent-soft), transparent 60%),
    radial-gradient(560px 480px at 108% 28%, var(--accent-soft), transparent 55%),
    radial-gradient(720px 560px at 50% 118%, rgba(255, 255, 255, 0.025), transparent 60%);
  transition: background 0.8s var(--ease);
}
.bg-fx::before {
  content: "";
  position: absolute;
  inset: -10%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: radial-gradient(circle at 50% 25%, black, transparent 72%);
          mask-image: radial-gradient(circle at 50% 25%, black, transparent 72%);
  opacity: 0.6;
}
.bg-scan {
  position: absolute;
  top: -30%; bottom: -30%; left: -25%; width: 55%;
  background: linear-gradient(100deg, transparent 42%, var(--accent-soft) 50%, transparent 58%);
  opacity: 0.5;
  animation: bg-scan-sweep 10s linear infinite;
  will-change: transform;
}
@keyframes bg-scan-sweep {
  0%   { transform: translateX(-10%); }
  100% { transform: translateX(260%); }
}
.bg-particle {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px 3px var(--accent-glow);
  opacity: 0.3;
  animation: bg-particle-float 15s ease-in-out infinite;
  will-change: transform, opacity;
  transition: background-color 0.8s var(--ease), box-shadow 0.8s var(--ease);
}
.bg-particle:nth-child(1) { top: 16%; left: 10%; animation-duration: 13s; animation-delay: -1s; }
.bg-particle:nth-child(2) { top: 68%; left: 18%; width: 3px; height: 3px; animation-duration: 17s; animation-delay: -6s; }
.bg-particle:nth-child(3) { top: 32%; left: 82%; animation-duration: 15s; animation-delay: -3s; }
.bg-particle:nth-child(4) { top: 78%; left: 74%; width: 5px; height: 5px; animation-duration: 19s; animation-delay: -9s; }
.bg-particle:nth-child(5) { top: 48%; left: 46%; width: 3px; height: 3px; animation-duration: 14s; animation-delay: -4.5s; }
.bg-particle:nth-child(6) { top: 8%; left: 60%; animation-duration: 18s; animation-delay: -11s; }
@keyframes bg-particle-float {
  0%, 100% { transform: translate3d(0, 0, 0); opacity: 0.22; }
  50%      { transform: translate3d(16px, -26px, 0); opacity: 0.55; }
}

button, input, select { font-family: inherit; }

/* The purple box some Android phones show on long-press/tap is the OS's own
   text-selection & tap-highlight color (it's tinted per-device, not part of
   this app's theme). Turn it off and give selection a colour that matches
   the app instead, while keeping normal typing/selecting inside inputs. */
* {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}
::selection { background: var(--accent-soft); color: var(--text); }
::-moz-selection { background: var(--accent-soft); color: var(--text); }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px 16px calc(84px + env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--panel-2), var(--bg));
  border: 1px solid var(--panel-border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
  transition: color 0.5s var(--ease), text-shadow 0.5s var(--ease), border-color 0.5s var(--ease);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.2px;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.6px;
}
.rank-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-glow);
  box-shadow: 0 0 16px var(--accent-glow);
  animation: rank-glow-pulse 3.4s ease-in-out infinite;
  transition: color 0.5s var(--ease), background-color 0.5s var(--ease), border-color 0.5s var(--ease);
}
@keyframes rank-glow-pulse {
  0%, 100% { box-shadow: 0 0 10px var(--accent-glow); }
  50%      { box-shadow: 0 0 20px var(--accent-glow); }
}

/* ---------- Panels / cards ----------
   Semi-transparent + blurred "glass" system windows: --panel/--panel-2 are
   translucent (see tokens above) so the ambient .bg-fx glow behind the app
   shows through, per rank, without sacrificing text readability. */
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(var(--panel-blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--panel-blur)) saturate(150%);
  transition: background-color 0.5s var(--ease), border-color 0.5s var(--ease), box-shadow 0.5s var(--ease);
}

/* ---------- Hunter Status Window (signature element) ---------- */
.status-window {
  position: relative;
  padding: 20px 18px;
  margin-bottom: 16px;
  overflow: hidden;
}
.status-window::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(420px 240px at 12% -6%, var(--accent-soft), transparent 62%),
    radial-gradient(320px 200px at 100% 120%, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.status-bracket {
  position: absolute;
  width: 16px; height: 16px;
  border-color: var(--accent-glow);
  opacity: 0.9;
  animation: bracket-pulse 3.4s ease-in-out infinite;
}
@keyframes bracket-pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}
.status-bracket.tl { top: 10px; left: 10px; border-top: 2px solid var(--accent); border-left: 2px solid var(--accent); }
.status-bracket.br { bottom: 10px; right: 10px; border-bottom: 2px solid var(--accent); border-right: 2px solid var(--accent); }

.status-row {
  display: flex;
  align-items: center;
  gap: 18px;
  position: relative;
}

.exp-ring-wrap { position: relative; width: 108px; height: 108px; flex: none; }
.exp-ring-wrap svg { transform: rotate(-90deg); }
.exp-ring-bg { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 8; }
.exp-ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--accent-glow));
  transition: stroke-dashoffset 0.4s var(--ease), stroke 0.5s var(--ease), filter 0.5s var(--ease);
}
.exp-ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.exp-ring-level {
  font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1;
}
.exp-ring-label {
  font-family: var(--font-mono); font-size: 9px; color: var(--text-faint); letter-spacing: 1.5px; margin-top: 2px;
}

.status-info { flex: 1; min-width: 0; }
.status-rankname {
  font-family: var(--font-display); font-weight: 800; font-size: 19px;
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-glow);
  margin: 0 0 2px;
  transition: color 0.5s var(--ease), text-shadow 0.5s var(--ease);
}
.status-title { font-size: 12px; color: var(--text-dim); margin: 0 0 10px; }
.exp-bar-track {
  height: 8px; border-radius: 999px; background: rgba(255,255,255,0.06);
  overflow: hidden; border: 1px solid var(--panel-border);
}
.exp-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3));
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 0.4s var(--ease), background 0.5s var(--ease), box-shadow 0.5s var(--ease);
}
.exp-bar-text {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint);
  margin-top: 6px; display: flex; justify-content: space-between;
}

.stat-strip {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-top: 16px; position: relative;
}
.stat-cell {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 9px 8px;
  text-align: center;
}
.stat-cell .num {
  font-family: var(--font-mono); font-weight: 700; font-size: 16px; color: var(--text);
}
.stat-cell .lbl {
  font-size: 9.5px; color: var(--text-faint); letter-spacing: 0.4px; margin-top: 2px; text-transform: uppercase;
}

/* ---------- Section headers ---------- */
.section-title {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  margin: 4px 2px 10px; display: flex; align-items: center; justify-content: space-between;
}
.section-title .count { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); font-weight: 400; }
.title-actions { display: flex; align-items: center; gap: 8px; }
.mini-label {
  font-family: var(--font-mono); font-size: 9.5px; color: var(--text-faint);
  letter-spacing: 0.6px; text-transform: uppercase; margin: 10px 0 6px 2px;
}

/* ---------- Quest composer ---------- */
.composer { padding: 14px; margin-bottom: 16px; }
.composer-input-row { display: flex; gap: 8px; }
.composer input[type="text"] {
  flex: 1; background: rgba(255,255,255,0.04); border: 1px solid var(--panel-border);
  color: var(--text); border-radius: var(--radius-md); padding: 12px 12px; font-size: 14.5px;
  outline: none; transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.composer input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer input[type="text"]::placeholder { color: var(--text-faint); }

.diff-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.diff-chip {
  font-family: var(--font-mono); font-size: 11.5px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--panel-border); background: rgba(255,255,255,0.03); color: var(--text-dim);
  cursor: pointer; transition: all 0.12s var(--ease);
}
.diff-chip.active {
  color: var(--bg); background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow); font-weight: 700;
}
.diff-chip:active { transform: scale(0.96); }

/* Per-quest penalty picker — deliberately uses the fixed --danger red
   (not the rank --accent) so it always reads as "penalty" regardless
   of the active rank theme, same as the reward chips use --accent. */
.penalty-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.penalty-chip {
  font-family: var(--font-mono); font-size: 11.5px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--panel-border); background: rgba(255,255,255,0.03); color: var(--text-dim);
  cursor: pointer; transition: all 0.12s var(--ease);
}
.penalty-chip.active {
  color: #fff; background: #ff0000; border-color: #ff0000;
  box-shadow: 0 0 12px rgba(255, 0, 0, 0.55); font-weight: 700;
}
.penalty-chip:active { transform: scale(0.96); }

.miss-notice {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 12px; padding: 10px 11px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid var(--accent-glow);
  font-size: 11.5px; line-height: 1.5; color: var(--text-dim);
  transition: background-color 0.5s var(--ease), border-color 0.5s var(--ease);
}
.miss-notice-glyph { color: var(--accent); flex: none; font-size: 13px; line-height: 1.5; }
.miss-notice strong { color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  border: none; border-radius: var(--radius-md); padding: 12px 16px;
  cursor: pointer; transition: transform 0.1s var(--ease), box-shadow 0.15s var(--ease), opacity 0.15s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  color: #0b0b10; background: linear-gradient(135deg, var(--accent-2), var(--accent), var(--accent-3));
  box-shadow: 0 0 18px var(--accent-glow);
  transition: transform 0.1s var(--ease), box-shadow 0.5s var(--ease), opacity 0.15s var(--ease), background 0.5s var(--ease);
}
.btn-primary:disabled { opacity: 0.4; box-shadow: none; cursor: not-allowed; }
.btn-ghost {
  color: var(--text); background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border);
}
.btn-danger {
  color: #fff; background: linear-gradient(135deg, #e5484d, #b91c1c);
  box-shadow: 0 0 18px rgba(229, 72, 77, 0.35);
}
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.04); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all 0.12s var(--ease); flex: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent-glow); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Quest list ---------- */
.quest-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.quest-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.03); border: 1px solid var(--panel-border);
  transition: border-color 0.15s var(--ease), opacity 0.15s var(--ease), background-color 0.5s var(--ease);
  animation: card-in 0.3s var(--ease);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.quest-card.done { opacity: 0.5; }
.quest-check {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  border: 2px solid var(--accent); background: transparent;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all 0.12s var(--ease), border-color 0.5s var(--ease); color: transparent;
}
.quest-check.done { background: var(--accent); color: var(--bg); box-shadow: 0 0 10px var(--accent-glow); }
.quest-check:active { transform: scale(0.9); }
.quest-main { flex: 1; min-width: 0; }
.quest-title {
  font-size: 14.5px; font-weight: 500; word-break: break-word;
}
.quest-card.done .quest-title { text-decoration: line-through; color: var(--text-faint); }
.quest-exp {
  font-family: var(--font-mono); font-size: 11px; color: var(--accent); margin-top: 2px;
}
.quest-penalty { color: var(--danger); }
.quest-actions { display: flex; gap: 6px; flex: none; }

.empty-state {
  text-align: center; padding: 34px 16px; color: var(--text-faint);
}
.empty-state .glyph { font-size: 26px; margin-bottom: 8px; opacity: 0.6; }
.empty-state .msg { font-size: 13px; }

/* ---------- Sub-view header (Task History / Workout History) ---------- */
.subview-header { display: flex; align-items: center; gap: 10px; margin: 4px 2px 14px; }
.subview-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; }

/* ---------- Workouts ---------- */
.workout-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.workout-card {
  padding: 13px; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.03); border: 1px solid var(--panel-border);
  animation: card-in 0.3s var(--ease);
  transition: border-color 0.5s var(--ease);
}
.workout-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.workout-name { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; }
.workout-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }
.workout-exlist { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.workout-ex-row {
  display: flex; justify-content: space-between; font-size: 13px;
  padding: 6px 9px; border-radius: 8px; background: rgba(255,255,255,0.025);
}
.workout-ex-row .ex-name { color: var(--text); }
.workout-ex-row .ex-detail { font-family: var(--font-mono); color: var(--accent); font-size: 12px; }
.workout-notes {
  margin-top: 9px; font-size: 12px; color: var(--text-dim); font-style: italic;
  padding: 8px 10px; border-left: 2px solid var(--accent-glow); background: rgba(255,255,255,0.02);
  border-radius: 0 8px 8px 0;
}

/* ---------- History (Task History / Workout History) ---------- */
.history-group { margin-bottom: 18px; }
.history-date-head {
  display: flex; align-items: baseline; gap: 8px; margin: 0 2px 8px;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); letter-spacing: 0.4px; text-transform: uppercase;
}
.history-date-head .day { color: var(--accent); }
.history-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.03); border: 1px solid var(--panel-border);
  margin-bottom: 7px;
  animation: card-in 0.3s var(--ease);
}
.history-main { flex: 1; min-width: 0; }
.history-title { font-size: 13.5px; font-weight: 500; }
.history-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }
.history-xp { font-family: var(--font-mono); font-size: 11px; text-align: right; flex: none; }
.history-xp .gain { color: var(--success); }
.history-xp .loss { color: var(--danger); }
.status-pill {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: 0.4px;
  padding: 4px 8px; border-radius: 999px; flex: none; text-transform: uppercase;
}
.status-pill.completed { color: var(--success); background: rgba(52, 211, 153, 0.14); border: 1px solid rgba(52, 211, 153, 0.35); }
.status-pill.failed { color: var(--danger); background: rgba(243, 106, 106, 0.14); border: 1px solid rgba(243, 106, 106, 0.35); }

/* ---------- Modal form fields (Workout editor) ---------- */
.modal-input {
  width: 100%; background: rgba(255,255,255,0.04); border: 1px solid var(--panel-border);
  color: var(--text); border-radius: var(--radius-sm); padding: 10px 11px; font-size: 13.5px;
  outline: none; font-family: var(--font-body);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-input::placeholder { color: var(--text-faint); }
.exercise-rows { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; max-height: 220px; overflow-y: auto; }
.exercise-row { display: flex; gap: 6px; align-items: center; }
.exercise-row .ex-name-input { flex: 2; }
.exercise-row .ex-sets-input, .exercise-row .ex-reps-input { flex: 1; min-width: 0; }
.exercise-row .icon-btn { width: 30px; height: 30px; }

/* ---------- Achievements ---------- */
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.ach-card {
  padding: 13px 12px; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.03); border: 1px solid var(--panel-border);
  transition: border-color 0.3s var(--ease), box-shadow 0.5s var(--ease);
  animation: card-in 0.3s var(--ease);
}
.ach-card.unlocked { border-color: var(--accent-glow); box-shadow: 0 0 14px -6px var(--accent-glow); }
.ach-card.locked { opacity: 0.42; }
.ach-icon { font-size: 20px; margin-bottom: 6px; }
.ach-name { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.ach-desc { font-size: 10.5px; color: var(--text-faint); line-height: 1.35; }
.ach-date { font-family: var(--font-mono); font-size: 9px; color: var(--accent); margin-top: 6px; }

/* ---------- Calendar ---------- */
.clock-panel { padding: 18px; text-align: center; margin-bottom: 16px; }
.clock-time {
  font-family: var(--font-mono); font-weight: 700; font-size: 34px; letter-spacing: 1px;
  color: var(--text); text-shadow: 0 0 20px var(--accent-glow);
}
.clock-date { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }

.cal-panel { padding: 14px; margin-bottom: 20px; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-month { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow { font-size: 10px; color: var(--text-faint); padding-bottom: 4px; font-family: var(--font-mono); }
.cal-day {
  position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 12.5px; color: var(--text-dim);
}
.cal-day.other { color: var(--text-faint); opacity: 0.35; }
.cal-day.today { background: var(--accent-soft); color: var(--accent); font-weight: 700; border: 1px solid var(--accent-glow); transition: background-color 0.5s var(--ease), border-color 0.5s var(--ease), color 0.5s var(--ease); }
.cal-day .dot {
  position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 999px; background: var(--accent);
}

/* ---------- Settings ---------- */
.settings-group { padding: 6px 0 18px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px; border-radius: var(--radius-md); background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border); margin-bottom: 10px;
}
.settings-label { font-size: 13.5px; font-weight: 600; }
.settings-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.switch { width: 44px; height: 26px; border-radius: 999px; background: rgba(255,255,255,0.1); position: relative; cursor: pointer; border: 1px solid var(--panel-border); flex: none; transition: background 0.15s var(--ease); }
.switch.on { background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); transition: background-color 0.5s var(--ease), box-shadow 0.5s var(--ease); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 999px; background: #0b0b10; transition: transform 0.15s var(--ease); }
.switch.on::after { transform: translateX(18px); background: #fff; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(0deg, rgba(6,6,10,0.92), rgba(6,6,10,0.72));
  backdrop-filter: blur(var(--panel-blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--panel-blur)) saturate(150%);
  border-top: 1px solid var(--panel-border);
  z-index: 20;
  transition: border-color 0.5s var(--ease);
}
.tabbar-inner { display: flex; gap: 4px; max-width: 520px; width: 100%; }
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-faint); padding: 6px 2px; cursor: pointer;
  border-radius: var(--radius-sm); transition: color 0.4s var(--ease);
}
.tab-btn.active { color: var(--accent); }
.tab-btn.active svg { filter: drop-shadow(0 0 6px var(--accent-glow)); }
.tab-btn .tab-lbl { font-size: 9.5px; font-family: var(--font-mono); letter-spacing: 0.3px; }

/* ---------- Toasts (level up / rank up / achievement) ---------- */
.toast-layer {
  position: fixed; top: 14px; left: 0; right: 0; display: flex; flex-direction: column;
  align-items: center; gap: 8px; z-index: 50; pointer-events: none; padding: 0 16px;
}
.toast {
  pointer-events: auto;
  max-width: 460px; width: 100%;
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
  border: 1px solid var(--accent-glow);
  box-shadow: 0 0 24px var(--accent-glow), var(--shadow-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  opacity: 0; transform: translateY(-10px);
  backdrop-filter: blur(var(--panel-blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--panel-blur)) saturate(150%);
  animation: toast-in 0.25s var(--ease) forwards, toast-out 0.25s var(--ease) forwards 3.2s;
}
.toast .glyph { font-size: 20px; flex: none; }
.toast .ttl { font-family: var(--font-display); font-weight: 800; font-size: 13.5px; color: var(--accent); }
.toast .sub { font-size: 11.5px; color: var(--text-dim); margin-top: 1px; }
@keyframes toast-in { to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
  animation: modal-backdrop-in 0.2s var(--ease);
}
.modal-card {
  max-width: 380px; width: 100%; padding: 20px; border: 1px solid var(--panel-border);
  animation: modal-card-in 0.25s var(--ease);
}
@keyframes modal-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title { font-family: var(--font-display); font-weight: 800; font-size: 16px; margin-bottom: 8px; color: var(--danger); }
.modal-body { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; }

/* ---------- Views ---------- */
.view { display: none; }
.view.active { display: block; animation: view-in 0.22s var(--ease); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (min-width: 640px) {
  .app { padding-top: 32px; }
}
