/* Base: fuentes, variables de diseño y componentes compartidos. */

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/geist-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/geist-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/instrument-serif-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/instrument-serif-latin-400-italic.woff2') format('woff2');
}

:root {
  --font-ui: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;

  --ink: #0d0a08;
  --text: #f6efe6;
  --text-2: rgba(246, 239, 230, 0.72);
  --text-3: rgba(246, 239, 230, 0.5);

  /* Cristal: oscuro y cálido, deja ver el fondo desenfocado */
  --glass: rgba(30, 22, 16, 0.42);
  --glass-strong: rgba(22, 16, 12, 0.86);
  --fill: rgba(255, 240, 222, 0.06);
  --fill-2: rgba(255, 240, 222, 0.1);
  --fill-3: rgba(255, 240, 222, 0.16);
  --line: rgba(255, 236, 214, 0.11);
  --line-2: rgba(255, 236, 214, 0.2);
  --blur: 26px;

  --ok: #5fd39a;
  --warn: #ffb057;
  --danger: #ff7d6e;

  --r-xl: 26px;
  --r-l: 20px;
  --r-m: 13px;
  --r-s: 9px;

  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(0.22, 0.8, 0.26, 1);

  /* Acento (ámbar por defecto) */
  --accent: #f5a54a;
  --accent-2: #ffd9a0;
  --accent-3: #c96f1f;
  --accent-ink: #2a1602;
  --accent-soft: rgba(245, 165, 74, 0.16);
  color-scheme: dark;
}
[data-accent='rose'] { --accent: #f2788a; --accent-2: #ffc4cb; --accent-3: #c2475c; --accent-ink: #2c060d; --accent-soft: rgba(242, 120, 138, 0.16); }
[data-accent='teal'] { --accent: #3fc6c0; --accent-2: #b4f0e8; --accent-3: #1f8d8c; --accent-ink: #021f1e; --accent-soft: rgba(63, 198, 192, 0.16); }
[data-accent='violet'] { --accent: #a98bf5; --accent-2: #dccfff; --accent-3: #7355c9; --accent-ink: #150a33; --accent-soft: rgba(169, 139, 245, 0.18); }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 400 14px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
h1, h2, h3, p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: rgba(255, 236, 214, 0.22) transparent; }

/* ---------- Fondo ---------- */
#backdrop {
  position: fixed; inset: 0; z-index: 0;
  background: #17110d center / cover no-repeat;
  transition: opacity 0.5s var(--ease);
}
#backdrop::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(13, 10, 8, 0.16), rgba(13, 10, 8, 0.4)); }
#backdrop[data-bg='none'] { background: var(--ink); }
#backdrop[data-bg='none']::after { display: none; }
#backdrop[data-bg='estudio'], .choice-thumb[data-bg='estudio'] { background-image: url('/img/bg-estudio.svg'); }
#backdrop[data-bg='atardecer'], .choice-thumb[data-bg='atardecer'] {
  background-image:
    radial-gradient(60% 55% at 18% 18%, rgba(255, 170, 110, 0.75), transparent 70%),
    radial-gradient(55% 60% at 85% 30%, rgba(214, 84, 110, 0.7), transparent 70%),
    radial-gradient(70% 60% at 55% 100%, rgba(94, 44, 92, 0.9), transparent 75%),
    linear-gradient(160deg, #3a1d1a, #1a0f18);
}
#backdrop[data-bg='aurora'], .choice-thumb[data-bg='aurora'] {
  background-image:
    radial-gradient(55% 60% at 15% 25%, rgba(46, 196, 170, 0.6), transparent 70%),
    radial-gradient(50% 55% at 80% 15%, rgba(96, 110, 232, 0.6), transparent 70%),
    radial-gradient(70% 60% at 60% 100%, rgba(22, 92, 110, 0.85), transparent 75%),
    linear-gradient(160deg, #0d2026, #0b1020);
}
#backdrop[data-bg='grafito'], .choice-thumb[data-bg='grafito'] {
  background-image:
    radial-gradient(60% 55% at 20% 10%, rgba(255, 255, 255, 0.16), transparent 70%),
    radial-gradient(60% 60% at 90% 90%, rgba(255, 255, 255, 0.08), transparent 70%),
    linear-gradient(160deg, #2b2a2a, #121212);
}

#app { position: relative; z-index: 1; height: 100%; }
.noscript { position: relative; z-index: 2; padding: 2rem; }
#layer { position: relative; z-index: 50; }

/* ---------- Cristal ---------- */
.glass, .glass-solid, .glass-accent {
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 244, 230, 0.07), var(--shadow);
}
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(135%);
  backdrop-filter: blur(var(--blur)) saturate(135%);
}
.glass-solid {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(34px) saturate(140%);
  backdrop-filter: blur(34px) saturate(140%);
  border-color: var(--line-2);
}
.glass-accent {
  background: linear-gradient(150deg, color-mix(in srgb, var(--accent) 62%, transparent), color-mix(in srgb, var(--accent-3) 34%, transparent));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border-color: color-mix(in srgb, var(--accent-2) 45%, transparent);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(26, 19, 14, 0.9); }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--fill-2); border: 1px solid var(--line);
  font-weight: 500; font-size: 13.5px; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: var(--fill-3); border-color: var(--line-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink);
  border-color: transparent; font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 8px 22px -10px var(--accent);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #fff, var(--accent-2)); border-color: transparent; }
.btn-danger { background: rgba(255, 125, 110, 0.18); border-color: rgba(255, 125, 110, 0.4); color: #ffc9c1; }
.btn-danger:hover:not(:disabled) { background: rgba(255, 125, 110, 0.3); border-color: rgba(255, 125, 110, 0.6); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { color: var(--text); }
.btn-ghost.is-on { background: var(--accent-soft); color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.btn-block { width: 100%; height: 42px; font-size: 14.5px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 10px; color: var(--text-2); transition: background 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled), .icon-btn.is-active { background: var(--fill-2); color: var(--text); }
.icon-btn.is-small { width: 28px; height: 28px; border-radius: 8px; }
.icon { flex: none; display: block; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field-help { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.field-static { padding: 9px 0; color: var(--text-2); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error, .login-error {
  padding: 9px 12px; border-radius: var(--r-s); font-size: 13px;
  background: rgba(255, 125, 110, 0.14); border: 1px solid rgba(255, 125, 110, 0.35); color: #ffc9c1;
}
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }

.input {
  width: 100%; height: 40px; padding: 0 12px;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: var(--r-s);
  transition: border-color 0.15s, background 0.15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 64px; line-height: 1.5; }
select.input { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: #1c1510; color: var(--text); }
.input::placeholder, .add-input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--line-2); }
.input:focus-visible { outline: none; border-color: var(--accent); background: rgba(0, 0, 0, 0.4); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-wrap { position: relative; }
.input-wrap > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-wrap.has-icon .input { padding-left: 36px; }
.input-wrap.has-action .input { padding-right: 40px; }
.input-action { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--text-3); }
.input-action:hover { color: var(--text); background: var(--fill); }

.check-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.switch {
  appearance: none; width: 34px; height: 20px; flex: none; margin: 0; cursor: pointer;
  border-radius: 999px; background: var(--fill-3); position: relative; transition: background 0.2s;
}
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
input[type='checkbox']:not(.switch) { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; flex: none; }

/* ---------- Piezas pequeñas ---------- */
.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 78%, #1a120c); color: #fff; font-weight: 600; letter-spacing: 0.01em;
  box-shadow: 0 0 0 2px rgba(20, 14, 10, 0.75);
}
.avatar.is-off { filter: grayscale(1); opacity: 0.6; }
.avatar.is-more { background: var(--fill-3); color: var(--text); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: -5px; }

.pill {
  display: inline-flex; align-items: center; max-width: 100%; height: 24px; padding: 0 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 26%, transparent); color: color-mix(in srgb, var(--c) 45%, #fff);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pill.is-small { height: 22px; padding: 0 8px; font-size: 11.5px; }

.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: 7px; background: var(--fill); color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip.is-quiet { background: transparent; padding: 0 2px; color: var(--text-3); }
.chip.is-ok { color: var(--ok); }
.chip.is-overdue { color: #ffc9c1; background: rgba(255, 125, 110, 0.16); }

.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--fill-2); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.is-accent { background: var(--accent-soft); color: var(--accent-2); }
.count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

.brand-mark {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 11px;
  background: linear-gradient(150deg, var(--accent-2), var(--accent) 55%, var(--accent-3)); color: var(--accent-ink);
  font: 400 22px/1 var(--font-display); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 18px -8px var(--accent);
}
.board-dot {
  display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 8px;
  background: color-mix(in srgb, var(--c) 30%, transparent); color: color-mix(in srgb, var(--c) 55%, #fff);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.board-dot.is-big { width: 42px; height: 42px; border-radius: 13px; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--fill-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { display: grid; justify-items: center; gap: 8px; padding: 44px 20px; text-align: center; }
.empty h3 { font-size: 16px; font-weight: 600; }
.empty p { max-width: 46ch; color: var(--text-2); }
.empty .btn { margin-top: 8px; }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--fill-2); color: var(--accent-2); margin-bottom: 4px; }

.swatches { display: grid; grid-template-columns: repeat(5, 28px); gap: 8px; padding: 6px; }
.swatch-btn { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--c); border: 2px solid rgba(0, 0, 0, 0.25); transition: transform 0.12s; }
.swatch-btn:hover { transform: scale(1.1); }
.swatch-btn.is-active { box-shadow: 0 0 0 2px var(--glass-strong), 0 0 0 4px var(--text); }
.swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; margin: 0 2px; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 13px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text-2); transition: background 0.15s, color 0.15s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--fill-3); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }

.select-chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); font-size: 13px; color: var(--text-3); }
.select-chip select, .select-plain { background: transparent; border: 0; height: 28px; padding: 0 6px; border-radius: 8px; color: var(--text); font-weight: 500; cursor: pointer; max-width: 190px; }
.select-chip select:hover, .select-plain:hover { background: var(--fill); }

/* ---------- Popover y menú ---------- */
.popover { position: fixed; z-index: 80; min-width: 180px; max-width: calc(100vw - 16px); max-height: min(420px, calc(100vh - 16px)); overflow: auto; padding: 6px; border-radius: var(--r-m); animation: pop 0.14s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.menu { display: grid; gap: 1px; }
.menu-title { padding: 7px 10px 5px; font-size: 12px; color: var(--text-3); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px; border-radius: 8px; text-align: left; font-size: 13.5px; color: var(--text); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--fill-2); outline: none; }
.menu-item.is-active { color: var(--accent-2); }
.menu-item.is-danger { color: #ffb3a8; }
.menu-item.is-danger:hover:not(:disabled) { background: rgba(255, 125, 110, 0.16); }
.menu-item .icon { color: var(--text-3); }
.menu-item.is-danger .icon { color: inherit; }
.menu-item.is-rich { align-items: flex-start; padding: 8px 10px; }
.menu-item.is-rich .icon { margin-top: 2px; }
.menu-item.is-rich span { display: grid; gap: 1px; }
.menu-item.is-rich strong { font-weight: 500; }
.menu-item.is-rich small { font-size: 12px; color: var(--text-3); }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--line); }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(8, 6, 4, 0.55); animation: fade 0.16s; overflow: auto; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(440px, 100%); border-radius: var(--r-l); animation: rise 0.2s var(--ease); }
.modal.is-wide { width: min(660px, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 6px 22px; }
.modal-head h2 { font-size: 17px; font-weight: 600; }
.modal-body { padding: 10px 22px 22px; }
.modal-text { color: var(--text-2); line-height: 1.55; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

/* ---------- Avisos ---------- */
#toasts { position: fixed; z-index: 90; left: 50%; bottom: 22px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: 999px; background: rgba(22, 16, 12, 0.94); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13.5px; animation: rise 0.2s var(--ease); transition: opacity 0.25s, transform 0.25s; }
.toast .icon { color: var(--ok); }
.toast.is-error { border-color: rgba(255, 125, 110, 0.5); }
.toast.is-error .icon { color: var(--danger); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
