/* Logged-in shell (round 1, system leg): a white sidebar from 60rem (Estudiar, Tu expediente), a top bar and
   five tabs below it. The dashboard and settings rules further down keep /inicio and /ajustes working until
   their legs replace them. Tokens from style.css only. */

/* Shell frame */
.app { min-height: 100vh; }
.app-side { display: none; }
.app-body { min-width: 0; }
.app-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; padding-top: max(.5rem, env(safe-area-inset-top)); background: var(--papel); border-top: 3px solid var(--tinta); border-bottom: 1px solid var(--regla); }
.app-top-brand { min-height: 44px; }
.app-top-title { flex: 1; min-width: 0; margin: 0; font-weight: 600; color: var(--titulo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-main { width: 100%; max-width: 76rem; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.app-footer { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; max-width: 76rem; margin: 0 auto; padding: 1.25rem 1rem 6.5rem; color: var(--gris); font-size: .85rem; border-top: 1px solid var(--regla); }
.app-footer a { color: var(--gris); }
.app-footer-links { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; }

/* Sidebar (wide screens): paper, hairline edge; the active section is ink on a celeste wash with a 3 px rule */
.app-brand { padding: .25rem .5rem .5rem; }
.app-nav ul { list-style: none; margin: 0 0 .5rem; padding: 0; display: grid; gap: 2px; }
.app-nav-title { margin: 1.1rem .625rem .375rem; font: 600 .6875rem/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--gris); }
.app-nav-title:first-child { margin-top: 0; }
.app-nav a { display: flex; align-items: center; min-height: 2.375rem; padding: .35rem .625rem; border-radius: var(--rad-btn); color: var(--grafito); text-decoration: none; font-weight: 500; font-size: .9375rem; }
.app-nav a:hover { background: var(--pizarra); color: var(--grafito); }
.app-nav a[aria-current="page"] { background: var(--celeste); color: var(--tinta); font-weight: 600; box-shadow: inset 3px 0 0 var(--tinta); }
.app-side-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--regla); display: grid; gap: .75rem; }
.app-account { margin: 0; display: grid; gap: .45rem; justify-items: start; font-size: .8125rem; color: var(--gris); }
.app-account-mail { overflow-wrap: anywhere; color: var(--grafito); font-weight: 500; }
.app-side-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.app-logout { margin: 0; }
.app-logout .link-button { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; color: var(--gris); text-decoration: none; font-size: .875rem; }
.app-logout .link-button:hover { color: var(--tinta); }

/* Bottom tabs (phones and tablets): five labels that never wrap or get cut */
.app-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--papel); border-top: 1px solid var(--regla); padding-bottom: env(safe-area-inset-bottom); }
.app-tabs > ul { list-style: none; margin: 0 auto; padding: 0 .25rem; max-width: 40rem; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.app-tabs a, .tab-more > summary { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; min-height: 56px; padding: .35rem .1rem; color: var(--gris); text-decoration: none; font-size: .75rem; font-weight: 500; white-space: nowrap; cursor: pointer; text-align: center; }
.app-tabs .icon { width: 1.375rem; height: 1.375rem; }
.app-tabs a[aria-current="page"], .tab-more > summary.is-active, .tab-more[open] > summary { color: var(--tinta); font-weight: 600; }
.app-tabs > ul > li > a[aria-current="page"] .icon { stroke-width: 2.2; }
.tab-more > summary { list-style: none; }
.tab-more > summary::-webkit-details-marker { display: none; }
.more-sheet { position: fixed; left: .75rem; right: .75rem; bottom: calc(64px + env(safe-area-inset-bottom)); max-width: 26rem; margin-left: auto; padding: .5rem; background: var(--papel); border: 1px solid var(--regla); border-radius: var(--rad-lg); box-shadow: var(--shadow-2); }
.more-sheet ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.more-sheet a { flex-direction: row; justify-content: flex-start; gap: .6rem; min-height: 48px; padding: .5rem .75rem; border-radius: var(--rad-btn); font-size: .9375rem; color: var(--grafito); white-space: normal; text-align: left; }
.more-sheet a:hover { background: var(--celeste); }
.more-sheet a[aria-current="page"] { background: var(--celeste); color: var(--tinta); }

@media (min-width: 60rem) {
  .app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .app-side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 1.25rem; padding: 1.25rem 1rem 1rem 1.25rem; background: var(--papel); border-top: 3px solid var(--tinta); border-right: 1px solid var(--regla); }
  .app-top, .app-tabs { display: none; }
  .app-main { padding: 2.25rem 2.75rem 3rem; }
  .app-footer { padding: 1.25rem 2.75rem 2rem; }
}

/* Panels: the dashboard's building block */
.panel { background: var(--papel); border: 1px solid var(--regla); border-radius: var(--rad-card); padding: 1.25rem; min-width: 0; }
.panel > .h3, .panel h2.h3 { margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; }
.panel-head .h3 { margin-bottom: .25rem; }
.panel-night { background: var(--noche); color: var(--on-noche); border-color: var(--night-2); }
.panel-night a, .panel-night .h3, .panel-night h2 { color: var(--on-noche); }
.panel-sand { background: var(--sand); border-color: var(--sand-2); }
.panel-sand .note, .panel-sand .citation, .panel-sand .disclaimer { color: var(--sand-ink); }
.panel-night .label, .panel-night .note { color: var(--on-noche-2); }
.panel-sand .label { color: var(--sand-ink); }

/* Page heads (/ajustes); /inicio has its own in home.css */
.dash-head { margin-bottom: 1.25rem; }
.dash-head h1 { font-size: var(--t-h1); margin-bottom: .35rem; }
.dash-head .lead { margin: 0; font-size: 1.05rem; }

/* Countdown */
.countdown { display: flex; align-items: baseline; gap: .5rem; margin: .25rem 0 .5rem; }
.countdown .num { font-size: clamp(3.4rem, 12vw, 5rem); font-weight: 600; line-height: .95; letter-spacing: -.06em; }
.countdown-unit { font-size: 1.1rem; font-weight: 600; }
.countdown-past { font-size: 1.15rem; font-weight: 650; }
.countdown-date { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin: 0 0 .35rem; font-weight: 500; }
.countdown-weeks { margin: 0; color: var(--on-night-muted); font-size: .9rem; }

/* Study pulse: the signature trace */
.pulse-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .5rem 1rem; }
.streak { display: flex; align-items: baseline; gap: .5rem; margin: 0; font-weight: 600; }
.streak .num { font-size: 2.6rem; line-height: 1; font-weight: 600; letter-spacing: -.05em; }
.pulse-note { margin: 0; color: var(--muted); font-size: .92rem; max-width: 22rem; }
.pulse { display: block; width: 100%; height: 5.5rem; margin-top: .75rem; overflow: visible; }
.pulse-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 2 4; }
.pulse-line { fill: none; stroke: var(--teal); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; animation: pulse-draw 1.6s var(--ease) both; }
.pulse-now { fill: var(--line-strong); }
.pulse-now.is-on { fill: var(--coral); }
.pulse-slot { fill: transparent; }
.pulse-slot:hover { fill: var(--teal-soft); opacity: .5; }
.pulse-axis { display: flex; justify-content: space-between; margin: .35rem 0 0; font: .75rem/1.2 var(--sans); color: var(--gris-2); }
@keyframes pulse-draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* Stats */
.stat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin: 0; }
.stat { background: var(--papel); border: 1px solid var(--regla); border-radius: var(--rad); padding: .9rem 1rem; }
.stat dt { font-size: .82rem; color: var(--muted); }
.stat dd { margin: .15rem 0 0; font-size: 1.75rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--titulo); }
@media (min-width: 48rem) { .stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Readiness rings */
.rings { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(7.25rem, 1fr)); gap: 1rem .75rem; }
.ring-item { display: grid; grid-template-rows: auto auto auto; justify-items: center; text-align: center; position: relative; }
.ring { width: 5.25rem; height: 5.25rem; grid-row: 1; grid-column: 1; }
.ring-track { fill: none; stroke: var(--line); stroke-width: 3.5; }
.ring-value { fill: none; stroke: var(--band, var(--teal)); stroke-width: 3.5; stroke-linecap: round; }
.is-empty .ring-track { stroke-dasharray: 2 3; }
.ring-pct { grid-row: 1; grid-column: 1; align-self: center; font-size: 1.15rem; font-weight: 600; }
.ring-title { margin-top: .45rem; font-weight: 650; font-size: .92rem; line-height: 1.25; }
.ring-meta { color: var(--muted); font-size: .78rem; }

/* Quick actions */
.quick { list-style: none; margin: 0 0 .75rem; padding: 0; display: grid; gap: .5rem; }
.quick-item { display: flex; align-items: center; gap: .75rem; min-height: 52px; padding: .65rem .85rem; border: 1px solid var(--regla); border-radius: var(--rad); color: var(--grafito); text-decoration: none; font-weight: 600; background: var(--papel); transition: border-color .15s var(--ease), background .15s var(--ease); }
.quick-item > span { flex: 1; display: grid; }
.quick-item small { font-weight: 400; font-size: .75rem; color: var(--muted); }
.quick-item .icon { color: var(--teal); }
.quick-item .quick-go { color: var(--faint); transition: transform .15s var(--ease); }
.quick-item:hover { border-color: var(--teal); background: var(--teal-soft); color: var(--ink); }
.quick-item:hover .quick-go { transform: translateX(3px); color: var(--teal); }
.quick-item.is-primary { background: var(--coral); border-color: var(--coral); color: var(--on-coral); }
.quick-item.is-primary .icon, .quick-item.is-primary .quick-go { color: var(--on-coral); }
.quick-item.is-primary:hover { background: var(--coral-strong); border-color: var(--coral-strong); }

/* Concept of the day and the plan */
.concept-body { font-size: 1.02rem; line-height: 1.6; }
.concept-case { margin: 0 0 .75rem; } .concept-case summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--sand-ink); }
.concept-case p { margin: .5rem 0 0; font-size: .95rem; color: var(--ink); }
.concept-answer { padding: .6rem .8rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--sand-2); }
.plan-list { margin: 0 0 1rem; display: grid; gap: 0; }
.plan-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.plan-list dt { color: var(--muted); font-size: .92rem; }
.plan-list dd { margin: 0; text-align: right; font-weight: 600; }
.plan-list dd .num, .plan-list dd.num { font-size: 1.25rem; }
.plan-list small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }

/* Settings */
.settings { max-width: 44rem; }
.settings-form { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.settings-block { display: grid; gap: .75rem; margin-bottom: 1rem; }
.settings-form .settings-block { margin-bottom: 0; }
.field { display: grid; gap: .35rem; }
.hint { margin: 0; color: var(--muted); font-size: .86rem; }
.segmented { margin: 0; padding: .25rem; border: 1px solid var(--regla-2); border-radius: var(--rad); display: grid; grid-template-columns: repeat(3, 1fr); gap: .25rem; background: var(--surface-2); }
.segmented label { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: var(--rad-btn); cursor: pointer; font-weight: 600; font-size: .92rem; }
.segmented input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--celeste); color: var(--tinta); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--foco); outline-offset: 2px; }
.settings-save { margin: 0; }
.settings-plan { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
@media (max-width: 30rem) { .settings-save .btn { width: 100%; } }

/* Pages written for the public layout (.section > .wrap) keep their markup inside the shell. */
.app-main .section { padding: 0 0 var(--s6); }
.app-main .section + .section { padding-top: var(--s5); }
.app-main .section-alt { background: none; border: 0; }
.app-main .wrap { max-width: none; margin: 0; padding: 0; }
.app-main .wrap.narrow { max-width: 46rem; }
/* Sticky headings inside the shell sit under the sticky top bar on phones and tablets */
@media (max-width: 59.99rem) { .app-main .gloss-letter { top: 3.3rem; } }
