/*
 * Theme tokens. Components below use only these names, so another palette is one more
 * :root[data-theme="…"] block. The three candidates are in design-palettes.html at the repo root;
 * Neon Club is the default.
 */
:root,
:root[data-theme="neon"] {
    color-scheme: dark;

    --bg: #0b0f24;
    --bg-deep: #080b1b;          /* nav, inputs, wells */
    --surface: #131938;          /* cards */
    --surface-2: #1b2247;        /* raised, hover */
    --line: #262f5e;

    --fg: #fdf3ff;
    --muted: #9a9ec4;
    --faint: #5d628a;

    --accent: #ff3ea5;
    --accent-strong: #ff1f93;
    --accent-line: rgba(255, 124, 196, 0.6);
    --accent-wash: rgba(255, 62, 165, 0.12);
    --on-accent: #ffffff;
    --secondary: #6ff2ff;
    --secondary-wash: rgba(111, 242, 255, 0.1);
    --ok: #6fe3a0;
    --danger: #ff5c5c;
    --danger-wash: rgba(255, 92, 92, 0.14);
    --warn: #ffd166;

    --glow: 0 0 0 1px rgba(255, 124, 196, 0.85), 0 0 18px 2px rgba(255, 62, 165, 0.55), 0 0 56px 6px rgba(255, 62, 165, 0.22);
    --glow-hover: 0 0 0 1px rgba(255, 160, 215, 0.95), 0 0 24px 4px rgba(255, 62, 165, 0.75), 0 0 72px 12px rgba(255, 62, 165, 0.3);
    --glow-soft: 0 0 14px rgba(255, 62, 165, 0.4);
    --glow-secondary: 0 0 0 1px rgba(111, 242, 255, 0.7), 0 0 16px rgba(111, 242, 255, 0.35);
    --focus-ring: 0 0 0 3px rgba(255, 62, 165, 0.18), 0 0 18px rgba(255, 62, 165, 0.35);
    --text-glow: 0 0 4px rgba(255, 140, 205, 0.9), 0 0 14px rgba(255, 62, 165, 0.7), 0 0 30px rgba(255, 62, 165, 0.4);
    --label-glow: 0 0 8px rgba(95, 240, 255, 0.6);
    --lift: 0 18px 40px -18px rgba(0, 0, 0, 0.8);
    --ground:
        radial-gradient(90% 420px at 50% 0%, rgba(255, 62, 165, 0.13), transparent 70%),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 22px);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23ff3ea5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

    --font-display: 'Righteous', 'Trebuchet MS', sans-serif;
    --font-body: 'Barlow', -apple-system, 'Segoe UI', system-ui, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --radius: 16px;
    --radius-sm: 12px;
    --radius-pill: 999px;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    font-size: 16px;
    background: var(--ground), var(--bg);
    background-attachment: fixed;
    color: var(--fg);
    line-height: 1.5;
}

main {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

a { color: var(--secondary); text-underline-offset: 3px; text-decoration-color: rgba(111, 242, 255, 0.4); }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
/* Blazor's FocusOnNavigate moves focus to the h1 for screen readers; it needs no ring. */
h1:focus, h1:focus-visible { outline: none; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; text-wrap: balance; }
h1 { font-size: 2rem; line-height: 1.15; margin: 0.25rem 0 1.25rem; text-shadow: var(--text-glow); }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; color: var(--secondary); text-shadow: var(--label-glow); }
h3 { font-size: 1rem; margin: 0 0 0.5rem; color: var(--fg); }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.small { font-size: 0.875rem; }

/* ---------- Navigation ---------- */
.nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 20px;
    padding: 12px 20px;
    background: rgba(8, 11, 27, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.nav .brand {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--fg);
    text-decoration: none;
    text-shadow: var(--text-glow);
    margin-right: 8px;
}
.nav nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.nav nav a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.nav nav a:hover { color: var(--fg); background: var(--surface); }
.nav nav a.brand, .nav nav a.brand:hover { padding: 0 8px 0 0; color: var(--fg); background: none; }
.nav nav a.active { color: var(--fg); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent-line), var(--glow-soft); }
.signout { display: flex; gap: 12px; align-items: center; margin: 0; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--lift);
}
.card > :last-child { margin-bottom: 0; }
.card.narrow {
    max-width: 420px;
    margin: 14vh auto;
    padding: 36px 28px;
    text-align: center;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    box-shadow: var(--lift), 0 0 0 1px rgba(255, 124, 196, 0.35), 0 0 48px -6px rgba(255, 62, 165, 0.35);
}
.card.narrow h1 { font-size: 2.6rem; margin-bottom: 0.5rem; }
.card.narrow p { color: var(--muted); margin: 0 0 24px; }
.card.notice {
    border-color: var(--accent-line);
    background: linear-gradient(180deg, rgba(255, 62, 165, 0.08), var(--surface) 60%);
    box-shadow: var(--lift), 0 0 32px -8px rgba(255, 62, 165, 0.45);
}
.card.inset { background: var(--bg-deep); box-shadow: none; margin: 16px 0 0; }

/* ---------- Buttons ---------- */
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: 600 0.95rem/1.2 var(--font-body);
    padding: 9px 18px;
    border-radius: var(--radius-pill);
    border: 0;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: var(--glow);
    cursor: pointer;
    text-decoration: none;
    transition: box-shadow 0.18s ease, transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}
button:hover, .button:hover { box-shadow: var(--glow-hover); transform: translateY(-1px); }
button:active, .button:active { transform: translateY(1px); }

button.secondary, .button.secondary {
    background: transparent;
    color: var(--secondary);
    box-shadow: inset 0 0 0 1.5px var(--secondary);
}
button.secondary:hover, .button.secondary:hover { background: var(--secondary-wash); box-shadow: inset 0 0 0 1.5px var(--secondary), var(--glow-secondary); }

button.danger, button.secondary.danger {
    background: transparent;
    color: var(--danger);
    box-shadow: inset 0 0 0 1.5px rgba(255, 92, 92, 0.55);
}
button.danger:hover, button.secondary.danger:hover { background: var(--danger-wash); box-shadow: inset 0 0 0 1.5px var(--danger); }
button.confirm, button.confirm.danger { background: var(--danger); color: #fff; box-shadow: 0 0 18px rgba(255, 92, 92, 0.45); }
button.confirm:hover { box-shadow: 0 0 26px rgba(255, 92, 92, 0.65); }

button.link, button.link:hover {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    color: var(--secondary);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
    transform: none;
}
button.link.danger { color: var(--danger); }

button:disabled, button:disabled:hover {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ---------- Form fields ---------- */
input, select, textarea {
    font: 500 1rem/1.3 var(--font-body);
    color: var(--fg);
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-deep);
    max-width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: rgba(255, 62, 165, 0.4); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
input[readonly] { color: var(--muted); }
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    background: var(--chevron) no-repeat right 14px center, var(--bg-deep);
    cursor: pointer;
}
select option { background: var(--surface-2); color: var(--fg); }
textarea { resize: vertical; min-height: 5rem; }
input[type=checkbox], input[type=radio] {
    width: 18px;
    height: 18px;
    padding: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
input[type=checkbox]:focus, input[type=radio]:focus { box-shadow: none; }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(0.7) sepia(1) hue-rotate(270deg) saturate(4); cursor: pointer; }

label { display: block; margin-bottom: 14px; }
label > span { display: block; font-size: 0.875rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
label.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; cursor: pointer; white-space: nowrap; }
label.inline > input { margin: 0; }
form.card label > input, form.card label > textarea, form.card label > select { width: 100%; }

.field { margin: 0; }
.field input { width: 96px; }
.field input[type=date] { width: auto; }
.picker input[type=search] { width: 100%; margin-bottom: 8px; }

/* Training days as toggle chips; the checkbox stays in place for keyboard and screen readers. */
fieldset.days { border: none; padding: 0; margin: 8px 0 16px; display: flex; flex-wrap: wrap; gap: 8px; }
fieldset.days legend { padding: 0; margin-bottom: 8px; font-size: 0.875rem; font-weight: 600; color: var(--muted); }
fieldset.days label.inline {
    position: relative;
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}
fieldset.days label.inline:hover { color: var(--fg); border-color: var(--faint); }
fieldset.days label.inline input { position: absolute; opacity: 0; width: 1px; height: 1px; }
fieldset.days label.inline:has(input:checked) {
    color: var(--fg);
    border-color: var(--accent);
    background: var(--accent-wash);
    box-shadow: var(--glow-soft);
}
fieldset.days label.inline:has(input:focus-visible) { outline: 2px solid var(--secondary); outline-offset: 2px; }

/* ---------- Layout helpers ---------- */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.row.spread { justify-content: space-between; }
.wide { width: 100%; }
.grow { flex: 1 1 160px; }
.short { width: 72px; }
.prewrap { white-space: pre-wrap; }

/* ---------- Lists ---------- */
.list { list-style: none; padding: 0; margin: 0 0 12px; }
.list > li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}
.list > li:last-child { border-bottom: none; }
.list > li > a:first-child, .list > li > span > a { font-weight: 600; color: var(--fg); text-decoration: none; }
.list > li > a:first-child:hover, .list > li > span > a:hover { color: var(--accent); }
.list.compact > li { padding: 6px 0; }
.list > li.pending { color: var(--muted); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- Workout and plan pieces ---------- */
.slot { border-bottom: 1px solid var(--line); padding: 14px 0; }
.slot-fields { align-items: flex-end; }
.slot-group {
    border: 1px solid var(--secondary);
    border-radius: var(--radius);
    box-shadow: var(--glow-secondary);
    background: var(--secondary-wash);
    padding: 4px 14px;
    margin: 14px 0;
}
.slot-group .slot:last-child { border-bottom: none; }
.group-header { align-items: flex-end; padding: 10px 0; border-bottom: 1px solid var(--line); }
.group-header .group-title { color: var(--secondary); text-shadow: var(--label-glow); font-weight: 600; }
.slot-select { display: inline-flex; align-items: center; gap: 6px; }
.set-targets { border-left: 2px solid var(--line); padding-left: 12px; margin: 8px 0; }
.set-targets input[type="number"] { width: 6.5em; }
.date { display: inline-block; min-width: 96px; color: var(--secondary); font-weight: 600; font-variant-numeric: tabular-nums; }
.week li.past { opacity: 0.5; }
.week li.today { font-weight: 600; }
.week li.today .date { color: var(--accent); text-shadow: var(--glow-soft); }

.badge {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line);
    color: var(--muted);
    white-space: nowrap;
}
.badge.active { border-color: var(--accent-line); color: var(--accent); background: var(--accent-wash); }
.badge.ended { color: var(--faint); }

.done { color: var(--ok); font-weight: 700; text-decoration: none; text-shadow: 0 0 8px rgba(111, 227, 160, 0.6); }

.checkin { margin-top: 10px; }
.checkin .field input[type=number] { width: 104px; }
.confirm-ask { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }

details { margin-top: 14px; }
details summary { cursor: pointer; color: var(--secondary); font-weight: 600; }

.progress-line { width: 100%; height: auto; overflow: visible; }
.progress-line .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; filter: drop-shadow(0 0 4px rgba(255, 62, 165, 0.8)); }
.progress-line .dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.progress-line .target { stroke: var(--secondary); stroke-dasharray: 4 6; opacity: 0.7; }

.exercise-image {
    max-width: 100%;
    max-height: 260px;
    display: block;
    margin-bottom: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
}

pre {
    background: var(--bg-deep);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    overflow-x: auto;
}
code { font-family: var(--font-mono); font-size: 0.875rem; color: var(--secondary); }

footer { max-width: 960px; margin: 0 auto; padding: 16px 16px 32px; }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    padding: 12px 20px;
    background: #2a0f1c;
    color: var(--fg);
    border-top: 1px solid var(--danger);
    box-shadow: 0 -8px 30px rgba(255, 92, 92, 0.25);
}

@media (max-width: 600px) {
    h1 { font-size: 1.6rem; }
    .nav { position: static; padding: 10px 16px; }
    .nav nav a { padding: 5px 10px; }
    .list > li { flex-wrap: wrap; }
    .card { padding: 16px; }
}

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