/* =========================================================================
   NutriGym · sistema visual
   ========================================================================= */
:root {
    --bg:            #07090d;
    --bg-soft:       #0b0f16;
    --surface:       rgba(255, 255, 255, .034);
    --surface-2:     rgba(255, 255, 255, .06);
    --line:          rgba(255, 255, 255, .09);
    --line-strong:   rgba(255, 255, 255, .16);

    --text:          #e8ecf3;
    --text-dim:      #97a1b4;
    --text-faint:    #6b7488;

    --accent:        #4ade80;
    --accent-2:      #22d3ee;
    --accent-warm:   #ff6b4a;
    --danger:        #f87171;

    --radius:        16px;
    --radius-sm:     10px;
    --shadow:        0 18px 48px rgba(0, 0, 0, .45);
    --ring:          0 0 0 1px var(--line);

    --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --display: 'Space Grotesk', var(--sans);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
img, svg, video, canvas { max-width: 100%; }

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

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    background-image:
        radial-gradient(880px 520px at 8% -10%, rgba(74, 222, 128, .10), transparent 60%),
        radial-gradient(760px 520px at 100% 0%, rgba(34, 211, 238, .09), transparent 55%),
        radial-gradient(700px 640px at 60% 110%, rgba(255, 107, 74, .07), transparent 60%);
    background-attachment: fixed;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.015em; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
ul { list-style: none; }
.muted { color: var(--text-dim); font-size: .82rem; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- estructura */
.app {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
}

/* --------------------------------------------------------------- sidebar */
.rail {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1.6rem 1rem;
    border-right: 1px solid var(--line);
    background: rgba(7, 9, 13, .72);
    backdrop-filter: blur(14px);
    z-index: 30;
}

.rail__brand { display: flex; align-items: center; gap: .7rem; padding: 0 .5rem; }

.rail__logo {
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    border-radius: 12px;
    font-family: var(--display);
    font-weight: 700;
    font-size: .92rem;
    color: #06110b;
    background: linear-gradient(140deg, var(--accent), var(--accent-2));
    box-shadow: 0 8px 22px rgba(74, 222, 128, .28);
}

.rail__word { font-family: var(--display); font-weight: 600; font-size: 1.06rem; letter-spacing: -.02em; }

.rail__nav { display: flex; flex-direction: column; gap: .25rem; }

.rail__link {
    display: flex;
    align-items: center;
    gap: .8rem;
    width: 100%;
    padding: .68rem .75rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    font-size: .92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .18s, color .18s, transform .18s;
}
.rail__link svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
.rail__link:hover { background: var(--surface); color: var(--text); }
.rail__link.is-active {
    background: linear-gradient(100deg, rgba(74, 222, 128, .16), rgba(34, 211, 238, .07));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(74, 222, 128, .22);
}

.rail__foot { margin-top: auto; }

.streak {
    display: flex; flex-direction: column;
    padding: .9rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--ring);
}
.streak strong { font-family: var(--display); font-size: 1.7rem; line-height: 1; color: var(--accent); }
.streak span { font-size: .74rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; margin-top: .3rem; }

/* ---------------------------------------------------------------- topbar */
.main { min-width: 0; padding: 1.6rem 2rem 3rem; }
/* en pantallas muy anchas el contenido se centra en vez de estirarse */
.topbar, .view { max-width: 1560px; margin-inline: auto; }

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.6rem;
}
.topbar__title { font-size: clamp(1.2rem, .95rem + 1.1vw, 1.6rem); }
.topbar__sub { color: var(--text-dim); font-size: .88rem; }
.topbar__actions { display: flex; align-items: center; gap: .6rem; }

.pill {
    padding: .38rem .8rem;
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--ring);
    font-size: .78rem;
    color: var(--text-dim);
    text-transform: capitalize;
}

/* --------------------------------------------------------------- botones */
.btn {
    border: 0;
    border-radius: var(--radius-sm);
    padding: .62rem 1.05rem;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s, box-shadow .2s, background .2s, opacity .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }

.btn--primary {
    color: #05130b;
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    box-shadow: 0 10px 26px rgba(74, 222, 128, .22);
}
.btn--primary:hover:not(:disabled) { box-shadow: 0 14px 32px rgba(74, 222, 128, .32); }

.btn--ghost { background: var(--surface); color: var(--text); box-shadow: var(--ring); }
.btn--ghost:hover { background: var(--surface-2); }

.btn--block { width: 100%; }

/* ---------------------------------------------------------------- vistas */
.view { display: none; animation: fade .35s ease both; }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
    position: relative;
    padding: 1.25rem;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--ring), 0 12px 30px rgba(0, 0, 0, .22);
    backdrop-filter: blur(10px);
}
.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.card__head h2 { font-size: 1.02rem; }
.card--accent {
    background: linear-gradient(150deg, rgba(74, 222, 128, .13), rgba(34, 211, 238, .05));
    box-shadow: inset 0 0 0 1px rgba(74, 222, 128, .2);
}
.card--accent h2 { margin-bottom: .3rem; }
.card--accent .btn { margin-top: 1rem; }

.stack { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }

/* ------------------------------------------------------------------- KPI */
.grid-kpi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 1.1rem;
    margin-bottom: 1.1rem;
}
.kpi { display: flex; flex-direction: column; gap: .45rem; overflow: hidden; }
.kpi::after {
    content: '';
    position: absolute; inset: -40% 55% 40% -10%;
    background: radial-gradient(circle, color-mix(in srgb, var(--kpi) 22%, transparent), transparent 70%);
    pointer-events: none;
}
.kpi__label { font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-faint); }
.kpi__value { font-family: var(--display); font-size: clamp(1.55rem, 1.25rem + 1.3vw, 2rem); line-height: 1; color: #fff; }
.kpi__value small { font-size: .82rem; font-weight: 500; color: var(--text-dim); margin-left: .25rem; }
.kpi__bar { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.kpi__bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--kpi); transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.kpi__hint { font-size: .75rem; color: var(--text-faint); }

.grid-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .95fr); gap: 1.1rem; }

/* ---------------------------------------------------------------- charts */
.seg { display: flex; gap: .2rem; padding: .22rem; border-radius: 999px; background: rgba(255, 255, 255, .05); }
.seg button {
    border: 0; background: transparent; color: var(--text-dim);
    padding: .34rem .75rem; border-radius: 999px;
    font-size: .78rem; font-weight: 500; cursor: pointer; transition: .18s;
}
.seg button:hover { color: var(--text); }
.seg button.is-active { background: var(--surface-2); color: #fff; box-shadow: var(--ring); }

.chart { width: 100%; height: 240px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
.chart .axis-label { fill: var(--text-faint); font-size: 10px; font-family: var(--sans); }
.chart .series-line { fill: none; stroke: url(#lineGrad); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart .series-area { fill: url(#areaGrad); }
.chart .dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; transition: r .15s; }
.chart .dot:hover { r: 6; }
.chart .empty { fill: var(--text-faint); font-size: 12px; }
.chart__empty { display: grid; place-items: center; height: 100%; margin: 0; padding: 0 .6rem;
    text-align: center; text-wrap: balance; color: var(--text-faint); font-size: .84rem; }

/* --------------------------------------------------------------- heatmap */
.heatmap { display: grid; grid-template-columns: repeat(14, 1fr); gap: 5px; }
.heatmap i {
    aspect-ratio: 1; border-radius: 4px;
    background: rgba(255, 255, 255, .05);
    transition: transform .15s;
}
.heatmap i:hover { transform: scale(1.18); }
.heatmap i.lvl1 { background: rgba(74, 222, 128, .28); }
.heatmap i.lvl2 { background: rgba(74, 222, 128, .5); }
.heatmap i.lvl3 { background: rgba(74, 222, 128, .72); }
.heatmap i.lvl4 { background: var(--accent); box-shadow: 0 0 12px rgba(74, 222, 128, .5); }
.heatmap__legend { display: flex; align-items: center; gap: 5px; margin-top: .8rem; font-size: .72rem; color: var(--text-faint); }
.heatmap__legend i { width: 11px; height: 11px; border-radius: 3px; background: rgba(255, 255, 255, .05); }
.heatmap__legend i.lvl1 { background: rgba(74, 222, 128, .28); }
.heatmap__legend i.lvl2 { background: rgba(74, 222, 128, .5); }
.heatmap__legend i.lvl3 { background: rgba(74, 222, 128, .72); }
.heatmap__legend i.lvl4 { background: var(--accent); }

/* ------------------------------------------------------------- historial */
.logs { display: flex; flex-direction: column; gap: .6rem; max-height: 380px; overflow-y: auto; padding-right: .3rem; }
.log {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .4rem 1rem;
    padding: .85rem 1rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .035);
    border-left: 3px solid var(--accent);
    transition: background .18s;
}
.log:hover { background: rgba(255, 255, 255, .06); }
.log__date { font-size: .74rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.log__metrics { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .4rem; }
.log__metrics span {
    font-size: .76rem; padding: .18rem .5rem; border-radius: 6px;
    background: rgba(255, 255, 255, .06); color: var(--text-dim);
}
.log__notes { grid-column: 1 / -1; font-size: .84rem; color: var(--text-dim); font-style: italic; }
.log__del {
    align-self: start; border: 0; background: transparent; color: var(--text-faint);
    cursor: pointer; font-size: 1.1rem; line-height: 1; padding: .2rem .35rem; border-radius: 6px;
}
.log__del:hover { color: var(--danger); background: rgba(248, 113, 113, .12); }
.empty-state { color: var(--text-faint); font-size: .88rem; padding: 1.2rem 0; text-align: center; }

/* ------------------------------------------------------------ formulario */
.form { display: flex; flex-direction: column; gap: .85rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > span { font-size: .78rem; color: var(--text-dim); font-weight: 500; }
.field > span em { font-style: normal; color: var(--text-faint); font-size: .72rem; }
.field input, .field select, .field textarea, .coach__form textarea, .atlas__search input, .hud-select, .drawer__ai select {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .04);
    color: var(--text);
    outline: none;
    transition: border-color .18s, box-shadow .18s, background .18s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.coach__form textarea:focus, .atlas__search input:focus {
    border-color: rgba(74, 222, 128, .55);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, .13);
    background: rgba(255, 255, 255, .06);
}
.field textarea, .coach__form textarea { resize: vertical; }
.field select option, .hud-select option { background: #10151d; }

.field input[type="range"] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); height: 24px; }

.form__msg { font-size: .82rem; min-height: 1.1rem; color: var(--accent); }
.form__msg.is-error { color: var(--danger); }

/* ------------------------------------------------------------------ toast */
.toast {
    position: fixed; bottom: 1.4rem; left: 50%;
    transform: translate(-50%, 20px);
    padding: .7rem 1.2rem;
    border-radius: 999px;
    background: #131a24;
    box-shadow: var(--shadow), inset 0 0 0 1px var(--line-strong);
    font-size: .86rem;
    opacity: 0;
    transition: opacity .25s, transform .25s;
    z-index: 200;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================================
   Atlas 3D
   ========================================================================= */
.atlas { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 25vw, 380px); gap: 1.1rem; }

.viewer {
    position: relative;
    height: min(74dvh, 760px);
    min-height: 400px;
    border-radius: var(--radius);
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 50% 0%, #141b26 0%, #0a0e15 55%, #06080c 100%);
    box-shadow: var(--ring), 0 24px 60px rgba(0, 0, 0, .5);
}
.viewer:fullscreen { height: 100dvh; border-radius: 0; }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.viewer__loader {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem;
    background: rgba(6, 8, 12, .9);
    color: var(--text-dim);
    font-size: .88rem;
    z-index: 5;
    transition: opacity .4s;
}
.viewer__loader.is-done { opacity: 0; pointer-events: none; }
.loader__ring {
    width: 42px; height: 42px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .12);
    border-top-color: var(--accent);
    animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader__bar { width: 190px; height: 3px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.loader__bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s; }

.viewer__hud {
    position: absolute; top: .9rem; left: .9rem; right: .9rem;
    display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap;
    z-index: 4;
}
.hud-group { display: flex; gap: .35rem; flex-wrap: wrap; }
.hud-btn, .hud-select {
    padding: .4rem .7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(10, 14, 20, .72);
    backdrop-filter: blur(8px);
    color: var(--text-dim);
    font-size: .78rem;
    font-weight: 500;
    cursor: pointer;
    transition: .18s;
}
.hud-select { width: auto; padding-right: .5rem; }
.hud-btn:hover { color: #fff; border-color: var(--line-strong); background: rgba(20, 26, 36, .85); }
.hud-btn--toggle.is-active {
    color: #05130b;
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    border-color: transparent;
}

.viewer__tip {
    position: absolute;
    padding: .3rem .6rem;
    border-radius: 7px;
    background: rgba(8, 11, 16, .9);
    box-shadow: inset 0 0 0 1px var(--line-strong);
    font-size: .78rem;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -140%);
    transition: opacity .15s;
    z-index: 6;
    max-width: min(72vw, 300px);
}
.viewer__tip.is-visible { opacity: 1; }

.viewer__help {
    position: absolute; bottom: .8rem; left: 0; right: 0;
    text-align: center; font-size: .74rem; color: var(--text-faint);
    pointer-events: none;
}

/* ---------------------------------------------------------- lista lateral */
.atlas__side { display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
    padding: .32rem .7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--text-dim);
    font-size: .76rem;
    cursor: pointer;
    transition: .18s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.is-active { background: var(--surface-2); color: #fff; border-color: var(--line-strong); }

.muscle-list { display: flex; flex-direction: column; gap: .45rem; overflow-y: auto; max-height: min(62dvh, 640px); padding-right: .3rem; }
.muscle-item {
    display: flex; align-items: center; gap: .75rem;
    width: 100%;
    padding: .7rem .85rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .035);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: .18s;
}
.muscle-item:hover { background: rgba(255, 255, 255, .07); transform: translateX(3px); }
.muscle-item.is-active { border-color: color-mix(in srgb, var(--dot) 55%, transparent); background: color-mix(in srgb, var(--dot) 12%, transparent); }
.muscle-item i { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 10px var(--dot); flex: none; }
.muscle-item strong { font-size: .88rem; font-weight: 600; display: block; }
.muscle-item small { font-size: .74rem; color: var(--text-faint); }

/* ---------------------------------------------------------------- drawer */
.drawer { position: fixed; inset: 0; z-index: 120; display: flex; justify-content: flex-end; background: rgba(4, 6, 9, .6); backdrop-filter: blur(3px); animation: fade .2s ease both; }
.drawer__panel {
    position: relative;
    width: min(560px, 100%);
    height: 100%;
    overflow-y: auto;
    padding: 2rem 1.8rem 3rem;
    background: linear-gradient(180deg, #101620, #0a0d13);
    box-shadow: -24px 0 60px rgba(0, 0, 0, .55);
    border-left: 1px solid var(--line);
    animation: slideIn .32s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }

.drawer__close {
    position: absolute; top: 1.1rem; right: 1.2rem;
    width: 34px; height: 34px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-dim);
    font-size: 1.3rem; line-height: 1;
    cursor: pointer;
}
.drawer__close:hover { color: #fff; background: var(--surface-2); }

.drawer__head { margin-bottom: 1rem; padding-right: 3rem; }
.drawer__group {
    display: inline-block;
    padding: .22rem .6rem; margin-bottom: .6rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--dot, var(--accent)) 18%, transparent);
    color: var(--dot, var(--accent));
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
}
.drawer__head h2 { font-size: clamp(1.25rem, 1.05rem + .8vw, 1.55rem); }
.drawer__latin { color: var(--text-faint); font-style: italic; font-size: .86rem; }
.drawer__desc { color: var(--text-dim); font-size: .92rem; margin-bottom: 1rem; }

.drawer__fact, .drawer__freq {
    display: flex; flex-direction: column; gap: .2rem;
    padding: .85rem 1rem; margin-bottom: 1.2rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .04);
    border-left: 3px solid var(--dot, var(--accent));
    font-size: .88rem;
}
.drawer__fact strong, .drawer__freq strong { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-faint); }

.drawer__anatomy { margin-bottom: 1.3rem; }
.drawer__anatomy h3 {
    display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; flex-wrap: wrap;
    font-size: .82rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-faint); margin-bottom: .6rem;
}
.drawer__ref { font-size: .7rem; letter-spacing: .02em; text-transform: none; color: var(--text-faint); font-style: italic; }
.parts { display: flex; flex-direction: column; gap: .45rem; }
.parts li {
    display: grid; gap: .15rem;
    padding: .6rem .8rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .03);
    border-left: 2px solid color-mix(in srgb, var(--dot, var(--accent)) 45%, transparent);
    transition: background .2s, border-color .2s;
}
.parts li.is-active { background: color-mix(in srgb, var(--dot, var(--accent)) 14%, transparent); border-left-color: var(--dot, var(--accent)); }
.parts strong { font-size: .86rem; color: var(--text); font-weight: 600; }
.parts span { font-size: .8rem; color: var(--text-dim); }
.parts em { font-style: normal; color: var(--text-faint); font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; margin-right: .45rem; }

.drawer__cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-bottom: 1.2rem; }
.drawer__cols h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-faint); margin-bottom: .55rem; }
.drawer__cols li {
    position: relative;
    padding-left: 1rem; margin-bottom: .42rem;
    font-size: .86rem; color: var(--text-dim);
}
.drawer__cols li::before {
    content: ''; position: absolute; left: 0; top: .55em;
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--dot, var(--accent)); opacity: .8;
}

.drawer__ai { border-top: 1px solid var(--line); padding-top: 1.2rem; }
.drawer__ai-controls { display: flex; gap: .5rem; flex-wrap: wrap; }
.drawer__ai select { width: auto; flex: 1 1 140px; }

/* ------------------------------------------------------------- salida IA */
.ai-output {
    margin-top: 1rem;
    padding: 1.1rem 1.2rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .035);
    box-shadow: inset 0 0 0 1px var(--line);
    font-size: .9rem;
    color: var(--text-dim);
    overflow-x: auto;
}
.ai-output h2 { font-size: 1.05rem; color: var(--text); margin: .9rem 0 .5rem; }
.ai-output h3 { font-size: .92rem; color: var(--accent); margin: .9rem 0 .4rem; }
.ai-output h4 {
    font-family: var(--display); font-weight: 600;
    font-size: .8rem; text-transform: uppercase; letter-spacing: .08em;
    color: var(--text); margin: 1rem 0 .45rem;
}
.ai-output h2:first-child, .ai-output h3:first-child, .ai-output h4:first-child { margin-top: 0; }
.ai-output p { margin-bottom: .6rem; }
.ai-output ul, .ai-output ol { margin: 0 0 .8rem 1.1rem; }
.ai-output li { margin-bottom: .3rem; list-style: disc; }
.ai-output ol li { list-style: decimal; }
.ai-output strong { color: var(--text); }
.ai-output table { width: 100%; border-collapse: collapse; margin-bottom: .9rem; font-size: .84rem; }
.ai-output th, .ai-output td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; }
.ai-output th { color: var(--text); font-weight: 600; background: rgba(255, 255, 255, .04); }
.ai-output code { background: rgba(255, 255, 255, .08); padding: .1rem .35rem; border-radius: 5px; font-size: .84em; }
.ai-output .thinking { display: flex; align-items: center; gap: .6rem; color: var(--text-faint); }
.ai-output .thinking::before {
    content: ''; width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .15); border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}

/* ----------------------------------------------------------------- coach */
.coach { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 1.1rem; align-items: start; }
.coach__form { display: flex; flex-direction: column; gap: .7rem; align-items: flex-start; }
.coach__form textarea { width: 100%; }
.coach__suggestions { display: flex; flex-wrap: wrap; gap: .4rem; }

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

/* portatil pequeno: las dos columnas pasan a una */
@media (max-width: 1180px) {
    .grid-main { grid-template-columns: 1fr; }
    .atlas { grid-template-columns: 1fr; }
    .muscle-list { max-height: 320px; }
    /* con el atlas en una columna el panel ya no depende del alto del visor */
    .exercise-panel { max-height: none; }
}

/* tableta: la barra lateral se queda en iconos y gana ancho el contenido */
@media (min-width: 861px) and (max-width: 1100px) {
    .app { grid-template-columns: 76px minmax(0, 1fr); }
    .rail { padding: 1.2rem .5rem; gap: 1.4rem; }
    .rail__brand { justify-content: center; padding: 0; }
    .rail__word { display: none; }
    .rail__link { flex-direction: column; gap: .25rem; padding: .6rem .3rem; font-size: .64rem; text-align: center; }
    .rail__link svg { width: 21px; height: 21px; }
    .streak { align-items: center; text-align: center; padding: .7rem .4rem; }
    .streak span { font-size: .6rem; letter-spacing: .04em; }
    .main { padding: 1.4rem 1.3rem 3rem; }
}

/* movil: la navegacion baja al pie y el contenido pasa a una columna */
@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .main { padding: 1.1rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); }

    .rail {
        position: fixed; top: auto; bottom: 0; left: 0; right: 0;
        height: auto;
        flex-direction: row; align-items: center; justify-content: space-between;
        gap: .5rem;
        padding: .45rem .8rem calc(.45rem + env(safe-area-inset-bottom));
        border-right: 0; border-top: 1px solid var(--line);
    }
    .rail__brand, .rail__foot { display: none; }
    .rail__nav { flex-direction: row; width: 100%; justify-content: space-around; }
    .rail__link { flex-direction: column; gap: .18rem; font-size: .7rem; padding: .45rem .6rem; }

    .field-row { grid-template-columns: 1fr; }
    .drawer__cols { grid-template-columns: 1fr; }
    .viewer { height: min(62dvh, 560px); min-height: 340px; }
    .viewer__help { display: none; }
    .heatmap { grid-template-columns: repeat(7, 1fr); }
    .drawer__panel { padding: 1.6rem 1.1rem calc(3rem + env(safe-area-inset-bottom)); }

    /* el HUD deja de envolverse sobre el modelo: la fila de camaras arriba,
       la de capas abajo, y cada una se desplaza en horizontal si no cabe */
    .viewer__hud {
        top: .6rem; left: .6rem; right: .6rem; bottom: .6rem;
        flex-direction: column; justify-content: space-between; gap: .4rem;
        pointer-events: none;
    }
    .hud-group { pointer-events: auto; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .hud-group::-webkit-scrollbar { display: none; }
    .hud-btn, .hud-range { white-space: nowrap; flex: none; }
    /* en articulado el reproductor ocupa el pie (dos filas en movil),
       asi que las capas suben por encima de el */
    .viewer.is-articulado .viewer__hud { bottom: 7.9rem; }

    /* el aviso no puede quedar debajo de la barra de navegacion */
    .toast {
        left: 1rem; right: 1rem;
        bottom: calc(4.6rem + env(safe-area-inset-bottom));
        text-align: center;
        transform: translateY(16px);
    }
    .toast.is-visible { transform: translateY(0); }
}

/* movil estrecho */
@media (max-width: 520px) {
    .main { padding: .9rem .8rem calc(5.4rem + env(safe-area-inset-bottom)); }
    .card { padding: 1rem; }
    /* dos indicadores por fila: la pagina se acorta a la mitad */
    .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi { padding: .85rem .9rem; }
    .kpi__label { font-size: .68rem; letter-spacing: .06em; }
    .kpi__hint { font-size: .7rem; }
    .topbar { align-items: flex-start; gap: .7rem; margin-bottom: 1.2rem; }
    .topbar__actions { width: 100%; justify-content: space-between; }
    .grid-kpi { gap: .7rem; margin-bottom: .7rem; }
    .stack { gap: .8rem; }

    .card__head { gap: .6rem; }
    .seg { width: 100%; }
    .seg button { flex: 1; padding: .36rem .25rem; font-size: .74rem; }
    .chart { height: 200px; }

    .ex-cat__items { grid-template-columns: 1fr; }
    .draft__actions { flex-direction: column-reverse; }
    .drawer__ai-controls { flex-direction: column; }
    .drawer__ai select { width: 100%; flex: none; }
    .drawer__panel { padding: 1.4rem .9rem calc(2.6rem + env(safe-area-inset-bottom)); }
    .drawer__head { padding-right: 2.6rem; }
    .viewer__tip { max-width: 80vw; }
    .coach__form .btn { width: 100%; }
}

/* movil en horizontal: apenas hay alto, asi que la cabecera se reduce al
   minimo y el visor ocupa lo que queda entre ella y la barra de navegacion */
@media (orientation: landscape) and (max-height: 560px) and (max-width: 1100px) {
    .main { padding-top: .6rem; padding-bottom: calc(4.2rem + env(safe-area-inset-bottom)); }
    .topbar { margin-bottom: .7rem; align-items: center; }
    .topbar__sub { display: none; }
    .topbar .pill { display: none; }
    .topbar__title { font-size: 1.05rem; }

    .rail { padding: .3rem .8rem calc(.3rem + env(safe-area-inset-bottom)); }
    .rail__link { flex-direction: row; gap: .45rem; padding: .35rem .7rem; }

    .viewer { height: calc(100dvh - 8.5rem); min-height: 200px; }
    /* en apaisado los dos grupos caben en una fila arriba: el HUD vuelve a
       anclarse solo al borde superior y no se estira a lo alto */
    .viewer__hud, .viewer.is-articulado .viewer__hud { flex-direction: row; align-items: flex-start; bottom: auto; }

    .drawer__panel { padding-top: 1.1rem; }
    .muscle-list { max-height: 46dvh; }
    .exercise-panel { max-height: none; }
}

/* pantallas tactiles: areas de pulsacion comodas y sin efectos de raton */
@media (pointer: coarse) {
    .hud-btn, .hud-select { padding: .55rem .85rem; font-size: .8rem; }
    .hud-range { padding: .42rem .7rem; }
    .chip { padding: .5rem .9rem; font-size: .8rem; }
    .seg button { padding: .5rem .85rem; }
    .day__arrow { width: 40px; height: 40px; }
    .drawer__close { width: 42px; height: 42px; }
    .slot__del { width: 34px; height: 34px; font-size: 1.15rem; }
    .log__del { min-width: 34px; min-height: 34px; }
    .drop__clear { width: 36px; height: 36px; }
    .player__speed button { padding: .45rem .6rem; }
    .player__toggle { width: 42px; height: 42px; }
    .mode-switch__btn { padding: .7rem .7rem; }

    .muscle-item:hover { transform: none; background: rgba(255, 255, 255, .035); }
    .heatmap i:hover { transform: none; }
    .chart .dot:hover { r: 4; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .2); }

/* tooltip del atlas con nombre y tipo de tejido */
.viewer__tip { display: grid; gap: .1rem; text-align: center; }
.viewer__tip strong { font-weight: 600; font-size: .8rem; }
.viewer__tip small { font-size: .66rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; }

/* control de opacidad del HUD */
.hud-range {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .3rem .6rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(10, 14, 20, .72);
    backdrop-filter: blur(8px);
    color: var(--text-dim);
    font-size: .74rem;
}
.hud-range input { width: 84px; accent-color: var(--accent); }

.viewer__credit {
    position: absolute; right: .9rem; bottom: 2.1rem; text-align: right;
    font-size: .62rem; color: var(--text-faint); pointer-events: auto;
}
.viewer__credit a { color: inherit; }
@media (max-width: 860px) { .hud-range input { width: 60px; } .viewer__credit { display: none; } }

/* =========================================================================
   Modo articulado
   ========================================================================= */
.mode-switch {
    display: grid; grid-template-columns: 1fr 1fr; gap: .3rem;
    padding: .3rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .03);
    box-shadow: var(--ring);
}
.mode-switch__btn {
    display: grid; gap: .05rem;
    padding: .55rem .7rem;
    border: 0; border-radius: 8px;
    background: transparent;
    color: var(--text-dim);
    text-align: left;
    cursor: pointer;
    transition: .18s;
}
.mode-switch__btn strong { font-family: var(--display); font-size: .92rem; font-weight: 600; }
.mode-switch__btn small { font-size: .7rem; color: var(--text-faint); }
.mode-switch__btn:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.mode-switch__btn.is-active {
    color: #fff;
    background: linear-gradient(135deg, rgba(74, 222, 128, .16), rgba(74, 222, 128, .04));
    box-shadow: inset 0 0 0 1px rgba(74, 222, 128, .35);
}
.mode-switch__btn.is-active small { color: var(--text-dim); }

.atlas-panel, .exercise-panel { display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.exercise-panel { overflow-y: auto; max-height: calc(min(74dvh, 760px) - 4.4rem); padding-right: .3rem; }

.exercise-grid { display: grid; gap: .7rem; }
.ex-cat { display: grid; gap: .35rem; }
.ex-cat__title { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); }
.ex-cat__items { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.ex-item {
    display: grid; gap: .1rem; align-content: start;
    padding: .5rem .6rem;
    border: 1px solid var(--line); border-radius: 9px;
    background: rgba(255, 255, 255, .03);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: .18s;
}
.ex-item strong { font-size: .8rem; font-weight: 600; line-height: 1.2; }
.ex-item small { font-size: .68rem; color: var(--text-faint); }
.ex-item:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, .06); }
.ex-item.is-active { border-color: rgba(255, 86, 56, .6); background: linear-gradient(135deg, rgba(255, 70, 40, .2), rgba(255, 70, 40, .04)); }

.exercise-card {
    display: grid; gap: .55rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .035);
    box-shadow: var(--ring);
}
.exercise-card__tag { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.exercise-card h3 { margin: 0; font-family: var(--display); font-size: 1.15rem; }
.exercise-card p { margin: 0; font-size: .8rem; line-height: 1.5; color: var(--text-dim); }
.exercise-card h4 { margin: .35rem 0 0; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); }

.ex-legend__item--primary, .ex-role--primary { --role: #ff2a22; }
.ex-legend__item--secondary, .ex-role--secondary { --role: #ff9a3d; }
.ex-legend__item--stabilizer, .ex-role--stabilizer { --role: #f2cc5b; }
.ex-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .7rem; color: var(--text-dim); }
.ex-legend__item { display: inline-flex; align-items: center; gap: .35rem; }
.ex-legend__item::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--role); box-shadow: 0 0 8px var(--role); }

.ex-muscles { display: grid; gap: .65rem; }
.ex-role { display: grid; gap: .25rem; }
.ex-role__title { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--role); }
.ex-muscle {
    display: grid; grid-template-columns: auto 1fr 60px; align-items: center; gap: .5rem;
    padding: .4rem .5rem;
    border: 0; border-radius: 7px;
    background: rgba(255, 255, 255, .03);
    color: var(--text);
    font-size: .8rem;
    text-align: left;
    cursor: pointer;
    transition: background .15s;
}
.ex-muscle:hover { background: rgba(255, 255, 255, .08); }
.ex-muscle i { width: 7px; height: 7px; border-radius: 50%; background: var(--role); box-shadow: 0 0 8px var(--role); }
.ex-meter { height: 4px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.ex-meter em { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--role); transition: width .12s linear; }
.ex-cues { margin: 0; padding-left: 1.05rem; display: grid; gap: .3rem; font-size: .78rem; line-height: 1.45; color: var(--text-dim); }

/* reproductor sobre el visor */
.player {
    position: absolute; left: .9rem; right: .9rem; bottom: .9rem; z-index: 4;
    display: flex; align-items: center; gap: .8rem;
    padding: .6rem .8rem;
    border-radius: 12px;
    background: rgba(8, 11, 16, .8);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 0 0 1px var(--line);
}
.player__toggle {
    flex: none; display: grid; place-items: center;
    width: 38px; height: 38px;
    border: 0; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    cursor: pointer;
}
.player__toggle span { box-sizing: border-box; width: 12px; height: 14px; border-left: 4px solid #05130b; border-right: 4px solid #05130b; }
.player__toggle.is-paused span {
    width: 0; height: 0; margin-left: 3px;
    border-top: 8px solid transparent; border-bottom: 8px solid transparent;
    border-left: 13px solid #05130b; border-right: 0;
}
.player__body { flex: 1; min-width: 0; display: grid; gap: .3rem; }
.player__head { display: flex; align-items: baseline; gap: .7rem; min-width: 0; }
.player__title { font-family: var(--display); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.player__phase { min-width: 0; overflow: hidden; font-size: .74rem; color: var(--text-dim); white-space: nowrap; text-overflow: ellipsis; }
.player__phase strong { margin-right: .45rem; font-weight: 600; color: #fff; }
.player__phase[data-type="concentric"] strong { color: #ff6a4d; }
.player__phase[data-type="eccentric"] strong { color: #ffb067; }
.player__phase[data-type="peak"] strong, .player__phase[data-type="stretch"] strong { color: #f2cc5b; }
.player__scrub { width: 100%; height: 14px; margin: 0; accent-color: var(--accent); }
.player__effort { height: 3px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.player__effort i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #f2cc5b, #ff4a2e); transition: width .12s linear; }
.player__speed { flex: none; display: flex; gap: .2rem; }
.player__speed button {
    padding: .3rem .45rem;
    border: 1px solid var(--line); border-radius: 7px;
    background: transparent;
    color: var(--text-dim);
    font-size: .72rem;
    cursor: pointer;
}
.player__speed button.is-active { color: #fff; border-color: var(--line-strong); background: rgba(255, 255, 255, .08); }
.viewer.is-articulado .viewer__help { display: none; }
.viewer.is-articulado .viewer__credit { bottom: 5.4rem; }

/* ficha: acceso a la animacion */
.drawer__motion { margin-bottom: 1.3rem; }
.drawer__motion h3 { margin: 0 0 .6rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); }
.motion-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.motion-link {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .45rem .8rem;
    border: 1px solid rgba(255, 86, 56, .35); border-radius: 999px;
    background: rgba(255, 70, 40, .08);
    color: var(--text);
    font-size: .8rem;
    cursor: pointer;
    transition: background .18s;
}
.motion-link span { font-size: .66rem; color: #ff6a4d; }
.motion-link:hover { background: rgba(255, 70, 40, .2); }

@media (max-width: 860px) {
    .exercise-panel { max-height: none; }
    .player { flex-wrap: wrap; left: .5rem; right: .5rem; bottom: .5rem; gap: .5rem .7rem; }
    .player__body { flex-basis: calc(100% - 50px); }
    .player__speed { margin-left: auto; }
}

/* =========================================================================
   Diario por foto · subida de imagen, borrador de IA y huecos del dia
   ========================================================================= */

.diary { display: grid; grid-template-columns: minmax(340px, .9fr) minmax(0, 1.25fr); gap: 1.1rem; align-items: start; }

/* ------------------------------------------------------- subir la foto -- */
.shot { display: flex; flex-direction: column; gap: 1rem; }

.shot__tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; padding: .3rem; background: rgba(0, 0, 0, .25); border-radius: 12px; box-shadow: var(--ring); }
.shot__tab {
    display: flex; flex-direction: column; gap: .1rem;
    padding: .55rem .7rem;
    border: 0; border-radius: 9px;
    background: transparent; color: var(--text-dim);
    cursor: pointer; text-align: left;
    transition: background .18s, color .18s;
}
.shot__tab strong { font-size: .88rem; font-weight: 600; }
.shot__tab small { font-size: .7rem; color: var(--text-faint); }
.shot__tab:hover { color: var(--text); }
.shot__tab.is-active { background: var(--surface-2); color: var(--text); box-shadow: var(--ring); }
.shot__tab.is-active small { color: var(--text-dim); }

.shot__body { display: flex; flex-direction: column; gap: .9rem; }
.shot__controls { display: flex; flex-direction: column; gap: .8rem; }

.drop {
    position: relative;
    display: grid; place-items: center;
    min-height: 200px;
    padding: 1.2rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, .22);
    cursor: pointer;
    overflow: hidden;
    transition: border-color .18s, background .18s;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: rgba(74, 222, 128, .07); }
.drop__empty { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; }
.drop__icon { font-size: 1.8rem; }
.drop__empty strong { font-size: .92rem; font-weight: 600; }
.drop__empty small { font-size: .76rem; color: var(--text-faint); max-width: 30ch; }
.drop__preview { width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px; display: block; }
.drop__clear {
    position: absolute; top: .5rem; right: .5rem;
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border: 0; border-radius: 50%;
    background: rgba(0, 0, 0, .65); color: var(--text);
    font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.drop__clear:hover { background: var(--danger); color: #07090d; }

.slot-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(96px, 100%), 1fr)); gap: .35rem; }
.slot-chip {
    display: flex; flex-direction: column; gap: .05rem;
    padding: .45rem .5rem;
    border: 1px solid var(--line); border-radius: 9px;
    background: var(--surface); color: var(--text-dim);
    font-size: .74rem; cursor: pointer; text-align: left;
    transition: border-color .18s, background .18s, color .18s;
}
.slot-chip span { font-weight: 500; color: var(--text); font-size: .76rem; }
.slot-chip small { color: var(--text-faint); font-size: .68rem; }
.slot-chip:hover { border-color: var(--line-strong); }
.slot-chip.is-active { border-color: var(--accent); background: rgba(74, 222, 128, .12); }
.slot-chip.is-taken span { color: var(--text-dim); }
.slot-chip.is-taken small { color: var(--accent-warm); }

/* ----------------------------------------------------- borrador de la IA */
.draft {
    display: flex; flex-direction: column; gap: .75rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(150deg, rgba(34, 211, 238, .1), rgba(74, 222, 128, .04));
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .22);
}
.draft__head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; }
.draft__tag { font-size: .72rem; color: var(--accent-2); text-transform: uppercase; letter-spacing: .05em; }
.draft__head h3 { font-size: 1rem; margin-top: .15rem; }
.draft__name {
    width: 100%;
    padding: .3rem .5rem;
    border: 1px solid var(--line); border-radius: 8px;
    background: rgba(0, 0, 0, .3);
    font-family: var(--display); font-size: 1rem; font-weight: 600;
}
.draft__name:focus { outline: none; border-color: var(--accent); }
.draft__conf { display: flex; align-items: center; gap: .35rem; font-size: .72rem; color: var(--text-dim); white-space: nowrap; }
.conf { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.conf--alta { background: var(--accent); }
.conf--media { background: #fbbf24; }
.conf--baja { background: var(--danger); }
.draft__note { font-size: .78rem; color: var(--text-dim); }

.draft__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(84px, 100%), 1fr)); gap: .5rem; }
.draft__field { display: flex; flex-direction: column; gap: .25rem; }
.draft__field > span { font-size: .72rem; color: var(--text-dim); }
.draft__field > span em { font-style: normal; color: var(--text-faint); }
.draft__field input {
    width: 100%;
    padding: .45rem .55rem;
    border: 1px solid var(--line); border-radius: 8px;
    background: rgba(0, 0, 0, .3);
    font-variant-numeric: tabular-nums;
}
.draft__field input:focus { outline: none; border-color: var(--accent); }

.draft__items { display: flex; flex-direction: column; gap: .25rem; }
.draft__items li { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; font-size: .78rem; padding: .25rem .1rem; border-bottom: 1px solid var(--line); }
.draft__items small { color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.draft__tip { font-size: .78rem; color: var(--accent); }
.draft__tip:empty { display: none; }
.draft__actions { display: flex; gap: .5rem; }
.draft__actions .btn { flex: 1; }

/* ------------------------------------------------------------- el dia --- */
.day__nav { display: flex; align-items: center; gap: .6rem; }
.day__nav h2 { font-size: 1.05rem; text-transform: capitalize; }
.day__arrow {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface); color: var(--text-dim);
    font-size: 1.1rem; cursor: pointer;
}
.day__arrow:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.day__arrow:disabled { opacity: .3; cursor: default; }

.day__totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: .9rem; }
.total { display: flex; flex-direction: column; gap: .3rem; }
.total__head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.total__head span { font-size: .76rem; color: var(--text-dim); }
.total__head strong { font-family: var(--display); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.total__head small { font-size: .72rem; color: var(--text-faint); font-weight: 400; }
.total__bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.total__bar i { display: block; height: 100%; border-radius: 99px; background: var(--c); transition: width .4s ease; }
.total__rest { font-size: .7rem; color: var(--text-faint); }
.total__rest.is-over { color: var(--accent-warm); }
.total--macros .macros { display: flex; gap: .9rem; flex-wrap: wrap; }
.macros span { display: flex; flex-direction: column; font-size: .68rem; color: var(--text-faint); }
.macros em { font-style: normal; font-family: var(--display); font-size: .95rem; color: var(--text); }

.day__watch { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(110px, 100%), 1fr)); gap: .6rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.wcell { display: flex; flex-direction: column; gap: .15rem; }
.wcell span { font-size: .72rem; color: var(--text-dim); }
.wcell strong { font-family: var(--display); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.wcell strong small { font-size: .7rem; color: var(--text-faint); font-weight: 400; margin-left: .15rem; }
.wcell.is-empty strong { color: var(--text-faint); }

/* ------------------------------------------------------ huecos del dia -- */
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: .7rem; }
.slot {
    display: flex; flex-direction: column; gap: .45rem;
    padding: .8rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, .18);
}
.slot.is-filled { border-color: rgba(74, 222, 128, .28); background: rgba(74, 222, 128, .05); }
.slot.is-optional { border-style: dashed; }
.slot header { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.slot__name { font-size: .8rem; font-weight: 600; }
.slot__window { font-size: .68rem; color: var(--text-faint); }
.slot__flag { font-size: .66rem; padding: .1rem .4rem; border-radius: 99px; white-space: nowrap; }
.slot__flag.is-ok { background: rgba(74, 222, 128, .16); color: var(--accent); }
.slot__flag.is-over { background: rgba(255, 107, 74, .16); color: var(--accent-warm); }
.slot__flag.is-under { background: rgba(125, 211, 252, .16); color: #7dd3fc; }
.slot__meal { font-family: var(--display); font-size: .92rem; line-height: 1.3; }
.slot__macros { display: flex; flex-wrap: wrap; gap: .3rem; }
.slot__macros span { font-size: .68rem; padding: .12rem .4rem; border-radius: 6px; background: var(--surface-2); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.slot__items { font-size: .7rem; color: var(--text-faint); line-height: 1.4; }
.slot__rec { font-size: .74rem; color: var(--text-dim); flex: 1; }
.slot__rec strong { color: var(--text); font-weight: 600; }
.slot footer { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-top: auto; padding-top: .3rem; }
.slot__src { font-size: .66rem; color: var(--text-faint); }
.slot__del {
    width: 22px; height: 22px;
    display: grid; place-items: center;
    border: 0; border-radius: 6px;
    background: transparent; color: var(--text-faint);
    font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.slot__del:hover { background: rgba(248, 113, 113, .16); color: var(--danger); }
.slot .btn { font-size: .78rem; padding: .45rem .7rem; }

@media (max-width: 1180px) { .diary { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
    .slots { grid-template-columns: 1fr; }
    .draft__fields { grid-template-columns: repeat(auto-fit, minmax(min(74px, 100%), 1fr)); }
    .drop { min-height: 160px; }
}
