/* =====================================================================
   Calendario de clase — estilos
   ===================================================================== */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1b1a17;
  --ink-2: #45433d;
  --muted: #77746b;
  --line: #e5e1d7;
  --line-2: #efece4;
  --accent: #2f45c5;
  --accent-ink: #ffffff;
  --accent-soft: #e9ecfb;
  --danger: #c0392b;

  --exam: #d1453b;      --exam-soft: #fbe9e7;
  --assignment: #c47c0e; --assignment-soft: #fbf1df;
  --tutoring: #12806f;  --tutoring-soft: #e2f3ef;
  --class: #5b6478;     --class-soft: #eceef3;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(27 26 23 / .05), 0 8px 24px -12px rgb(27 26 23 / .18);
  --shadow-lg: 0 24px 60px -20px rgb(27 26 23 / .35);
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1c1a; --surface-2: #191917; --ink: #f1efe9; --ink-2: #cfccc3;
    --muted: #9a968b; --line: #2f2d29; --line-2: #262522; --accent: #8a9bff; --accent-ink: #10132b;
    --accent-soft: #23284a; --danger: #ff7a6b;
    --exam: #ff7f72; --exam-soft: #3a211e; --assignment: #f0b450; --assignment-soft: #382c17;
    --tutoring: #4fd1b8; --tutoring-soft: #16302b;
    --class: #a3abc0; --class-soft: #262a33;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px -12px rgb(0 0 0 / .6);
    --shadow-lg: 0 24px 60px -20px rgb(0 0 0 / .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1d1c1a; --surface-2: #191917; --ink: #f1efe9; --ink-2: #cfccc3;
  --muted: #9a968b; --line: #2f2d29; --line-2: #262522; --accent: #8a9bff; --accent-ink: #10132b;
  --accent-soft: #23284a; --danger: #ff7a6b;
  --exam: #ff7f72; --exam-soft: #3a211e; --assignment: #f0b450; --assignment-soft: #382c17;
  --tutoring: #4fd1b8; --tutoring-soft: #16302b;
  --class: #a3abc0; --class-soft: #262a33;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px -12px rgb(0 0 0 / .6);
  --shadow-lg: 0 24px 60px -20px rgb(0 0 0 / .8);
  color-scheme: dark;
}

.t-exam { --t: var(--exam); --t-soft: var(--exam-soft); }
.t-assignment { --t: var(--assignment); --t-soft: var(--assignment-soft); }
.t-tutoring { --t: var(--tutoring); --t-soft: var(--tutoring-soft); }
.t-class { --t: var(--class); --t-soft: var(--class-soft); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font: 500 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd {
  font: 600 11px var(--font); padding: 1px 6px; border-radius: 5px; margin-left: auto;
  background: rgb(255 255 255 / .18); border: 1px solid rgb(255 255 255 / .25);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 650; letter-spacing: -.005em; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgb(0 0 0 / .08), inset 0 1px 0 rgb(255 255 255 / .12); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--line), var(--ink) 15%); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: 1px solid transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; font-size: 14px; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 14px; }
.form h2 { margin: 0 0 2px; font: 600 26px/1.15 var(--display); letter-spacing: -.01em; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.field > span em { font-style: normal; font-weight: 500; color: var(--muted); }
.field small { color: var(--muted); font-size: 12.5px; }
.field input, .field select, .field textarea, .copy-row input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
.field input:disabled { opacity: .7; }
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.form-msg { margin: 0; min-height: 0; font-size: 14px; font-weight: 600; }
.form-msg:empty { display: none; }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: var(--tutoring); }

.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span {
  position: relative; width: 34px; height: 20px; border-radius: 20px; background: var(--line); flex: none;
  transition: background .15s;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .18s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.inline { height: 42px; }

.type-picker { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type-picker label { position: relative; cursor: pointer; }
.type-picker input { position: absolute; opacity: 0; }
.type-picker span {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 8px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 650; font-size: 14px; text-align: center; transition: all .15s;
}
.type-picker span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--t); flex: none; }
.type-picker input:checked + span { border-color: var(--t); background: var(--t-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--t); }
.type-picker input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Carga ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot-error { max-width: 420px; text-align: center; padding: 24px; }

/* ---------- Acceso ---------- */
.auth { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  --neon-pink: #ff4fd8; --neon-cyan: #3ef0ff; --neon-yellow: #ffd23f; --neon-red: #ff5a6e;
  --px: "Press Start 2P", ui-monospace, monospace;
  position: relative; overflow: hidden; isolation: isolate;
  padding: 40px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background: radial-gradient(900px 420px at 50% 100%, #3a1460 0%, transparent 70%), linear-gradient(180deg, #07061a 0%, #120b33 55%, #1c0f45 100%);
  color: #eef0ff;
}
/* Estrellas de píxel */
.px-stars, .px-stars::after { position: absolute; inset: 0; z-index: -3; pointer-events: none; }
.px-stars {
  background-image:
    linear-gradient(#fff, #fff), linear-gradient(#fff, #fff), linear-gradient(#b8c1ff, #b8c1ff), linear-gradient(#fff, #fff),
    linear-gradient(#3ef0ff, #3ef0ff), linear-gradient(#fff, #fff), linear-gradient(#ff4fd8, #ff4fd8), linear-gradient(#fff, #fff),
    linear-gradient(#fff, #fff), linear-gradient(#b8c1ff, #b8c1ff), linear-gradient(#fff, #fff), linear-gradient(#ffd23f, #ffd23f);
  background-size: 2px 2px, 2px 2px, 3px 3px, 2px 2px, 2px 2px, 3px 3px, 2px 2px, 2px 2px, 3px 3px, 2px 2px, 2px 2px, 2px 2px;
  background-position: 8% 12%, 22% 30%, 37% 8%, 51% 22%, 64% 14%, 78% 34%, 90% 9%, 14% 46%, 70% 48%, 44% 40%, 96% 26%, 30% 54%;
  background-repeat: no-repeat; opacity: .85;
}
.px-stars::after {
  content: "";
  background-image: linear-gradient(#fff, #fff), linear-gradient(#fff, #fff), linear-gradient(#3ef0ff, #3ef0ff), linear-gradient(#fff, #fff), linear-gradient(#ff4fd8, #ff4fd8), linear-gradient(#fff, #fff);
  background-size: 2px 2px, 3px 3px, 2px 2px, 2px 2px, 2px 2px, 3px 3px;
  background-position: 4% 24%, 28% 16%, 58% 6%, 84% 18%, 48% 30%, 18% 4%;
  background-repeat: no-repeat; animation: twinkle 2.4s steps(2) infinite;
}
@keyframes twinkle { 50% { opacity: .15; } }
/* Horizonte y suelo de neón */
.px-horizon { position: absolute; left: 0; right: 0; bottom: 38%; height: 2px; z-index: -2; background: var(--neon-pink); box-shadow: 0 0 18px 4px rgb(255 79 216 / .55), 0 0 60px 12px rgb(255 79 216 / .25); }
.px-floor {
  position: absolute; left: -50%; right: -50%; bottom: 0; height: 38%; z-index: -2;
  background-image: linear-gradient(rgb(255 79 216 / .55) 2px, transparent 2px), linear-gradient(90deg, rgb(62 240 255 / .38) 2px, transparent 2px);
  background-size: 56px 40px; transform: perspective(260px) rotateX(58deg); transform-origin: top;
  mask-image: linear-gradient(to bottom, transparent 0%, #000 45%); -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 45%);
  animation: floor 1.6s linear infinite;
}
@keyframes floor { to { background-position: 0 40px, 0 0; } }
.px-scan { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: repeating-linear-gradient(0deg, rgb(0 0 0 / .22) 0 1px, transparent 1px 3px); mix-blend-mode: multiply; }

.px-label { font: 400 10px/1.6 var(--px); letter-spacing: .08em; text-transform: uppercase; margin: 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 750; letter-spacing: -.01em; position: relative; z-index: 1; }
.px-mark { display: grid; place-items: center; width: 40px; height: 40px; background: #1d1450; color: var(--neon-cyan); --pad-hole: #1d1450;
  box-shadow: 0 -3px 0 0 #3a2b8a, 0 3px 0 0 #0b0826, -3px 0 0 0 #3a2b8a, 3px 0 0 0 #0b0826; }
.px-mark svg { width: 26px; height: 26px; }

.auth-hero { position: relative; z-index: 1; max-width: 560px; }
.auth-hero .px-label { color: var(--neon-yellow); margin-bottom: 20px; }
.px-blink-cursor::after { content: "_"; animation: blink 1s steps(2) infinite; margin-left: 4px; }
.auth-hero h1 {
  font: 400 clamp(22px, 2.55vw, 36px)/1.45 var(--px); letter-spacing: -.01em; margin: 0 0 22px;
  text-shadow: 3px 3px 0 #2a1170;
}
.auth-hero h1 em {
  font-style: normal; color: var(--neon-pink);
  text-shadow: 3px 3px 0 #2a1170, 0 0 18px rgb(255 79 216 / .55);
}
.auth-hero > p:last-child { margin: 0; font-size: 17px; color: rgb(238 240 255 / .78); max-width: 470px; }

/* Registro de misiones con borde pixelado */
.quest-log {
  position: relative; z-index: 1; max-width: 470px; display: grid; gap: 8px; padding: 16px; margin: 4px;
  background: rgb(10 8 32 / .82);
  box-shadow: 0 -4px 0 0 var(--neon-cyan), 0 4px 0 0 var(--neon-cyan), -4px 0 0 0 var(--neon-cyan), 4px 0 0 0 var(--neon-cyan), 0 0 40px rgb(62 240 255 / .18);
}
.ql-head { display: flex; align-items: center; justify-content: space-between; color: var(--neon-cyan); margin-bottom: 4px; }
.px-hearts { display: flex; gap: 6px; }
.px-hearts i { width: 14px; height: 12px; background: var(--neon-red);
  clip-path: polygon(0 14%, 14% 0, 43% 0, 50% 14%, 57% 0, 86% 0, 100% 14%, 100% 43%, 86% 57%, 71% 71%, 57% 86%, 50% 100%, 43% 86%, 29% 71%, 14% 57%, 0 43%); }
.px-hearts i:last-child { opacity: .3; }
.quest { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; align-items: center; padding: 9px 10px; background: rgb(255 255 255 / .04); border-left: 4px solid var(--q); }
.q-boss { --q: var(--neon-red); } .q-mission { --q: var(--neon-yellow); } .q-save { --q: var(--neon-cyan); }
.q-tag { font: 400 8px/1 var(--px); padding: 6px 0; text-align: center; background: var(--q); color: #0b0826; }
.q-main { min-width: 0; }
.q-main strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-main small { color: rgb(238 240 255 / .6); font-size: 12.5px; }
.q-time { font: 400 9px var(--px); color: var(--q); white-space: nowrap; }
.xp { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: 6px; color: var(--neon-yellow); }
.xp-bar { height: 12px; background: #1d1450; box-shadow: 0 0 0 2px #3a2b8a; position: relative; overflow: hidden; }
.xp-bar i { position: absolute; inset: 0 auto 0 0; width: 42%; background: repeating-linear-gradient(90deg, var(--neon-yellow) 0 10px, transparent 10px 12px); animation: xp 1.6s steps(12) both .3s; }
@keyframes xp { from { width: 0; } }
.press-start { position: relative; z-index: 1; color: rgb(238 240 255 / .85); animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Panel del formulario */
.auth-panel {
  background-image: linear-gradient(var(--line-2) 1px, transparent 1px), linear-gradient(90deg, var(--line-2) 1px, transparent 1px);
  background-size: 24px 24px; background-position: center;
}
.auth-card { background: var(--surface); padding: 28px; border-radius: 18px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.auth-sub { margin: -8px 0 4px; font-size: 14px; }
.auth .btn-primary { box-shadow: 0 4px 0 color-mix(in srgb, var(--accent), #000 40%); transition: transform .05s, box-shadow .05s, filter .15s; }
.auth .btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent), #000 40%); }

.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: min(420px, 100%); display: grid; gap: 22px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--line-2); border: 1px solid var(--line); }
.tabs button { flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; font-weight: 650; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- App ---------- */
.app { display: grid; grid-template-columns: 284px 1fr; min-height: 100%; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 22px; padding: 20px 18px;
  border-right: 1px solid var(--line); background: var(--surface-2);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand strong { display: block; font-size: 15.5px; letter-spacing: -.01em; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 12.5px; }
.brand > div { min-width: 0; flex: 1; }
.brand strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); flex: none; }
.sidebar-close, .scrim { display: none; }

.side-section h3 { margin: 0 0 10px; font-size: 11.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.upcoming { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.upcoming li button {
  width: 100%; display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; text-align: left;
  padding: 7px 8px; border: 0; border-radius: 10px; background: transparent;
}
.upcoming li button:hover { background: var(--line-2); }
.up-date { display: grid; place-items: center; height: 40px; border-radius: 9px; background: var(--t-soft); color: var(--t); font-size: 10px; font-weight: 750; text-transform: uppercase; line-height: 1; letter-spacing: .04em; }
.up-date b { font: 600 17px var(--display); letter-spacing: 0; }
.up-text { min-width: 0; }
.up-text strong { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-text small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-empty { color: var(--muted); font-size: 13.5px; padding: 6px 2px; }

.filters { display: grid; gap: 2px; }
.filter {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink-2); user-select: none;
}
.filter:hover { background: var(--line-2); }
.filter input { position: absolute; opacity: 0; pointer-events: none; }
.filter .box {
  width: 18px; height: 18px; border-radius: 6px; border: 2px solid var(--c); display: grid; place-items: center; flex: none;
  transition: background .12s;
}
.filter .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.filter input:checked + .box { background: var(--c); }
.filter input:checked + .box svg { opacity: 1; }
.filter input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.filter-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side-footer { margin-top: auto; display: flex; align-items: center; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.user-chip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border: 0; border-radius: 12px; background: transparent; text-align: left; }
.user-chip:hover { background: var(--line-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 13px; flex: none; }
.user-meta { min-width: 0; }
.user-meta strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { color: var(--muted); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; padding: 18px 28px 28px; gap: 18px; }

.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.menu-btn { display: none; }
.nav { display: flex; align-items: center; gap: 4px; }
.topbar h1 { margin: 0 auto 0 6px; font: 600 28px/1.1 var(--display); letter-spacing: -.02em; }
.topbar h1 span { color: var(--muted); font-weight: 500; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); width: 220px; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink); }
.seg { display: flex; padding: 3px; border-radius: 11px; background: var(--line-2); border: 1px solid var(--line); }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; font-weight: 650; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Resumen */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  display: grid; gap: 4px; align-content: start; text-align: left; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; min-width: 0;
}
button.stat:hover { border-color: color-mix(in srgb, var(--line), var(--ink) 18%); }
.stat::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--t, var(--accent)); }
.stat-label { font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat-value { font: 600 24px/1.15 var(--display); letter-spacing: -.015em; }
.stat-value small { font: 600 14px var(--font); color: var(--muted); letter-spacing: 0; }
.stat-sub { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Vista mes */
.month { flex: 1; display: flex; flex-direction: column; min-height: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.month-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.month-head div { padding: 10px 12px; font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.month-grid { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(112px, 1fr); }
.day {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px 6px 8px; min-width: 0;
  border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); cursor: pointer;
}
.day:nth-child(7n) { border-right: 0; }
.day.weekend { background: color-mix(in srgb, var(--surface-2), var(--bg) 35%); }
.day.out { background: var(--surface-2); }
.day.out .day-num { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.day:hover { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.day-top { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.day-num { display: grid; place-items: center; min-width: 28px; height: 28px; border-radius: 50%; font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.day.today .day-num { background: var(--accent); color: var(--accent-ink); }
.day-add { opacity: 0; width: 26px; height: 26px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.day-add svg { width: 15px; height: 15px; }
.day:hover .day-add, .day-add:focus-visible { opacity: 1; }
.day-add:hover { background: var(--line-2); color: var(--ink); }
.chips { display: grid; gap: 3px; min-width: 0; }
.chip {
  display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; padding: 3px 7px 3px 6px; border: 0; text-align: left;
  border-radius: 7px; background: var(--t-soft); color: var(--ink); font-size: 12.5px; font-weight: 650; line-height: 1.35;
  box-shadow: inset 3px 0 0 var(--t);
}
.chip:hover { filter: brightness(.97); box-shadow: inset 3px 0 0 var(--t), 0 0 0 1px var(--t); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; margin-left: 2px; }
.chip-time { color: var(--t); font-variant-numeric: tabular-nums; flex: none; font-size: 11.5px; }
.chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.done .chip-title { text-decoration: line-through; opacity: .55; }
.more { border: 0; background: none; text-align: left; padding: 1px 7px; font-size: 12px; font-weight: 700; color: var(--muted); border-radius: 6px; }
.more:hover { color: var(--ink); background: var(--line-2); }
.day-dots { display: none; }

/* Vista agenda */
.agenda { display: grid; gap: 18px; }
.agenda-day { display: grid; grid-template-columns: 120px 1fr; gap: 18px; scroll-margin-top: 20px; }
.agenda-date { padding-top: 10px; position: sticky; top: 12px; align-self: start; }
.agenda-date .dnum { font: 600 32px/1 var(--display); letter-spacing: -.02em; }
.agenda-date .dname { font-size: 13px; font-weight: 700; color: var(--ink-2); text-transform: capitalize; }
.agenda-date .drel { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.agenda-day.is-today .dnum { color: var(--accent); }
.agenda-day.past { opacity: .55; }
.agenda-list { display: grid; gap: 8px; }
.item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: inset 4px 0 0 var(--t); cursor: pointer;
}
.item:hover { border-color: color-mix(in srgb, var(--t) 45%, var(--line)); }
.item-time { width: 74px; font-size: 13px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; line-height: 1.3; }
.item-time small { display: block; color: var(--muted); font-weight: 600; }
.item-main { min-width: 0; }
.item-title { font-weight: 750; font-size: 15px; letter-spacing: -.005em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item.done .item-title > span:first-child { text-decoration: line-through; opacity: .55; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.item-meta span { display: inline-flex; align-items: center; gap: 5px; }
.item-meta svg { width: 14px; height: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 750; letter-spacing: .02em; background: var(--t-soft); color: var(--t);
}
.subject-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; color: var(--ink-2); }
.subject-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.check-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 9px; font-size: 13px; font-weight: 700;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
}
.check-btn .tick { width: 16px; height: 16px; border-radius: 5px; border: 2px solid var(--line); display: grid; place-items: center; }
.check-btn .tick svg { width: 11px; height: 11px; opacity: 0; color: #fff; }
.check-btn.on { border-color: color-mix(in srgb, var(--tutoring) 40%, transparent); color: var(--tutoring); background: var(--tutoring-soft); }
.check-btn.on .tick { background: var(--tutoring); border-color: var(--tutoring); }
.check-btn.on .tick svg { opacity: 1; }

.empty { display: grid; place-items: center; text-align: center; gap: 8px; padding: 64px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); background: var(--surface); }
.empty strong { color: var(--ink); font: 600 20px var(--display); }

/* ---------- Diálogos ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line);
  border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
.dialog-wide { width: min(760px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgb(15 14 12 / .45); backdrop-filter: blur(2px); }
.dialog[open] { animation: pop .18s ease-out; display: flex; flex-direction: column; }
.dialog > form { display: flex; flex-direction: column; min-height: 0; gap: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.dialog-head h2 { margin: 0; font: 600 22px var(--display); letter-spacing: -.01em; }
.dialog-body { padding: 12px 20px 18px; overflow-y: auto; display: grid; gap: 14px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 18px 18px; }
.dialog-foot .btn-danger-ghost { margin-right: auto; }
.tabs-inline { margin: 8px 20px 0; }

.detail-head { padding: 20px 20px 0; display: grid; gap: 10px; }
.detail-top { display: flex; align-items: center; gap: 10px; }
.detail-top .icon-btn { margin-left: auto; }
.detail-head h2 { margin: 0; font: 600 26px/1.15 var(--display); letter-spacing: -.015em; overflow-wrap: anywhere; }
.countdown { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--t); font-size: 14px; }
.detail-list { display: grid; gap: 12px; margin: 0; padding: 18px 20px; }
.detail-list div { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; }
.detail-list svg { color: var(--muted); margin-top: 2px; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.detail-list dd small { display: block; color: var(--muted); }
.detail-desc { margin: 0 20px 18px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 500; color: var(--ink-2); }
.detail-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 18px 18px; }
.detail-foot .spacer { flex: 1; }

.callout { padding: 16px; border-radius: 14px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent); display: grid; gap: 10px; }
.callout h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 15px; }
.callout p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface); }
.callout-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Admin */
.admin-list { display: grid; gap: 8px; }
.admin-row { display: grid; grid-template-columns: 42px 1fr 1fr auto; gap: 8px; align-items: center; }
.admin-row input[type="color"] { width: 42px; height: 42px; padding: 3px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.admin-row input[type="text"] { min-height: 42px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); width: 100%; min-width: 0; }
.admin-row .actions { display: flex; gap: 4px; }
.user-row { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line-2); }
.user-row:last-child { border-bottom: 0; }
.user-row strong { display: block; font-size: 14px; }
.user-row small { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.user-row select { height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 8px; }
.section-note { margin: 0; font-size: 13.5px; color: var(--muted); }

/* ---------- Horario y clases ---------- */
#today-btn.is-today { color: var(--muted); }
.hol-label {
  font-size: 10.5px; font-weight: 750; color: var(--muted); background: var(--line-2); border-radius: 5px;
  padding: 2px 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.day.holiday { background-image: repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in srgb, var(--line) 45%, transparent) 8px 9px); }
.day-top { gap: 4px; }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent); font-size: 14px; color: var(--ink-2);
}
.banner svg { color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 750;
  background: var(--line-2); color: var(--ink-2); width: fit-content; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pill-changed, .pill-moved-in { background: var(--assignment-soft); color: var(--assignment); }
.pill-cancelled, .pill-moved { background: var(--exam-soft); color: var(--exam); }
.pill-holiday { background: var(--line-2); color: var(--muted); }
.pill-now { background: var(--tutoring-soft); color: var(--tutoring); }

/* Vista Día */
.dayview { display: grid; gap: 14px; }
.day-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.day-side { display: grid; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 16px 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
.panel-head h2 { margin: 0; font: 600 19px var(--display); letter-spacing: -.01em; }
.panel-head .muted { font-size: 13px; font-weight: 600; }
.panel-empty { padding: 22px 8px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.panel .item { box-shadow: inset 4px 0 0 var(--t); }

.class-list { display: grid; gap: 6px; }
.class-row {
  display: grid; grid-template-columns: 58px 4px 1fr auto; gap: 12px; align-items: center; text-align: left; width: 100%;
  padding: 12px 12px 12px 8px; border-radius: 12px; border: 1px solid transparent; background: transparent;
}
.class-row:hover { background: var(--surface-2); border-color: var(--line-2); }
.cr-time { display: grid; justify-items: end; font-variant-numeric: tabular-nums; line-height: 1.25; }
.cr-time b { font-size: 15px; }
.cr-time small { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.cr-bar { align-self: stretch; border-radius: 4px; background: var(--c); min-height: 38px; }
.cr-main { display: grid; gap: 3px; min-width: 0; }
.cr-main strong { font-size: 15.5px; letter-spacing: -.005em; }
.cr-main small { color: var(--muted); font-size: 13px; }
.cr-note { font-style: italic; }
.class-row.past { opacity: .5; }
.class-row.running { background: color-mix(in srgb, var(--c) 9%, var(--surface)); border-color: color-mix(in srgb, var(--c) 35%, transparent); }
.class-row.st-cancelled .cr-main strong, .class-row.st-holiday .cr-main strong, .class-row.st-moved .cr-main strong,
.class-row.st-cancelled .cr-time, .class-row.st-holiday .cr-time, .class-row.st-moved .cr-time { text-decoration: line-through; opacity: .6; }
.class-row.st-cancelled .cr-bar, .class-row.st-holiday .cr-bar, .class-row.st-moved .cr-bar { opacity: .35; }
.now-tag, .next-tag { font-size: 11.5px; font-weight: 800; padding: 4px 9px; border-radius: 20px; white-space: nowrap; }
.now-tag { background: var(--c); color: #fff; }
.next-tag { background: var(--line-2); color: var(--ink-2); }
.strike-if-cancelled, .strike-if-moved, .strike-if-holiday { text-decoration: line-through; }
.subject-title { display: flex; align-items: center; gap: 10px; }
.subject-title::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--c); flex: none; }

/* Vista Semana */
.weekview { display: grid; gap: 14px; }
.week-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.week { min-width: 640px; }
.wrow { display: grid; }
.wheads { position: sticky; top: 0; z-index: 3; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.whead {
  display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 10px 4px; border: 0; background: transparent;
  font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-left: 1px solid var(--line-2);
}
.whead b { font: 600 20px var(--display); color: var(--ink); letter-spacing: 0; text-transform: none; }
.whead:hover b { color: var(--accent); }
.whead.today b { background: var(--accent); color: var(--accent-ink); border-radius: 50%; width: 32px; height: 32px; display: inline-grid; place-items: center; font-size: 17px; }
.wtops { border-bottom: 1px solid var(--line); }
.wlabel { font-size: 9.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 4px; text-align: center; }
.wtop { display: grid; gap: 3px; align-content: start; padding: 6px 4px; border-left: 1px solid var(--line-2); min-width: 0; }
.wbody { position: relative; }
.wrail { border-right: 1px solid var(--line-2); }
.wh { position: relative; }
.wh span { position: absolute; top: -8px; right: 8px; font-size: 11px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--surface); padding: 0 2px; }
.wh:first-child span { top: 4px; }
.wcol {
  position: relative; border-left: 1px solid var(--line-2);
  background-image: linear-gradient(var(--line-2) 1px, transparent 1px); background-size: 100% 56px;
}
.wcol.today { background-color: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.wcol.holiday { background-image: repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in srgb, var(--line) 50%, transparent) 8px 9px); }
.wblock {
  position: absolute; display: flex; flex-direction: column; gap: 1px; overflow: hidden; text-align: left;
  padding: 5px 7px; border-radius: 8px; border: 0; font-size: 12px; line-height: 1.25; min-width: 0;
}
.wblock strong { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wblock small { font-size: 11px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wclass { background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: var(--ink); box-shadow: inset 3px 0 0 var(--c); }
.wclass:hover { background: color-mix(in srgb, var(--c) 24%, var(--surface)); }
.wclass.st-cancelled, .wclass.st-holiday, .wclass.st-moved { opacity: .5; background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--line-2) 6px 12px); }
.wclass.st-cancelled strong, .wclass.st-holiday strong, .wclass.st-moved strong { text-decoration: line-through; }
.wclass.st-changed, .wclass.st-moved-in { box-shadow: inset 3px 0 0 var(--c), inset 0 0 0 1.5px var(--assignment); }
.wevent { background: var(--t-soft); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--t); z-index: 1; }
.wtag { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--t, var(--assignment)); }
.wclass .wtag { color: var(--assignment); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--exam); z-index: 2; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--exam); }

/* Cambio puntual */
.dialog-sub { margin: 2px 0 0; font-size: 14px; font-weight: 600; }
.mode-picker { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.mode-picker label { position: relative; cursor: pointer; }
.mode-picker input { position: absolute; opacity: 0; }
.mode-picker span { display: grid; gap: 1px; padding: 11px 14px 11px 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); position: relative; }
.mode-picker span::before { content: ""; position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); }
.mode-picker small { color: var(--muted); font-size: 13px; }
.mode-picker input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.mode-picker input:checked + span::before { border: 5px solid var(--accent); }
.mode-picker input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Administración: asignaturas, horario y cuatrimestres */
.admin-toolbar { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; }
.inline-field { min-width: 240px; }
.subject-cards { display: grid; gap: 12px; }
.subject-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface); box-shadow: inset 4px 0 0 var(--c, var(--line)); display: grid; gap: 10px; }
.subject-card.new-card { border-style: dashed; box-shadow: none; background: var(--surface-2); }
.subject-form { display: grid; grid-template-columns: 42px minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.slots { display: grid; gap: 6px; padding-left: 12px; }
.slots-head { font-size: 11.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.slot-row { display: grid; grid-template-columns: minmax(0, 1.1fr) 112px 112px minmax(0, 1fr) minmax(0, 1fr) 112px; gap: 6px; align-items: center; }
.range-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 160px 160px 170px; gap: 8px; align-items: center; margin-bottom: 6px; }
.range-head { display: grid; grid-template-columns: minmax(0, 1.4fr) 160px 160px 170px; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 2px 4px; }
:is(.subject-form, .slot-row, .range-row) :is(input:not([type="color"]), select) {
  min-height: 38px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); width: 100%; min-width: 0; outline: none;
}
:is(.subject-form, .slot-row, .range-row) :is(input, select):focus { border-color: var(--accent); background: var(--surface); }
.subject-form input[type="color"] { width: 42px; height: 38px; padding: 3px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
:is(.subject-form, .slot-row, .range-row) .actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.admin-section { display: grid; gap: 8px; }
.admin-section + .admin-section { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.admin-section h3 { margin: 0; font: 600 18px var(--display); }
.callout-plain { background: var(--surface-2); border-color: var(--line); margin-top: 8px; }
.callout-plain svg { color: var(--accent); }

/* Toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 650; font-size: 14px; box-shadow: var(--shadow-lg); animation: toast .2s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast { from { opacity: 0; transform: translateY(8px); } }

.fab { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search { width: 180px; }
  .day-layout { grid-template-columns: 1fr; }
  .subject-form { grid-template-columns: 42px minmax(0, 1fr) minmax(0, 1fr); }
  .subject-form select, .subject-form .actions { grid-column: span 1; }
  .subject-form .actions { grid-column: 2 / -1; }
  .slot-row { grid-template-columns: minmax(0, 1fr) 112px 112px; }
  .slot-row .actions { grid-column: 3; }
}
@media (min-width: 1181px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); z-index: 40; transform: translateX(-102%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .app.menu-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgb(15 14 12 / .4); z-index: 39; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.menu-open .scrim { opacity: 1; pointer-events: auto; }
  .sidebar-close, .menu-btn { display: inline-grid; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 24px 40px; gap: 22px; }
  .quest-log, .press-start, .px-floor, .px-horizon { display: none; }
  .auth-hero h1 { font-size: 21px; }
  .auth-hero > p:last-child { font-size: 15px; }
  .auth-panel { padding: 24px 14px 40px; }
  .auth-card { padding: 22px; }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .main { padding: 12px 12px 96px; gap: 14px; }
  .topbar { gap: 6px; }
  .topbar h1 { font-size: 22px; order: 2; flex: 1; margin: 0 4px; }
  .nav { order: 3; }
  .nav .btn { padding: 0 10px; }
  .menu-btn { order: 1; }
  .seg { order: 4; flex: 1 1 100%; }
  .seg button { flex: 1; padding: 0 6px; }
  .search { order: 5; width: auto; flex: 1 1 100%; }
  .class-row { grid-template-columns: 50px 4px 1fr; padding: 10px 8px 10px 4px; }
  .class-row .now-tag, .class-row .next-tag { grid-column: 3; justify-self: start; }
  .panel { padding: 4px 12px 12px; }
  .week { min-width: 560px; }
  .wblock { padding: 4px 5px; }
  .wblock small { display: none; }
  .range-row, .range-head { grid-template-columns: 1fr 1fr; }
  .range-row input[name="name"] { grid-column: 1 / -1; }
  .range-head span:first-child { display: none; }
  .range-row .actions { grid-column: 1 / -1; }
  .slot-row { grid-template-columns: 1fr 1fr; }
  .slot-row select { grid-column: 1 / -1; }
  .slot-row .actions { grid-column: 1 / -1; }
  .subject-form { grid-template-columns: 42px 1fr; }
  .subject-form > :is(input[name="teacher"], select, .actions) { grid-column: 1 / -1; }
  .slots { padding-left: 0; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 11px 12px; }
  .stat-value { font-size: 19px; }
  .month { min-height: 0; }
  .month-head div { padding: 8px 0; text-align: center; font-size: 10.5px; }
  .month-grid { grid-auto-rows: minmax(62px, 1fr); }
  .day { padding: 4px 2px; align-items: center; }
  .day-add, .chips { display: none; }
  .day-top { justify-content: center; }
  .day-num { min-width: 26px; height: 26px; font-size: 13px; }
  .day-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 100%; }
  .day-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--t); }
  .agenda-day { grid-template-columns: 1fr; gap: 8px; }
  .agenda-date { position: static; display: flex; align-items: baseline; gap: 10px; padding-top: 0; }
  .agenda-date .dnum { font-size: 24px; }
  .item { grid-template-columns: 1fr auto; padding: 12px 14px; }
  .item-time { width: auto; grid-column: 1 / -1; display: flex; gap: 8px; }
  .item-time small { display: inline; }
  .row { grid-template-columns: 1fr; }
  .type-picker span { font-size: 13px; }
  .admin-row { grid-template-columns: 42px 1fr auto; }
  .admin-row .teacher { grid-column: 2 / 3; }
  .user-row { grid-template-columns: 34px 1fr; }
  .user-row select, .user-row .icon-btn { grid-column: 2; justify-self: start; }
  .fab {
    display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30;
    width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-lg);
  }
  .fab svg { width: 24px; height: 24px; }
  .dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .dialog-foot, .detail-foot { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

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

@media print {
  .sidebar, .topbar .nav, .search, .seg, .stats, .fab, .day-add { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .month { box-shadow: none; }
}
