/* =============================================================
   Regymo — Design System v2
   Serious, disciplined fitness-tech. Graphite base, deep accents.
   ============================================================= */

:root {
    /* ---------- Brand — deep indigo, no candy ---------- */
    --brand-400: #6366f1;
    --brand-500: #4f46e5;
    --brand-600: #4338ca;
    --brand-700: #3730a3;
    --brand-800: #312e81;
    --brand-900: #1e1b4b;

    /* ---------- Surface — graphite/bone ---------- */
    --bg:            #f3f4f7;
    --bg-subtle:     #e7e9ef;
    --surface:       #ffffff;
    --surface-2:     #f6f7fa;
    --surface-hover: #edeff4;
    --surface-ink:   #0b0f1a;
    --surface-ink-2: #111827;

    /* ---------- Text ---------- */
    --text:       #0b0f1a;
    --text-soft:  #1f2937;
    --text-muted: #4b5563;
    --text-faint: #6b7280;
    --text-dim:   #9ca3af;
    --text-on-brand: #ffffff;
    --text-on-ink:   #f3f4f6;

    /* ---------- Border ---------- */
    --border:        #d1d5db;
    --border-soft:   #e4e6eb;
    --border-strong: #9ca3af;
    --border-ink:    rgba(255, 255, 255, 0.1);

    /* ---------- Feedback ---------- */
    --danger:      #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.1);
    --warn:        #d97706;
    --warn-soft:   rgba(217, 119, 6, 0.1);
    --success:     #059669;
    --success-soft: rgba(5, 150, 105, 0.1);
    --info:        #2563eb;
    --info-soft:   rgba(37, 99, 235, 0.1);

    /* ---------- Radii — tighter, engineered ---------- */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 18px;
    --r-2xl: 22px;
    --r-full: 999px;

    /* ---------- Shadows — denser, grounded ---------- */
    --sh-xs: 0 1px 2px rgba(11, 15, 26, 0.06);
    --sh-sm: 0 1px 2px rgba(11, 15, 26, 0.08), 0 1px 2px rgba(11, 15, 26, 0.04);
    --sh-md: 0 2px 4px rgba(11, 15, 26, 0.08), 0 4px 8px -2px rgba(11, 15, 26, 0.06);
    --sh-lg: 0 4px 8px rgba(11, 15, 26, 0.08), 0 12px 24px -6px rgba(11, 15, 26, 0.12);
    --sh-xl: 0 20px 40px -12px rgba(11, 15, 26, 0.25);
    --sh-brand: 0 6px 16px -4px rgba(67, 56, 202, 0.5);
    --sh-inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);

    /* ---------- Gradients — single-family, no rainbow ---------- */
    --grad-brand:      linear-gradient(140deg, #4f46e5 0%, #4338ca 60%, #3730a3 100%);
    --grad-brand-soft: linear-gradient(140deg, rgba(79, 70, 229, 0.08) 0%, rgba(67, 56, 202, 0.06) 100%);
    --grad-ink:        linear-gradient(160deg, #111827 0%, #0b0f1a 100%);
    --grad-ink-brand:  linear-gradient(160deg, #1e1b4b 0%, #0b0f1a 90%);

    /* ---------- Section accents — one confident hue per section ---------- */
    --sec-workout:      #4338ca;
    --sec-workout-600:  #3730a3;
    --sec-workout-soft: rgba(67, 56, 202, 0.1);
    --sec-workout-grad: linear-gradient(140deg, #4f46e5 0%, #3730a3 100%);
    --sec-workout-glow: 0 10px 22px -8px rgba(67, 56, 202, 0.55);
    --sec-workout-ink:  #1e1b4b;

    --sec-food:        #047857;
    --sec-food-600:    #065f46;
    --sec-food-soft:   rgba(4, 120, 87, 0.1);
    --sec-food-grad:   linear-gradient(140deg, #059669 0%, #047857 60%, #064e3b 100%);
    --sec-food-glow:   0 10px 22px -8px rgba(4, 120, 87, 0.5);
    --sec-food-ink:    #022c22;

    --sec-coach:       #6d28d9;
    --sec-coach-600:   #5b21b6;
    --sec-coach-soft:  rgba(109, 40, 217, 0.1);
    --sec-coach-grad:  linear-gradient(140deg, #7c3aed 0%, #5b21b6 100%);
    --sec-coach-glow:  0 10px 22px -8px rgba(109, 40, 217, 0.5);
    --sec-coach-ink:   #2e1065;

    --sec-duel:        #b45309;
    --sec-duel-600:    #92400e;
    --sec-duel-soft:   rgba(180, 83, 9, 0.12);
    --sec-duel-grad:   linear-gradient(140deg, #f59e0b 0%, #d97706 60%, #b45309 100%);
    --sec-duel-glow:   0 10px 22px -8px rgba(180, 83, 9, 0.55);
    --sec-duel-ink:    #451a03;

    --sec-friends:      #be123c;
    --sec-friends-600:  #9f1239;
    --sec-friends-soft: rgba(190, 18, 60, 0.08);
    --sec-friends-grad: linear-gradient(140deg, #e11d48 0%, #9f1239 100%);
    --sec-friends-glow: 0 10px 22px -8px rgba(190, 18, 60, 0.45);

    /* Rarity tiers — metallic, serious */
    --rarity-bronze: linear-gradient(140deg, #78350f 0%, #b45309 50%, #d97706 100%);
    --rarity-silver: linear-gradient(140deg, #475569 0%, #94a3b8 50%, #cbd5e1 100%);
    --rarity-gold:   linear-gradient(140deg, #92400e 0%, #d97706 40%, #fbbf24 100%);
    --rarity-legend: linear-gradient(140deg, #1e1b4b 0%, #4338ca 50%, #6d28d9 100%);

    /* ---------- Type ---------- */
    --font-sans:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: "Space Grotesk", "Inter", -apple-system, sans-serif;
    --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* ---------- Spacing ---------- */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-8: 32px;
    --s-10: 40px;
    --s-12: 48px;
    --s-16: 64px;

    /* ---------- Layout ---------- */
    --container: 1120px;
    --topbar-h: 64px;

    /* ---------- Transition ---------- */
    --t-fast: 120ms cubic-bezier(0.2, 0, 0.2, 1);
    --t:      180ms cubic-bezier(0.2, 0, 0.2, 1);
    --t-slow: 300ms cubic-bezier(0.2, 0, 0.2, 1);
}

/* ============================================================
   Reset / Base
   ============================================================ */

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

html { -webkit-text-size-adjust: 100%; tab-size: 4; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-image:
        linear-gradient(rgba(11, 15, 26, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(11, 15, 26, 0.025) 1px, transparent 1px);
    background-size: 56px 56px;
    background-position: -1px -1px;
    background-attachment: fixed;
    min-height: 100vh;
}

img, svg, video, canvas { max-width: 100%; display: block; }

a { color: var(--brand-600); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--brand-700); }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 var(--s-4);
    line-height: 1.15;
}
h1 { font-size: clamp(1.9rem,  2.6vw + 1rem,  2.6rem);  letter-spacing: -0.035em; font-weight: 700; }
h2 { font-size: clamp(1.45rem, 1.6vw + 0.9rem, 1.9rem); font-weight: 700; }
h3 { font-size: 1.1rem;  font-weight: 700; letter-spacing: -0.015em; }
h4 { font-size: 0.98rem; font-weight: 600; letter-spacing: -0.01em; }

.display-num {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "ss01", "ss02";
}

.mono-num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.eyebrow {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

p { margin: 0 0 var(--s-4); }
.text-lead  { font-size: clamp(1rem, 0.4vw + 0.95rem, 1.15rem); color: var(--text-soft); }
.text-muted { color: var(--text-muted); font-size: 0.88rem; }
.text-faint { color: var(--text-faint); }

code, kbd, pre, samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
}
code:not(pre > code) {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.88em;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: var(--s-6) 0;
}

::selection { background: var(--brand-500); color: #fff; }

/* ============================================================
   Layout — container & topbar
   ============================================================ */

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--s-8) var(--s-5);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: var(--s-5);
    padding: 0 clamp(16px, 3vw, 32px);
    background: rgba(246, 247, 250, 0.88);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar .logo {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: -0.03em;
    text-decoration: none;
}
.topbar .logo::before {
    content: "F";
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--grad-ink-brand);
    box-shadow: var(--sh-md), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    display: grid;
    place-items: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
.topbar .logo .wm-accent { color: var(--brand-500); margin-left: -3px; }
.topbar .logo:hover { color: var(--text); }

.topbar nav {
    display: flex;
    align-items: center;
    gap: var(--s-1);
    margin-left: auto;
}

.topbar nav a,
.topbar nav .btn-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--r-md);
    color: var(--text-soft);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--t-fast), color var(--t-fast);
}
.topbar nav a:hover,
.topbar nav .btn-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.topbar nav a.active {
    background: var(--grad-brand-soft);
    color: var(--brand-700);
    font-weight: 600;
}

.inline-form { display: inline; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    border-radius: var(--r-md);
    cursor: pointer;
    color: var(--text);
    margin-left: auto;
}
.nav-toggle:hover { background: var(--surface-hover); }
.nav-toggle svg { width: 24px; height: 24px; }

@media (max-width: 840px) {
    .nav-toggle { display: inline-flex; }
    .topbar nav {
        position: absolute;
        top: var(--topbar-h);
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: var(--s-3);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: saturate(180%) blur(18px);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--sh-lg);
        transform: translateY(-8px);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--t), transform var(--t);
    }
    .topbar nav a,
    .topbar nav .btn-link,
    .topbar nav .inline-form { width: 100%; }
    .topbar nav a,
    .topbar nav .btn-link {
        padding: 12px 14px;
        text-align: left;
        width: 100%;
    }
    .topbar.is-open nav {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }
}

/* ============================================================
   Card
   ============================================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    padding: var(--s-6);
    box-shadow: var(--sh-sm);
    margin-bottom: var(--s-5);
    transition: box-shadow var(--t), transform var(--t), border-color var(--t);
}
.card:hover { box-shadow: var(--sh-md); }
.card-flat { box-shadow: none; border: 1px solid var(--border); }
.card-elevated { box-shadow: var(--sh-lg); border-color: transparent; }
.card-accent {
    background: var(--grad-brand);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--sh-brand);
}
.card-accent h1, .card-accent h2, .card-accent h3 { color: #fff; }
.card-accent .muted,
.card-accent .text-muted { color: rgba(255, 255, 255, 0.78); }

/* Ink (dark) hero card — for dashboards, coin balance, challenges */
.card-ink {
    background: var(--grad-ink-brand);
    color: var(--text-on-ink);
    border: 1px solid var(--border-ink);
    border-radius: var(--r-xl);
    padding: var(--s-8);
    box-shadow: var(--sh-xl), var(--sh-inset);
    position: relative;
    overflow: hidden;
}
.card-ink h1, .card-ink h2, .card-ink h3 { color: #fff; }
.card-ink .muted,
.card-ink .text-muted { color: rgba(255, 255, 255, 0.62); }
.card-ink .stat-label { color: rgba(255, 255, 255, 0.55); }
.card-ink .stat-value { color: #fff; }
.card-ink .eyebrow { color: rgba(255, 255, 255, 0.55); }

/* Section-accent card variants (use on sub-heroes) */
.card-sec-workout  { background: var(--sec-workout-grad);  color: #fff; border-color: transparent; box-shadow: var(--sec-workout-glow); }
.card-sec-food     { background: var(--sec-food-grad);     color: #fff; border-color: transparent; box-shadow: var(--sec-food-glow); }
.card-sec-coach    { background: var(--sec-coach-grad);    color: #fff; border-color: transparent; box-shadow: var(--sec-coach-glow); }
.card-sec-duel     { background: var(--sec-duel-grad);     color: #fff; border-color: transparent; box-shadow: var(--sec-duel-glow); }
.card-sec-friends  { background: var(--sec-friends-grad);  color: #fff; border-color: transparent; box-shadow: var(--sec-friends-glow); }
.card-sec-workout h1, .card-sec-workout h2, .card-sec-workout h3,
.card-sec-food h1, .card-sec-food h2, .card-sec-food h3,
.card-sec-coach h1, .card-sec-coach h2, .card-sec-coach h3,
.card-sec-duel h1, .card-sec-duel h2, .card-sec-duel h3,
.card-sec-friends h1, .card-sec-friends h2, .card-sec-friends h3 { color: #fff; }

.card h3 { margin-bottom: var(--s-3); }
.card > *:last-child { margin-bottom: 0; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    min-height: 42px;
    background: var(--grad-brand);
    color: #fff;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: 0.93rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--sh-brand);
    transition: transform var(--t-fast), box-shadow var(--t), filter var(--t-fast), background var(--t);
    white-space: nowrap;
    user-select: none;
}
.btn:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px -8px rgba(67, 56, 202, 0.55);
    filter: brightness(1.08);
}
.btn:active { transform: translateY(0); filter: brightness(0.96); }
.btn:focus-visible {
    outline: 3px solid rgba(79, 70, 229, 0.35);
    outline-offset: 2px;
}
.btn:disabled, .btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--sh-xs);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    box-shadow: var(--sh-xs);
}
.btn-secondary:hover {
    color: var(--text);
    background: var(--surface-hover);
    box-shadow: var(--sh-sm);
    filter: none;
}

.btn-ghost {
    background: transparent;
    color: var(--brand-600);
    border: 1px solid rgba(79, 70, 229, 0.3);
    box-shadow: none;
}
.btn-ghost:hover {
    background: var(--grad-brand-soft);
    color: var(--brand-700);
    filter: none;
    box-shadow: none;
}

.btn-ink {
    background: var(--grad-ink);
    color: #fff;
    border: 1px solid var(--border-ink);
    box-shadow: var(--sh-md), var(--sh-inset);
}
.btn-ink:hover {
    background: var(--grad-ink-brand);
    color: #fff;
    box-shadow: var(--sh-lg), var(--sh-inset);
    filter: none;
}

.btn-danger {
    background: var(--danger);
    box-shadow: 0 6px 16px -6px rgba(220, 38, 38, 0.5);
}
.btn-danger:hover {
    box-shadow: 0 10px 20px -6px rgba(220, 38, 38, 0.55);
}

.btn-success {
    background: var(--sec-food-grad);
    box-shadow: var(--sec-food-glow);
}
.btn-success:hover {
    box-shadow: 0 14px 28px -10px rgba(4, 120, 87, 0.6);
}

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; border-radius: 8px; }
.btn-lg { min-height: 52px; padding: 14px 26px; font-size: 1.02rem; border-radius: 12px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: 10px; min-width: 42px; }
.btn-icon.btn-sm { padding: 6px; min-width: 34px; }

/* ============================================================
   Forms
   ============================================================ */

label {
    display: block;
    margin-top: var(--s-4);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-soft);
}
label:first-child { margin-top: 0; }

input, select, textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    margin-top: 6px;
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover, select:hover, textarea:hover { border-color: var(--brand-400); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}
input[type="checkbox"], input[type="radio"] {
    width: auto;
    margin: 0 8px 0 0;
    accent-color: var(--brand-500);
    vertical-align: middle;
}
textarea { min-height: 96px; resize: vertical; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-4);
}
@media (max-width: 560px) {
    .form-row { grid-template-columns: 1fr; }
}

.error {
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid rgba(220, 38, 38, 0.25);
    padding: 10px 12px;
    border-radius: var(--r-md);
    font-size: 0.9rem;
    margin-top: var(--s-3);
}

/* ============================================================
   Tables
   ============================================================ */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
}
table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
table th:first-child { border-top-left-radius: 10px; }
table th:last-child { border-top-right-radius: 10px; }
table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text);
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--surface-2); }

/* ============================================================
   Utilities
   ============================================================ */

.flex { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.flex-col { display: flex; flex-direction: column; gap: var(--s-3); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }

.grid {
    display: grid;
    gap: var(--s-5);
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.grid-2 { display: grid; gap: var(--s-5); grid-template-columns: repeat(2, 1fr); }
.grid-3 { display: grid; gap: var(--s-5); grid-template-columns: repeat(3, 1fr); }
.grid-4 { display: grid; gap: var(--s-4); grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.muted { color: var(--text-muted); font-size: 0.88rem; }
.faint { color: var(--text-faint); }
.text-center { text-align: center; }
.text-gradient {
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }

.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); } .mt-8 { margin-top: var(--s-8); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); } .mb-6 { margin-bottom: var(--s-6); }

/* ============================================================
   Badge / Chip
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    background: var(--surface-hover);
    color: var(--text-soft);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: 1px solid var(--border);
}
.badge-green { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-red   { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-blue  { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-yellow{ background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-brand { background: var(--grad-brand-soft); color: var(--brand-700); border-color: transparent; }
.badge-workout { background: var(--sec-workout-soft); color: var(--sec-workout-600); border-color: transparent; }
.badge-food    { background: var(--sec-food-soft);    color: var(--sec-food-600);    border-color: transparent; }
.badge-coach   { background: var(--sec-coach-soft);   color: var(--sec-coach-600);   border-color: transparent; }
.badge-duel    { background: var(--sec-duel-soft);    color: var(--sec-duel-600);    border-color: transparent; }
.badge-friends { background: var(--sec-friends-soft); color: var(--sec-friends-600); border-color: transparent; }
.badge-rarity-bronze { background: var(--rarity-bronze); color: #fff; border-color: transparent; }
.badge-rarity-silver { background: var(--rarity-silver); color: #0b0f1a; border-color: transparent; }
.badge-rarity-gold   { background: var(--rarity-gold);   color: #0b0f1a; border-color: transparent; }
.badge-rarity-legend { background: var(--rarity-legend); color: #fff; border-color: transparent; }

/* Topbar chips — streak / coins */
.top-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: var(--r-md);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}
.top-chip--streak { background: #fff; color: var(--text); border: 1px solid var(--border); }
.top-chip--streak strong { color: var(--sec-duel); font-weight: 700; }
.top-chip--coins  { background: var(--surface-ink); color: #fbbf24; border: 1px solid var(--surface-ink); }

/* ============================================================
   Stat / Metric
   ============================================================ */

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-display);
    letter-spacing: -0.04em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-value.gradient {
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}
.stat-unit { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }

/* ============================================================
   Progress
   ============================================================ */

.progress {
    width: 100%;
    height: 8px;
    background: var(--bg-subtle);
    border-radius: var(--r-full);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--grad-brand);
    border-radius: var(--r-full);
    transition: width var(--t-slow);
}
.progress-bar.accent { background: var(--sec-food-grad); }
.progress-bar.sunset { background: var(--sec-duel-grad); }
.progress-bar.workout { background: var(--sec-workout-grad); }
.progress-bar.coach   { background: var(--sec-coach-grad); }
.progress-bar.friends { background: var(--sec-friends-grad); }

/* ============================================================
   Hero / Landing
   ============================================================ */

.hero {
    position: relative;
    padding: clamp(48px, 8vw, 96px) 0 clamp(40px, 6vw, 72px);
    overflow: hidden;
    isolation: isolate;
}
.hero::before {
    content: "";
    position: absolute;
    inset: -20% -10% auto auto;
    width: 620px;
    height: 620px;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.18), transparent 65%);
    filter: blur(40px);
    z-index: -1;
}
.hero::after {
    content: "";
    position: absolute;
    inset: auto auto -30% -15%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(109, 40, 217, 0.12), transparent 65%);
    filter: blur(40px);
    z-index: -1;
}
.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--r-full);
    background: var(--grad-brand-soft);
    color: var(--brand-700);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: var(--s-5);
    border: 1px solid rgba(79, 70, 229, 0.25);
}
.hero h1 {
    font-size: clamp(2.4rem, 5vw + 0.8rem, 4rem);
    font-weight: 700;
    letter-spacing: -0.045em;
    line-height: 1.05;
    margin-bottom: var(--s-5);
    max-width: 18ch;
}
.hero-lead {
    font-size: clamp(1rem, 0.4vw + 0.95rem, 1.2rem);
    color: var(--text-soft);
    max-width: 58ch;
    margin-bottom: var(--s-8);
}
.hero-cta { display: flex; gap: var(--s-3); flex-wrap: wrap; }

/* Features grid on landing */
.features {
    display: grid;
    gap: var(--s-5);
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-top: var(--s-10);
}
.feature {
    padding: var(--s-6);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.feature:hover {
    transform: translateY(-4px);
    box-shadow: var(--sh-lg);
    border-color: transparent;
}
.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--grad-brand-soft);
    color: var(--brand-600);
    border: 1px solid rgba(79, 70, 229, 0.15);
    margin-bottom: var(--s-4);
}
.feature-icon svg { width: 22px; height: 22px; }
.feature h3 { margin-bottom: 6px; font-size: 1.05rem; }
.feature p { color: var(--text-muted); font-size: 0.92rem; margin: 0; }

/* ============================================================
   Page header
   ============================================================ */

.page-header {
    margin-bottom: var(--s-8);
}
.page-header h1 { margin-bottom: var(--s-2); }
.page-header p { color: var(--text-muted); margin: 0; }

/* ============================================================
   Auth card
   ============================================================ */

.auth-shell {
    min-height: calc(100vh - var(--topbar-h) - 40px);
    display: grid;
    place-items: center;
    padding: var(--s-8) var(--s-4);
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-xl);
    padding: clamp(28px, 4vw, 40px);
    box-shadow: var(--sh-lg);
}
.auth-card h1 {
    font-size: 1.75rem;
    margin-bottom: var(--s-2);
}
.auth-card .muted { margin-bottom: var(--s-5); }

/* ============================================================
   Chat / Coach
   ============================================================ */

.chat-container {
    display: flex;
    flex-direction: column;
    height: min(70vh, 640px);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--sh-sm);
}
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--s-6);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    scroll-behavior: smooth;
}
.chat-empty {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    max-width: 40ch;
}
.chat-empty h3 { color: var(--text); margin-bottom: 6px; }
.msg {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    animation: msg-in 200ms ease-out;
}
@keyframes msg-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}
.msg-user {
    align-self: flex-end;
    background: var(--grad-brand);
    color: #fff;
    border-bottom-right-radius: 6px;
}
.msg-bot {
    align-self: flex-start;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border-soft);
    border-bottom-left-radius: 6px;
}
.msg-error {
    align-self: flex-start;
    background: var(--danger-soft);
    color: #991b1b;
    border-bottom-left-radius: 6px;
}
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-faint);
    animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}
.chat-input {
    display: flex;
    gap: var(--s-2);
    padding: var(--s-4);
    border-top: 1px solid var(--border-soft);
    background: var(--surface-2);
}
.chat-input input {
    flex: 1;
    margin-top: 0;
    border-radius: var(--r-full);
    padding: 12px 18px;
}
.chat-input .btn {
    border-radius: var(--r-full);
    padding: 12px 22px;
}

/* ============================================================
   Action tiles
   ============================================================ */

.actions {
    display: grid;
    gap: var(--s-4);
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.action-tile {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-5);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    color: var(--text);
    text-decoration: none;
    transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.action-tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--sh-md);
    color: var(--text);
    border-color: var(--brand-400);
}
.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--grad-brand-soft);
    color: var(--brand-600);
    flex-shrink: 0;
}
.action-icon svg { width: 20px; height: 20px; }
.action-title { font-weight: 600; font-size: 0.95rem; color: var(--text); line-height: 1.2; }
.action-sub   { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   List row (entries, friends, txs)
   ============================================================ */

.row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) 0;
    border-bottom: 1px solid var(--border-soft);
}
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; color: var(--text); }
.row-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.row-right { font-weight: 600; }

/* Empty state */
.empty {
    padding: var(--s-8) var(--s-4);
    text-align: center;
    color: var(--text-muted);
}
.empty svg { width: 48px; height: 48px; margin-bottom: var(--s-3); opacity: 0.5; }

/* ============================================================
   Coin balance feature
   ============================================================ */

.coin-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-5);
    padding: var(--s-8);
    background: var(--grad-ink-brand);
    color: var(--text-on-ink);
    border: 1px solid var(--border-ink);
    border-radius: var(--r-xl);
    margin-bottom: var(--s-6);
    box-shadow: var(--sh-xl), var(--sh-inset);
    position: relative;
    overflow: hidden;
}
.coin-hero::before {
    content: "";
    position: absolute;
    inset: auto -20% -60% auto;
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.16), transparent 60%);
    filter: blur(30px);
    pointer-events: none;
}
.coin-hero > * { position: relative; z-index: 1; }
.coin-hero .stat-label { color: rgba(255, 255, 255, 0.55); }
.coin-hero .stat-value { color: #fbbf24; font-size: clamp(2.4rem, 5vw, 3.2rem); }
.coin-symbol {
    width: 80px; height: 80px;
    border-radius: var(--r-lg);
    background: var(--sec-duel-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: var(--sec-duel-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
.fade-in { animation: fade-in 320ms ease-out; }

@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--brand-500);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    display: inline-block;
}

/* ============================================================
   Skeleton loader
   ============================================================ */

.skel {
    display: block;
    background: linear-gradient(90deg, var(--bg-subtle) 0%, var(--surface-hover) 50%, var(--bg-subtle) 100%);
    background-size: 200% 100%;
    animation: skel 1.4s infinite;
    border-radius: 8px;
    height: 14px;
}
@keyframes skel {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
    margin-top: var(--s-16);
    padding: var(--s-8) var(--s-5);
    border-top: 1px solid var(--border-soft);
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* ============================================================
   Scrollbar
   ============================================================ */

/* ============================================================
   v3 — Shell (sidebar + topbar), SectionLabel, accent cards
   ============================================================ */

/* Sidebar shell — replaces topbar-only layout */
.app-shell { display: flex; min-height: 100vh; }
.app-main  { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: clamp(20px, 2.6vw, 32px) clamp(20px, 3vw, 36px); }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    padding: 20px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 50;
}
.sidebar .sb-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 18px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.03em;
    color: var(--text);
    text-decoration: none;
}
.sidebar .sb-brand::before {
    content: "F";
    width: 30px; height: 30px;
    border-radius: 8px;
    background: var(--grad-ink-brand);
    display: grid; place-items: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    box-shadow: var(--sh-md), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.sidebar .sb-brand .sb-brand-accent { color: var(--brand-500); margin-left: -3px; }

.sidebar .sb-label {
    padding: 0 10px 8px;
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.sidebar a.sb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-soft);
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    position: relative;
    transition: all var(--t-fast);
}
.sidebar a.sb-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar a.sb-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar a.sb-item.is-active {
    font-weight: 600;
    color: var(--brand-700);
    background: var(--grad-brand-soft);
}
.sidebar a.sb-item.is-active.sec-food    { color: var(--sec-food-600);    background: var(--sec-food-soft); }
.sidebar a.sb-item.is-active.sec-workout { color: var(--sec-workout-600); background: var(--sec-workout-soft); }
.sidebar a.sb-item.is-active.sec-coach   { color: var(--sec-coach-600);   background: var(--sec-coach-soft); }
.sidebar a.sb-item.is-active.sec-duel    { color: var(--sec-duel-600);    background: var(--sec-duel-soft); }
.sidebar a.sb-item.is-active.sec-friends { color: var(--sec-friends-600); background: var(--sec-friends-soft); }
.sidebar a.sb-item.is-active::before {
    content: "";
    position: absolute;
    left: -12px; top: 7px; bottom: 7px; width: 3px;
    border-radius: 0 2px 2px 0;
    background: currentColor;
}
.sidebar .sb-user {
    margin-top: auto;
    padding: 14px 10px 4px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
}
.sidebar .sb-user-av {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--grad-ink-brand);
    display: grid; place-items: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    border: 1px solid var(--border-ink);
}
.sidebar .sb-user-name { font-weight: 700; font-size: 0.85rem; letter-spacing: -0.01em; }
.sidebar .sb-user-meta { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); letter-spacing: -0.01em; }

/* App topbar (inside main area, not full-width) */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 clamp(20px, 3vw, 36px);
    background: rgba(246, 247, 250, 0.88);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.app-topbar .search {
    flex: 1;
    max-width: 440px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.88rem;
    color: var(--text-muted);
    box-shadow: var(--sh-xs);
}
.app-topbar .search .kbd {
    padding: 2px 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-soft);
    font-weight: 600;
}
.app-topbar .top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.app-topbar .top-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    display: grid; place-items: center;
    cursor: pointer;
    color: var(--text-soft);
    transition: all var(--t-fast);
}
.app-topbar .top-btn:hover { border-color: var(--border-strong); color: var(--text); }
.app-topbar .top-btn svg { width: 16px; height: 16px; }

/* Mobile sidebar drawer */
.sb-toggle { display: none; }
@media (max-width: 980px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        transform: translateX(-100%);
        transition: transform var(--t);
        box-shadow: var(--sh-xl);
    }
    .app-shell.sb-open .sidebar { transform: none; }
    .sb-toggle {
        display: grid;
        place-items: center;
        width: 40px; height: 40px;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: #fff;
        cursor: pointer;
        color: var(--text);
    }
    .sb-toggle svg { width: 18px; height: 18px; }
    .app-shell.sb-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(11, 15, 26, 0.4);
        z-index: 45;
    }
}

/* SectionLabel — dot + UPPERCASE + optional mono */
.sec-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.sec-label::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 2px;
    background: currentColor;
}
.sec-label .mono {
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
    opacity: 0.7;
}
.sec-label.workout { color: var(--sec-workout); }
.sec-label.food    { color: var(--sec-food); }
.sec-label.coach   { color: var(--sec-coach); }
.sec-label.duel    { color: var(--sec-duel-600); }
.sec-label.friends { color: var(--sec-friends); }
.sec-label.brand   { color: var(--brand-600); }
.sec-label.amber   { color: #b45309; }

/* Accent-bar card — white card with 3px gradient stripe on top */
.acard {
    position: relative;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 22px;
    box-shadow: var(--sh-xs);
    overflow: hidden;
}
.acard > .stripe {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--grad-brand);
}
.acard.workout > .stripe  { background: var(--sec-workout-grad); }
.acard.food    > .stripe  { background: var(--sec-food-grad); }
.acard.coach   > .stripe  { background: var(--sec-coach-grad); }
.acard.duel    > .stripe  { background: linear-gradient(90deg, #fbbf24, #b45309); }
.acard.friends > .stripe  { background: var(--sec-friends-grad); }
.acard.amber-tint {
    background: linear-gradient(165deg, #fffbeb 0%, #ffffff 50%, #fef3c7 100%);
}
.acard.emerald-tint {
    background: linear-gradient(165deg, #ecfdf5 0%, #ffffff 55%, #f0fdfa 100%);
}
.acard.rose-tint {
    background: linear-gradient(165deg, #fff7ed 0%, #ffffff 60%, #fef3c7 100%);
}

/* Page header v3 */
.ph {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}
.ph h1 {
    margin: 12px 0 4px;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 2.5vw + 0.8rem, 2.3rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.05;
}
.ph p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

/* Display digit / mono digit */
.d-num {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.d-num.xl { font-size: clamp(2.6rem, 5vw, 4rem); }
.d-num.lg { font-size: clamp(2rem, 3.5vw, 2.6rem); }
.d-num.md { font-size: clamp(1.3rem, 2vw, 1.5rem); }
.m-num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    font-weight: 700;
}

/* KPI stripe (grid of 3-4 mini-cards with accent-bar) */
.kpi-grid { display: grid; gap: 14px; }
.kpi-grid.cols-3 { grid-template-columns: 1.4fr 1fr 1fr; }
.kpi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
    .kpi-grid.cols-3, .kpi-grid.cols-4 { grid-template-columns: 1fr; }
}

/* Split layouts */
.split-1-2  { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }
.split-3-2  { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.split-3-2-c{ display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
@media (max-width: 900px) {
    .split-1-2, .split-3-2, .split-3-2-c { grid-template-columns: 1fr; }
}

/* Segmented v3 (compact, mono label) */
.seg-v3 {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.seg-v3 button, .seg-v3 a {
    appearance: none;
    border: none;
    background: transparent;
    padding: 5px 12px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--t-fast);
}
.seg-v3 button:hover, .seg-v3 a:hover { color: var(--text); }
.seg-v3 button.is-active, .seg-v3 a.is-active {
    background: #fff;
    color: var(--text);
    box-shadow: var(--sh-xs);
}

/* Action list (sidebar rail, friends list, etc.) */
.a-list > * + * { border-top: 1px solid var(--border-soft); }
.a-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}
.a-row .a-ic {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: grid; place-items: center;
    font-size: 15px;
    flex-shrink: 0;
}

/* Mono tag (right-aligned number chip for list rows) */
.mtag {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: -0.01em;
    color: var(--text);
}
.mtag.success { color: var(--success); }
.mtag.danger  { color: var(--danger); }
.mtag.muted   { color: var(--text-muted); }
.mtag.duel    { color: var(--sec-duel-600); }

/* Rarity legend dot */
.r-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
}
.r-legend::before {
    content: "";
    width: 8px; height: 8px;
    border-radius: 2px;
    background: var(--bg-subtle);
}
.r-legend.bronze::before { background: var(--rarity-bronze); }
.r-legend.silver::before { background: var(--rarity-silver); }
.r-legend.gold::before   { background: var(--rarity-gold); }
.r-legend.legend::before { background: var(--rarity-legend); }

/* Medal (achievements) */
.medal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--sh-xs);
    position: relative;
    overflow: hidden;
}
.medal.locked { background: var(--surface-2); box-shadow: none; opacity: 0.7; }
.medal .disc {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 22px;
    box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.35), 0 2px 6px -1px rgba(11, 15, 26, 0.2);
}
.medal.bronze .disc { background: var(--rarity-bronze); box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.35), 0 2px 6px -1px rgba(11, 15, 26, 0.2), 0 0 0 2px #92400e; }
.medal.silver .disc { background: var(--rarity-silver); box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.35), 0 2px 6px -1px rgba(11, 15, 26, 0.2), 0 0 0 2px #64748b; }
.medal.gold   .disc { background: var(--rarity-gold);   box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.35), 0 2px 6px -1px rgba(11, 15, 26, 0.2), 0 0 0 2px #b45309; }
.medal.legend .disc { background: var(--rarity-legend); box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.35), 0 2px 6px -1px rgba(11, 15, 26, 0.2), 0 0 0 2px #4338ca; }
.medal.locked .disc { filter: grayscale(1); opacity: 0.4; }
.medal .m-label {
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
    font-family: var(--font-display);
    color: var(--text);
}
.medal.locked .m-label { color: var(--text-muted); }
.medal .m-sub {
    font-size: 10px;
    color: var(--text-faint);
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
}

/* Avatar and stack */
.av {
    border-radius: 50%;
    display: grid; place-items: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    background: var(--grad-brand);
}
.av.sm { width: 30px; height: 30px; font-size: 11px; }
.av.md { width: 36px; height: 36px; font-size: 13px; }
.av.lg { width: 40px; height: 40px; font-size: 15px; }
.av.xl { width: 72px; height: 72px; font-size: 28px; }
.av.workout { background: var(--sec-workout-grad); }
.av.food    { background: var(--sec-food-grad); }
.av.coach   { background: var(--sec-coach-grad); }
.av.duel    { background: var(--sec-duel-grad); }
.av.friends { background: var(--sec-friends-grad); }
.av.ink     { background: var(--grad-ink-brand); border: 1px solid var(--border-ink); }
.av-stack { display: inline-flex; }
.av-stack .av { margin-left: -10px; border: 2px solid #fff; }
.av-stack .av:first-child { margin-left: 0; }

/* Meal tabs (nutrition) */
.meal-tabs {
    display: flex;
    padding: 4px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    gap: 2px;
}
.meal-tabs button, .meal-tabs a {
    flex: 1;
    padding: 12px 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    text-align: left;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: all var(--t-fast);
    display: flex; flex-direction: column; gap: 4px;
    text-decoration: none;
}
.meal-tabs button:hover, .meal-tabs a:hover { color: var(--text); }
.meal-tabs .mt-kcal { font-size: 11px; font-weight: 700; color: var(--text-faint); font-family: var(--font-mono); letter-spacing: -0.01em; }
.meal-tabs .is-active {
    background: #fff;
    color: var(--text);
    box-shadow: var(--sh-xs);
}
.meal-tabs .is-active .mt-kcal { color: var(--sec-food); }

/* Food row (diary) */
.f-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-soft);
}
.f-row:last-child { border-bottom: none; }
.f-row .f-ic {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--sec-food-soft);
    display: grid; place-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12px;
    color: var(--sec-food-600);
    border: 1px solid rgba(5, 150, 105, 0.15);
    flex-shrink: 0;
}
.f-row .f-main { flex: 1; min-width: 0; }
.f-row .f-name { font-weight: 600; font-size: 0.95rem; letter-spacing: -0.01em; }
.f-row .f-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
    display: flex; gap: 12px;
    letter-spacing: -0.01em;
}
.f-row .f-kcal {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--text);
}
.f-row .f-kcal .unit { font-size: 10px; color: var(--text-faint); font-weight: 500; margin-left: 4px; letter-spacing: 0.02em; }
.f-row .f-del {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border);
    display: grid; place-items: center;
    color: var(--text-muted);
    cursor: pointer;
}

/* Chat shell v3 */
.chat-v3 {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    box-shadow: var(--sh-sm);
    overflow: hidden;
    min-height: 540px;
    max-height: calc(100vh - 180px);
}
.chat-v3 .ch-head {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; gap: 12px;
}
.chat-v3 .ch-ic {
    width: 44px; height: 44px;
    border-radius: 14px;
    background: var(--sec-coach-grad);
    display: grid; place-items: center;
    color: #fff;
    box-shadow: var(--sec-coach-glow);
}
.chat-v3 .ch-live {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    display: inline-block;
    margin-left: 8px;
}
.chat-v3 .ch-body {
    flex: 1;
    padding: 22px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: linear-gradient(180deg, #fafafb 0%, #fff 100%);
}
.chat-v3 .msg-row { display: flex; gap: 12px; align-items: flex-start; }
.chat-v3 .msg-row.user { flex-direction: row-reverse; }
.chat-v3 .msg-av {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.chat-v3 .msg-row.bot  .msg-av { background: var(--sec-coach-grad); }
.chat-v3 .msg-row.user .msg-av { background: var(--sec-duel-grad); }
.chat-v3 .bubble {
    max-width: 460px;
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 0.94rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-v3 .msg-row.bot .bubble {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border-soft);
    box-shadow: var(--sh-xs);
}
.chat-v3 .msg-row.user .bubble {
    background: var(--sec-coach-grad);
    color: #fff;
    border: none;
    box-shadow: var(--sec-coach-glow);
}
.chat-v3 .msg-row.error .bubble {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.25);
}
.chat-v3 .ch-input {
    padding: 14px 22px 20px;
    border-top: 1px solid var(--border-soft);
}
.chat-v3 .ch-suggest { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chat-v3 .ch-suggest button {
    padding: 6px 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    cursor: pointer;
    font-family: inherit;
}
.chat-v3 .ch-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 16px;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    box-shadow: var(--sh-xs);
}
.chat-v3 .ch-input-bar input {
    flex: 1;
    border: none;
    outline: none;
    margin: 0;
    padding: 0;
    background: transparent;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    box-shadow: none;
}
.chat-v3 .ch-input-bar input:focus { box-shadow: none; }
.chat-v3 .ch-send {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--sec-coach-grad);
    color: #fff;
    border: none;
    display: grid; place-items: center;
    cursor: pointer;
    box-shadow: var(--sec-coach-glow);
}

/* ============================================================
   v2 — Metric tile / section header / segmented / ghost row
   ============================================================ */

.metric-tile {
    padding: var(--s-5);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    transition: box-shadow var(--t), transform var(--t), border-color var(--t);
}
.metric-tile:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.metric-tile.ink { background: var(--grad-ink-brand); color: var(--text-on-ink); border-color: var(--border-ink); box-shadow: var(--sh-lg), var(--sh-inset); }
.metric-tile.ink .stat-label { color: rgba(255, 255, 255, 0.55); }
.metric-tile.ink .stat-value { color: #fff; }
.metric-tile.accent-workout { border-top: 3px solid var(--sec-workout); }
.metric-tile.accent-food    { border-top: 3px solid var(--sec-food); }
.metric-tile.accent-coach   { border-top: 3px solid var(--sec-coach); }
.metric-tile.accent-duel    { border-top: 3px solid var(--sec-duel); }
.metric-tile.accent-friends { border-top: 3px solid var(--sec-friends); }
.metric-tile .metric-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
    font-family: var(--font-display);
    font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--text-muted);
}
.metric-tile .metric-head .icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: var(--surface-2);
    color: var(--text-soft);
    border: 1px solid var(--border-soft);
}
.metric-tile.ink .metric-head { color: rgba(255, 255, 255, 0.55); }
.metric-tile.ink .metric-head .icon { background: rgba(255,255,255,0.06); color: #fff; border-color: var(--border-ink); }

.section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: var(--s-3); flex-wrap: wrap;
    margin: var(--s-10) 0 var(--s-5);
}
.section-head:first-child { margin-top: 0; }
.section-head h2 { margin: 0; }
.section-head .sub { color: var(--text-muted); font-size: 0.9rem; margin: 0; }
.section-head .link { font-size: 0.88rem; font-weight: 600; color: var(--brand-600); }
.section-head .link:hover { color: var(--brand-700); }

.segmented {
    display: inline-flex;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    gap: 2px;
}
.segmented button, .segmented a {
    appearance: none;
    background: transparent;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--t-fast);
}
.segmented button:hover, .segmented a:hover { color: var(--text); }
.segmented button.active, .segmented a.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--sh-xs);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--r-full);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-soft);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--t-fast);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--grad-brand-soft); border-color: rgba(79, 70, 229, 0.3); color: var(--brand-700); font-weight: 600; }

/* Diary / list row — with left icon, rich subtitle, right meta */
.d-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-4);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    margin-bottom: var(--s-2);
    transition: box-shadow var(--t-fast), border-color var(--t-fast);
}
.d-row:hover { box-shadow: var(--sh-sm); border-color: var(--border); }
.d-row .d-icon {
    width: 38px; height: 38px; border-radius: 8px;
    display: grid; place-items: center;
    background: var(--surface-2);
    color: var(--text-soft);
    border: 1px solid var(--border-soft);
    flex-shrink: 0;
}
.d-row.workout .d-icon { background: var(--sec-workout-soft); color: var(--sec-workout-600); border-color: transparent; }
.d-row.food    .d-icon { background: var(--sec-food-soft);    color: var(--sec-food-600);    border-color: transparent; }
.d-row.coach   .d-icon { background: var(--sec-coach-soft);   color: var(--sec-coach-600);   border-color: transparent; }
.d-row.duel    .d-icon { background: var(--sec-duel-soft);    color: var(--sec-duel-600);    border-color: transparent; }
.d-row.friends .d-icon { background: var(--sec-friends-soft); color: var(--sec-friends-600); border-color: transparent; }
.d-row .d-main { flex: 1; min-width: 0; }
.d-row .d-title { font-weight: 600; color: var(--text); font-size: 0.95rem; }
.d-row .d-sub   { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); letter-spacing: -0.01em; }
.d-row .d-right { font-weight: 700; font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text); }

/* Coin chip (inline "+15 ◆" etc.) */
.coin-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--r-full);
    background: var(--sec-duel-soft);
    color: var(--sec-duel-600);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.coin-chip.neg { background: var(--danger-soft); color: var(--danger); }

/* Action tile — section-accent variants */
.action-tile.workout .action-icon { background: var(--sec-workout-soft); color: var(--sec-workout-600); }
.action-tile.food    .action-icon { background: var(--sec-food-soft);    color: var(--sec-food-600); }
.action-tile.coach   .action-icon { background: var(--sec-coach-soft);   color: var(--sec-coach-600); }
.action-tile.duel    .action-icon { background: var(--sec-duel-soft);    color: var(--sec-duel-600); }
.action-tile.friends .action-icon { background: var(--sec-friends-soft); color: var(--sec-friends-600); }
.action-tile:hover { border-color: var(--border-strong); }
.action-tile.workout:hover { border-color: var(--sec-workout); }
.action-tile.food:hover    { border-color: var(--sec-food); }
.action-tile.coach:hover   { border-color: var(--sec-coach); }
.action-tile.duel:hover    { border-color: var(--sec-duel); }
.action-tile.friends:hover { border-color: var(--sec-friends); }

/* Weekly streak grid */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-grid .day {
    text-align: center;
}
.week-grid .day-label {
    font-family: var(--font-display);
    font-size: 10px; font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.week-grid .day-box {
    height: 38px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: var(--bg-subtle);
    color: var(--text-faint);
    font-size: 12px; font-weight: 700;
}
.week-grid .day-box.done {
    background: var(--grad-brand);
    color: #fff;
    box-shadow: 0 4px 10px -4px rgba(67, 56, 202, 0.45);
}
.week-grid .day-box.rest {
    background: var(--surface-2);
    border: 1px dashed var(--border);
    color: var(--text-faint);
}

/* Rarity medal (for challenges / achievements) */
.rarity-medal {
    display: inline-grid;
    place-items: center;
    width: 56px; height: 56px;
    border-radius: var(--r-lg);
    color: #fff;
    font-weight: 800;
    font-family: var(--font-display);
    box-shadow: var(--sh-md), inset 0 1px 0 rgba(255,255,255,0.2);
}
.rarity-medal.bronze { background: var(--rarity-bronze); }
.rarity-medal.silver { background: var(--rarity-silver); color: #0b0f1a; }
.rarity-medal.gold   { background: var(--rarity-gold); color: #0b0f1a; }
.rarity-medal.legend { background: var(--rarity-legend); }

/* Stat — variant with mono-numeric */
.stat-value.mono { font-family: var(--font-mono); font-weight: 700; }

@media (pointer: fine) {
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb {
        background: var(--border-strong);
        border-radius: 10px;
        border: 2px solid var(--bg);
    }
    ::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
}
