/* Notebook v3 — tema claro/oscuro con acentos (tokens en :root) */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f2f3f7;
  --surface-3: #e8eaf1;
  --glass: rgba(255, 255, 255, 0.78);
  --border: #e3e5ed;
  --border-2: #d3d7e2;
  --text: #12141c;
  --text-2: #363c4d;
  --muted: #5f6678;
  --dim: #8a90a0;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --star: #f59e0b;
  --mark-bg: rgba(250, 204, 21, 0.38);
  --shadow-sm: 0 1px 2px rgba(18, 20, 28, 0.06), 0 1px 1px rgba(18, 20, 28, 0.03);
  --shadow: 0 8px 24px rgba(18, 20, 28, 0.08), 0 2px 6px rgba(18, 20, 28, 0.04);
  --shadow-lg: 0 24px 64px rgba(18, 20, 28, 0.18);
  --overlay: rgba(15, 18, 28, 0.38);
  --scroll: #cfd3de;

  /* acento (violeta por defecto) */
  --accent: #6b4dff;
  --accent-2: #a855f7;
  --on-accent: #ffffff;

  --accent-soft: color-mix(in oklab, var(--accent) 11%, transparent);
  --accent-soft-2: color-mix(in oklab, var(--accent) 20%, transparent);
  --accent-text: color-mix(in oklab, var(--accent) 82%, var(--text));
  --accent-grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --mine: color-mix(in oklab, var(--accent) 12%, var(--surface));
  --mine-border: color-mix(in oklab, var(--accent) 22%, var(--surface));
  --danger-soft: color-mix(in oklab, var(--danger) 11%, transparent);
  --ok-soft: color-mix(in oklab, var(--ok) 13%, transparent);
  --warn-soft: color-mix(in oklab, var(--warn) 13%, transparent);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0d12;
    --surface: #12151c;
    --surface-2: #181c25;
    --surface-3: #212633;
    --glass: rgba(18, 21, 28, 0.72);
    --border: #222734;
    --border-2: #2e3545;
    --text: #eceef5;
    --text-2: #c7ccda;
    --muted: #9399ab;
    --dim: #6b7285;
    --danger: #f87171;
    --ok: #4ade80;
    --warn: #fbbf24;
    --star: #fbbf24;
    --mark-bg: rgba(251, 191, 36, 0.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.6);
    --overlay: rgba(2, 4, 8, 0.62);
    --scroll: #2c3342;
    --accent: #c8ff2e;
    --accent-2: #a78bfa;
    --on-accent: #0b0d12;
    --mine: color-mix(in oklab, var(--accent-2) 22%, var(--surface));
    --mine-border: color-mix(in oklab, var(--accent-2) 34%, var(--surface));
    --accent-text: color-mix(in oklab, var(--accent) 85%, white);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #181c25;
  --surface-3: #212633;
  --glass: rgba(18, 21, 28, 0.72);
  --border: #222734;
  --border-2: #2e3545;
  --text: #eceef5;
  --text-2: #c7ccda;
  --muted: #9399ab;
  --dim: #6b7285;
  --danger: #f87171;
  --ok: #4ade80;
  --warn: #fbbf24;
  --star: #fbbf24;
  --mark-bg: rgba(251, 191, 36, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.6);
  --overlay: rgba(2, 4, 8, 0.62);
  --scroll: #2c3342;
  --accent: #c8ff2e;
  --accent-2: #a78bfa;
  --on-accent: #0b0d12;
  --mine: color-mix(in oklab, var(--accent-2) 22%, var(--surface));
  --mine-border: color-mix(in oklab, var(--accent-2) 34%, var(--surface));
  --accent-text: color-mix(in oklab, var(--accent) 85%, white);
}

/* acentos: por defecto la marca (violeta en claro, lima en oscuro); el resto se elige en Apariencia */
:root[data-accent="violet"] { --accent: #6b4dff; --accent-2: #a855f7; --on-accent: #fff; }
:root[data-accent="lime"] { --accent: #4d9a0a; --accent-2: #16a34a; --on-accent: #fff; }
:root[data-accent="blue"] { --accent: #2563eb; --accent-2: #06b6d4; --on-accent: #fff; }
:root[data-accent="amber"] { --accent: #c2620a; --accent-2: #e11d48; --on-accent: #fff; }
:root[data-accent="pink"] { --accent: #db2777; --accent-2: #9333ea; --on-accent: #fff; }
@media (prefers-color-scheme: dark) {
  :root[data-accent="violet"]:not([data-theme="light"]) { --accent: #9b8bff; --accent-2: #c084fc; --on-accent: #0b0d12; }
  :root[data-accent="lime"]:not([data-theme="light"]) { --accent: #a3e635; --accent-2: #4ade80; --on-accent: #0b0d12; }
  :root[data-accent="blue"]:not([data-theme="light"]) { --accent: #60a5fa; --accent-2: #22d3ee; --on-accent: #0b0d12; }
  :root[data-accent="amber"]:not([data-theme="light"]) { --accent: #fbbf24; --accent-2: #fb7185; --on-accent: #0b0d12; }
  :root[data-accent="pink"]:not([data-theme="light"]) { --accent: #f472b6; --accent-2: #c084fc; --on-accent: #0b0d12; }
}
:root[data-theme="dark"][data-accent="violet"] { --accent: #9b8bff; --accent-2: #c084fc; --on-accent: #0b0d12; }
:root[data-theme="dark"][data-accent="lime"] { --accent: #a3e635; --accent-2: #4ade80; --on-accent: #0b0d12; }
:root[data-theme="dark"][data-accent="blue"] { --accent: #60a5fa; --accent-2: #22d3ee; --on-accent: #0b0d12; }
:root[data-theme="dark"][data-accent="amber"] { --accent: #fbbf24; --accent-2: #fb7185; --on-accent: #0b0d12; }
:root[data-theme="dark"][data-accent="pink"] { --accent: #f472b6; --accent-2: #c084fc; --on-accent: #0b0d12; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.5; letter-spacing: -0.006em;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
#app { height: 100vh; height: 100dvh; }
::selection { background: var(--accent-soft-2); }
a { color: var(--accent-text); text-underline-offset: 2px; }
button { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { letter-spacing: -0.02em; }

.ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ic svg { width: 18px; height: 18px; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-color: var(--scroll) transparent; scrollbar-width: thin; }

.spinner {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--accent-soft-2); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
.spinner.sm { width: 13px; height: 13px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.hint { color: var(--dim); font-size: 13px; }
.hint.center { text-align: center; }
.mobile-only { display: none !important; }
.mini-label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 4px 0 8px; }

/* ---------- splash / auth ---------- */
.splash {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(900px 500px at 50% 15%, var(--accent-soft), transparent 65%);
}
.splash-logo, .auth-logo, .brand-logo {
  background: var(--accent-grad); color: var(--on-accent); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px color-mix(in oklab, var(--accent) 35%, transparent);
}
.splash-logo { width: 64px; height: 64px; border-radius: 20px; animation: floaty 2.6s ease-in-out infinite; }
.splash-logo .ic svg { width: 30px; height: 30px; }
@keyframes floaty { 50% { transform: translateY(-6px); } }

.auth-wrap {
  height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(800px 420px at 15% 0%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 400px at 100% 100%, color-mix(in oklab, var(--accent-2) 10%, transparent), transparent 60%);
}
.auth-card {
  width: min(390px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 24px;
  padding: 30px; box-shadow: var(--shadow-lg); animation: pop .35s var(--ease);
}
.auth-logo { width: 50px; height: 50px; border-radius: 16px; margin-bottom: 16px; }
.auth-card h1 { margin: 0 0 4px; font-size: 24px; }
.auth-card p.sub { margin: 0 0 22px; color: var(--muted); }
.auth-card .btn-primary { width: 100%; margin-top: 6px; padding: 12px; }
.auth-foot { display: flex; justify-content: center; margin-top: 18px; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; background: var(--surface-2); }
.lang-switch button { background: none; border: 0; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.lang-switch button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- formularios ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input[type="text"], input[type="password"], input[type="search"], textarea, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px; font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input:hover, textarea:hover, select:hover { border-color: var(--border-2); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--dim); }
textarea { resize: vertical; }
select { cursor: pointer; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: background-color .15s, border-color .15s, transform .08s, box-shadow .15s; white-space: nowrap;
  text-decoration: none; box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: 0 4px 14px color-mix(in oklab, var(--accent) 30%, transparent); }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 88%, white); border-color: transparent; }
.btn-danger { background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 30%, transparent); color: var(--danger); box-shadow: none; }
.btn-danger:hover { background: color-mix(in oklab, var(--danger) 18%, transparent); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-sm .ic svg { width: 15px; height: 15px; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex-shrink: 0;
  background: none; border: 1px solid transparent; border-radius: 11px; color: var(--muted); cursor: pointer;
  transition: background-color .15s, color .15s, transform .08s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon:active { transform: scale(0.94); }
.btn-icon.on { background: var(--accent-soft); color: var(--accent-text); }
.btn-icon.busy, .send-btn.busy { pointer-events: none; opacity: 0.55; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-grad); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.avatar.sm { width: 27px; height: 27px; font-size: 12px; }
.avatar.xs { width: 18px; height: 18px; font-size: 10px; }

/* ---------- estructura ---------- */
.app { display: grid; grid-template-columns: 296px 1fr; height: 100%; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 2px; padding: 16px 12px 12px 16px; font-weight: 750; font-size: 17px; letter-spacing: -0.02em; }
.brand-logo { width: 32px; height: 32px; border-radius: 10px; margin-right: 8px; box-shadow: none; }
.brand-logo .ic svg { width: 17px; height: 17px; }
.brand-name { flex: 1; }
.avatar-btn { width: 38px; }

.tabs { display: flex; gap: 2px; margin: 0 12px 12px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.tab {
  flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 7px 4px;
  border: 0; border-radius: 9px; background: none; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.tab .ic { display: none; }
.tab span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.side-head { display: flex; align-items: center; gap: 2px; padding: 10px 10px 4px 18px; }
.side-label { flex: 1; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-head .btn-icon { width: 30px; height: 30px; }
.side-head .btn-icon .ic svg { width: 16px; height: 16px; }

.subj-list { padding: 0 10px 6px; max-height: 32vh; overflow-y: auto; flex-shrink: 0; }
.subj-item { display: flex; align-items: center; border-radius: var(--radius-sm); margin-bottom: 1px; }
.subj-item.active { background: var(--accent-soft); }
.subj-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: none; border: 0;
  color: var(--text-2); font-size: 14px; text-align: left; cursor: pointer; border-radius: var(--radius-sm); font-weight: 500;
}
.subj-btn:hover { background: var(--surface-2); }
.subj-item.active .subj-btn { color: var(--accent-text); font-weight: 650; }
.subj-item.active .subj-btn:hover { background: none; }
.subj-btn .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subj-btn .ct { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; min-width: 24px; text-align: center; font-weight: 600; }
.subj-item.active .subj-btn .ct { background: var(--accent-soft-2); color: var(--accent-text); }
.subj-more { width: 30px; height: 30px; }

.note-list { flex: 1; overflow-y: auto; padding: 2px 10px 14px; min-height: 0; }
.note-item {
  position: relative; display: block; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 4px;
  background: none; border: 1px solid transparent; border-radius: 12px; cursor: pointer; color: var(--text);
  transition: background-color .15s, border-color .15s;
}
.note-item:hover { background: var(--surface-2); }
.note-item.active { background: var(--surface); border-color: var(--border-2); box-shadow: var(--shadow); }
.note-top { display: flex; align-items: center; gap: 6px; padding-right: 18px; }
.note-item .t { flex: 1; font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-stars { display: inline-flex; align-items: center; gap: 2px; color: var(--star); font-size: 11.5px; font-weight: 600; }
.note-stars .ic svg { width: 12px; height: 12px; fill: var(--star); }
.note-bottom { display: flex; gap: 8px; align-items: baseline; margin-top: 3px; }
.note-item .s { flex: 1; color: var(--muted); font-size: 12.8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item .when { color: var(--dim); font-size: 11.5px; white-space: nowrap; }
.note-item .st { position: absolute; top: 11px; right: 11px; color: var(--dim); }
.note-item .st.emb { color: var(--ok); opacity: .75; }
.note-item .st .ic svg { width: 13px; height: 13px; }

.empty-hint { text-align: center; color: var(--muted); padding: 26px 12px; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-hint.small { padding: 14px 8px; font-size: 13px; }
.big-ic { width: 56px; height: 56px; border-radius: 18px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; color: var(--accent-text); }
.big-ic .ic svg { width: 26px; height: 26px; }

.main { min-width: 0; min-height: 0; position: relative; display: flex; flex-direction: column; }
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; animation: fadeUp .2s var(--ease); }
.view-head { display: flex; align-items: center; gap: 10px; padding: 14px 22px 10px; }
.view-head h2 { margin: 0; font-size: 20px; flex: 1; }

/* ---------- editor ---------- */
.notes-view { flex-direction: column; }
.editor-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.editor-pane.drop::after {
  content: ''; position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 20px; background: var(--accent-soft); pointer-events: none; z-index: 20;
}
.editor-head { display: flex; align-items: center; gap: 4px; padding: 12px 16px 2px 22px; }
.editor-head .title-input {
  flex: 1; min-width: 0; background: none; border: 1px solid transparent; font-size: 21px; font-weight: 750; padding: 6px 8px; margin-left: -8px;
  letter-spacing: -0.02em; box-shadow: none;
}
.editor-head .title-input:hover { border-color: var(--border); }
.editor-head .title-input:focus { background: var(--surface); }
.star-toggle { width: auto; padding: 0 9px; gap: 4px; }
.star-toggle .ic svg { fill: currentColor; }
.star-toggle.on { color: var(--star); background: color-mix(in oklab, var(--star) 14%, transparent); }
.star-count { font-size: 12.5px; font-weight: 650; }

.editor-meta { display: flex; align-items: center; gap: 8px; padding: 2px 22px 10px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.editor-meta .meta-ic { color: var(--dim); }
.editor-meta .meta-ic svg { width: 15px; height: 15px; }
.editor-meta select { width: auto; max-width: 220px; padding: 4px 10px; font-size: 13px; border-radius: 999px; background: var(--surface-2); font-weight: 600; }
.meta-date { color: var(--dim); font-size: 12.5px; }
.index-badge { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-soft); padding: 3px 10px; border-radius: 999px; }
.index-badge.ok { color: var(--ok); background: var(--ok-soft); }
.index-badge .ic svg { width: 13px; height: 13px; }

.search-bar { display: flex; align-items: center; gap: 6px; padding: 8px 22px; border-bottom: 1px solid var(--border); }
.search-bar .sb-ic { color: var(--dim); }
.search-bar input { flex: 1; padding: 6px 12px; border-radius: 999px; }
.search-count { font-size: 12.5px; color: var(--muted); min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.search-bar .btn { padding: 5px 7px; box-shadow: none; }

.thread {
  flex: 1; overflow-y: auto; padding: 16px max(48px, calc((100% - 860px) / 2)) 24px; display: flex; flex-direction: column; gap: 6px;
  overscroll-behavior: contain;
}
.day-sep { align-self: center; margin: 12px 0 6px; position: sticky; top: 4px; z-index: 2; }
.day-sep span {
  font-size: 12px; font-weight: 600; color: var(--muted); background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border); padding: 3px 12px; border-radius: 999px; text-transform: capitalize; box-shadow: var(--shadow-sm);
}
.thread-ph { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }

.bubble {
  position: relative; align-self: flex-end; max-width: min(620px, 78%); background: var(--mine); border: 1px solid var(--mine-border);
  border-radius: 20px 20px 6px 20px; padding: 9px 14px 6px; content-visibility: auto; contain-intrinsic-size: auto 60px;
  box-shadow: var(--shadow-sm); color: var(--text);
}
.bubble.other { align-self: flex-start; background: var(--surface); border-color: var(--border); border-radius: 20px 20px 20px 6px; }
.bubble.pop { animation: pop .22s var(--ease); }
.bubble .sender { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--accent-text); margin-bottom: 3px; }
.bubble .txt { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.bubble-foot { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 2px; color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.bubble-foot .star-mark { color: var(--star); }
.bubble-foot .star-mark svg { width: 12px; height: 12px; fill: var(--star); }
.bubble-foot .sending-ic svg { width: 12px; height: 12px; }
.bubble.sending { opacity: .7; }
.bubble.failed { border-color: color-mix(in oklab, var(--danger) 45%, transparent); background: var(--danger-soft); }
.failed-foot { color: var(--danger); gap: 8px; flex-wrap: wrap; font-size: 12px; font-weight: 600; margin-top: 6px; }
.failed-foot .ic svg { width: 13px; height: 13px; }
.failed-foot .btn { box-shadow: none; }
.bubble.starred::after { content: ''; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--star); }
.bubble.other.starred::after { left: auto; right: -1px; }
.bubble-more {
  position: absolute; top: 50%; left: -34px; transform: translateY(-50%); width: 28px; height: 28px; opacity: 0;
  border-radius: 50%; transition: opacity .12s;
}
.bubble.other .bubble-more { left: auto; right: -34px; }
.bubble.image .bubble-more, .bubble.audio .bubble-more { top: 22px; }
.bubble:hover .bubble-more, .bubble:focus-within .bubble-more { opacity: 1; }
.bubble.flash { animation: flash 1.8s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.bubble.search-hit { outline: 1px solid color-mix(in oklab, var(--warn) 55%, transparent); }
.bubble.search-cur { outline: 2px solid var(--warn); }
.bubble.editing { width: min(620px, 78%); }
.bubble.err { border-color: color-mix(in oklab, var(--danger) 45%, transparent); }

.bubble.image, .bubble.audio { width: min(420px, 78%); }
.img-thumb-wrap { display: block; width: 100%; padding: 0; border: 0; background: var(--surface-2); border-radius: 14px; overflow: hidden; cursor: zoom-in; margin: 2px 0 6px; }
.thumb { display: block; width: 100%; max-height: 340px; object-fit: contain; }
.bubble audio { width: 100%; height: 40px; margin: 2px 0 4px; border-radius: 999px; }
.media-status { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.media-status.done { display: none; }
.media-status.error { color: var(--danger); }
.media-status .ic svg { width: 14px; height: 14px; }
.img-text { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
.img-text summary { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; color: var(--muted); list-style: none; font-weight: 600; }
.img-text summary::-webkit-details-marker { display: none; }
.img-text summary::before { content: '▸'; font-size: 10px; transition: transform .15s; }
.img-text[open] summary::before { transform: rotate(90deg); }
.img-text summary span { flex: 1; }
.img-edit { width: 26px; height: 26px; }
.img-text-body { white-space: pre-wrap; font-size: 13.5px; padding: 4px 0 2px; color: var(--text-2); max-height: 300px; overflow-y: auto; overflow-wrap: anywhere; }
.img-edit-ta { min-height: 90px; font-size: 14px; margin-top: 4px; }
.img-edit-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }

.no-note { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px; max-width: 470px; }
.no-note-title { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.015em; }
.mobile-list { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.mobile-list .note-list { padding: 4px 12px 16px; }
.mobile-list .note-item { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); margin-bottom: 8px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 22px 10px; flex-shrink: 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip .ic svg { width: 14px; height: 14px; }
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 40%, transparent); color: var(--accent-text); font-weight: 650; }

.fab {
  position: absolute; right: 24px; bottom: 96px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow); z-index: 5;
}
.star-banner { display: flex; align-items: center; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--border); color: var(--star); background: var(--surface); }
.star-banner span:nth-child(2) { flex: 1; color: var(--text); }

/* ---------- compositor flotante ---------- */
.composer {
  position: relative; display: flex; align-items: flex-end; gap: 4px; margin: 0 max(16px, calc((100% - 900px) / 2)) 14px;
  padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 26px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: color-mix(in oklab, var(--accent) 45%, var(--border)); box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft); }
.composer-box { flex: 1; min-width: 0; display: flex; }
.composer textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 200px; border: 0; background: transparent; box-shadow: none !important;
  border-radius: 18px; padding: 9px 8px; line-height: 1.45; field-sizing: content; scrollbar-width: none;
}
.composer textarea::-webkit-scrollbar { display: none; }
.composer textarea:hover { border: 0; }
.composer textarea:focus { background: transparent; }
.composer textarea:focus-visible { outline: none; }
.composer .btn-icon { width: 40px; height: 40px; border-radius: 50%; }
.send-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; flex-shrink: 0; }
.send-btn .ic svg { width: 18px; height: 18px; }
.mic-btn { color: var(--accent-text); }
/* enviar y micrófono se alternan según haya texto (sin mover el foco) */
.notes-view .composer .send-btn { display: none; }
.notes-view .composer.has-text .send-btn { display: inline-flex; animation: pop .15s var(--ease); }
.notes-view .composer.has-text .mic-btn { display: none; }
.stop-btn { align-self: center; box-shadow: none; }
.split-chip { position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); z-index: 4; animation: fadeUp .15s; }
.split-chip .chip { box-shadow: var(--shadow); background: var(--surface); }

.rec-bar {
  display: flex; align-items: center; gap: 10px; margin: 0 max(16px, calc((100% - 900px) / 2)) 14px; padding: 5px 5px 5px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 26px; box-shadow: var(--shadow);
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.rec-hint { flex: 1; color: var(--muted); font-size: 13px; }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.9); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeUp .15s; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; cursor: zoom-out; }
.lb-close { position: absolute; top: 14px; right: 14px; background: rgba(255, 255, 255, 0.12); color: #fff; }
.lb-open { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); }

/* ---------- preguntar ---------- */
.chat-view { position: relative; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-head { padding-bottom: 8px; }
.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.chat-title > .ic { color: var(--accent-text); }
.chat-title-txt { min-width: 0; }
.chat-title-txt .nm { font-weight: 750; font-size: 17px; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title-txt .sub { color: var(--dim); font-size: 12.5px; }
.chats-toggle { display: none; }
.chat-thread { flex: 1; overflow-y: auto; padding: 8px 24px 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-thread > * { width: 100%; max-width: 820px; margin-left: auto; margin-right: auto; }
.msg { padding: 11px 15px; border-radius: 20px; overflow-wrap: anywhere; }
.msg.user {
  align-self: flex-end; width: auto; max-width: min(640px, 80%); margin-right: max(0px, calc((100% - 820px) / 2));
  background: var(--accent); color: var(--on-accent); white-space: pre-wrap; border-radius: 20px 20px 6px 20px; box-shadow: var(--shadow-sm);
}
.msg-wrap { display: flex; flex-direction: column; gap: 6px; animation: pop .22s var(--ease); }
.msg.bot { background: var(--surface); border: 1px solid var(--border); border-radius: 20px 20px 20px 6px; position: relative; box-shadow: var(--shadow-sm); }
.msg.insufficient, .msg.error { color: var(--muted); }
.msg.insufficient .md, .msg.error .md { display: flex; gap: 8px; align-items: flex-start; }
.msg.error { border-color: color-mix(in oklab, var(--danger) 40%, transparent); }
.msg-ic { color: var(--warn); margin-top: 2px; }
.msg.error .msg-ic { color: var(--danger); }
.caret { display: inline-block; width: 7px; height: 16px; background: var(--accent); vertical-align: text-bottom; animation: pulse .9s infinite; border-radius: 2px; margin-left: 2px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.msg-tools { display: flex; align-items: center; gap: 6px; padding-left: 4px; }
.msg-tools .btn-icon { width: 30px; height: 30px; }
.query-note { font-size: 12px; color: var(--dim); font-style: italic; }

.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--accent-text); }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; line-height: 1.3; }
.md h1 { font-size: 21px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4 { font-size: 15px; }
.md strong { color: var(--text); font-weight: 700; }
.md code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 6px; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; overflow-x: auto; }
.md pre code { background: none; border: 0; padding: 0; }
.md blockquote { margin: 0 0 10px; padding: 6px 14px; border-left: 3px solid var(--accent); color: var(--text-2); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.md table { border-collapse: separate; border-spacing: 0; margin: 0 0 12px; display: block; overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: 12px; }
.md th, .md td { border-bottom: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.md tr:last-child td { border-bottom: 0; }
.md th { background: var(--surface-2); font-weight: 650; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.cite {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; margin: 0 1px;
  font-size: 11px; font-weight: 700; color: var(--accent-text); background: var(--accent-soft); border: 1px solid color-mix(in oklab, var(--accent) 30%, transparent);
  border-radius: 7px; cursor: pointer; vertical-align: 2px; transition: background-color .15s, color .15s;
}
.cite:hover { background: var(--accent); color: var(--on-accent); }

.sources { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); overflow: hidden; }
.sources summary { display: flex; align-items: center; gap: 8px; padding: 9px 14px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; list-style: none; }
.sources summary::-webkit-details-marker { display: none; }
.sources summary:hover { color: var(--text); }
.sources summary .ic svg { width: 15px; height: 15px; }
.src-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--border); padding: 10px 14px; cursor: pointer; }
.src-item:hover { background: var(--surface-2); }
.src-item .t { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.src-n { width: 20px; height: 20px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.src-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-subj { font-size: 11.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; white-space: nowrap; }
.src-item .pct { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.match-bar { height: 4px; background: var(--surface-3); border-radius: 4px; margin: 7px 0; overflow: hidden; }
.match-fill { height: 100%; background: var(--accent-grad); border-radius: 4px; }
.snip { font-size: 13px; color: var(--text-2); white-space: pre-wrap; max-height: 9.5em; overflow: hidden; }
.snip mark, .pi-snip mark { background: var(--mark-bg); color: inherit; border-radius: 4px; padding: 0 2px; }

.ask-empty { margin: auto; max-width: 540px; padding-top: 40px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.examples .chip { white-space: normal; text-align: left; box-shadow: var(--shadow-sm); }

.convo-side { width: 276px; border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.convo-head { display: flex; align-items: center; gap: 6px; padding: 16px 12px 8px 18px; }
.convo-head .btn { box-shadow: none; }
.convo-close { display: none; }
.convo-list { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.convo-item { display: flex; align-items: center; border-radius: 12px; margin-bottom: 2px; }
.convo-item.active { background: var(--accent-soft); }
.convo-btn { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; border-radius: 12px; }
.convo-btn:hover { background: var(--surface-2); }
.convo-item.active .convo-btn:hover { background: none; }
.convo-btn .nm { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-item.active .convo-btn .nm { color: var(--accent-text); }
.convo-btn .sub { font-size: 12px; color: var(--dim); }
.convo-item .btn-icon { width: 30px; height: 30px; opacity: 0; }
.convo-item:hover .btn-icon, .convo-item.active .btn-icon { opacity: 1; }
.convo-backdrop { display: none; }

/* ---------- estudiar ---------- */
.study-view { overflow-y: auto; }
.study-wrap { width: 100%; max-width: 880px; margin: 0 auto; padding-bottom: 30px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin: 0 22px 16px; box-shadow: var(--shadow-sm); }
.card-title { font-weight: 750; margin-bottom: 14px; font-size: 15.5px; letter-spacing: -0.01em; }
.kind-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.kind {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 14px 15px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; cursor: pointer;
  transition: border-color .15s, background-color .15s, transform .1s;
}
.kind > .ic { color: var(--accent-text); margin-bottom: 4px; width: 34px; height: 34px; border-radius: 11px; background: var(--accent-soft); }
.kind:hover { border-color: var(--border-2); transform: translateY(-1px); }
.kind.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.kind .kn { font-weight: 700; }
.kind .kd { font-size: 12.5px; color: var(--muted); }
.study-row { display: flex; gap: 12px; flex-wrap: wrap; }
.study-row .col { display: flex; flex-direction: column; gap: 2px; min-width: 200px; }
.study-row .col.grow { flex: 1; }
.study-go { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.study-go .hint { flex: 1; }
.gen-status { display: flex; align-items: center; gap: 8px; color: var(--accent-text); font-size: 13.5px; font-weight: 600; width: 100%; }
.set-list { display: flex; flex-direction: column; gap: 4px; }
.set-item { display: flex; align-items: center; border-radius: 12px; }
.set-item:hover { background: var(--surface-2); }
.set-btn { flex: 1; min-width: 0; display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; text-align: left; background: none; border: 0; padding: 9px 10px; cursor: pointer; }
.set-btn > .ic { grid-row: span 2; color: var(--accent-text); align-self: center; width: 34px; height: 34px; border-radius: 11px; background: var(--accent-soft); }
.set-btn .nm { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-btn .sub { font-size: 12.5px; color: var(--dim); }
.viewer-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.viewer-top .btn { box-shadow: none; }
.viewer-title { font-weight: 750; font-size: 18px; letter-spacing: -0.015em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partial-note { font-size: 13px; color: var(--warn); background: var(--warn-soft); border: 1px solid color-mix(in oklab, var(--warn) 30%, transparent); padding: 9px 13px; border-radius: 12px; margin-bottom: 16px; }
.summary-md { font-size: 15px; line-height: 1.6; }

.fc-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; outline: none; }
.fc-count { color: var(--muted); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fc-card { width: min(580px, 100%); height: 310px; perspective: 1400px; background: none; border: 0; padding: 0; cursor: pointer; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform .5s var(--ease); transform-style: preserve-3d; }
.fc-card.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 24px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 28px; text-align: center; border: 1px solid var(--border); overflow-y: auto; box-shadow: var(--shadow);
}
.fc-front { background: var(--surface); }
.fc-back { background: linear-gradient(150deg, var(--mine), color-mix(in oklab, var(--accent-2) 14%, var(--surface))); transform: rotateY(180deg); border-color: var(--mine-border); }
.fc-label { position: absolute; top: 16px; left: 18px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.fc-text { font-size: 20px; font-weight: 650; line-height: 1.45; white-space: pre-wrap; letter-spacing: -0.01em; }
.fc-back .fc-text { font-size: 17px; font-weight: 500; }
.fc-nav { display: flex; gap: 8px; }
.fc-nav .btn.on { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

.quiz { display: flex; flex-direction: column; gap: 14px; }
.quiz-q { background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; padding: 16px; }
.qq { font-weight: 650; margin-bottom: 12px; }
.q-opts { display: grid; gap: 7px; }
.q-opt {
  display: flex; justify-content: flex-start; text-align: left; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; font-size: 14.5px; transition: border-color .15s, background-color .15s;
}
.q-opt:hover:not(:disabled) { border-color: var(--accent); }
.q-opt:disabled { cursor: default; }
.q-opt.right { border-color: var(--ok); background: var(--ok-soft); color: var(--text); }
.q-opt.wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--text); }
.q-expl { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 13.5px; color: var(--danger); }
.q-expl.ok { color: var(--ok); }
.q-expl span { color: var(--text-2); }
.q-expl .ic svg { width: 16px; height: 16px; }
.quiz-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 0; }
.quiz-score { font-weight: 700; }

/* ---------- paleta de búsqueda ---------- */
.palette-back { align-items: flex-start; padding-top: 12vh; }
.palette {
  width: min(660px, 94vw); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg);
  overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; animation: pop .18s var(--ease);
}
.palette-bar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-bar input { border: 0; background: none !important; padding: 4px 0; font-size: 16px; box-shadow: none !important; }
kbd { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--surface-2); }
.palette-results { overflow-y: auto; flex: 1; padding: 6px; }
.palette-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.palette-item:hover, .palette-item.sel { background: var(--accent-soft); }
.pi-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.pi-title { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-subj { font-size: 11.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.pi-date { margin-left: auto; font-size: 12px; color: var(--dim); white-space: nowrap; }
.pi-snip { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.palette-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }
.palette-foot { border-top: 1px solid var(--border); padding: 6px; }
.palette-ask { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 9px 12px; border-radius: 12px; color: var(--accent-text); cursor: pointer; font-size: 14px; font-weight: 600; }
.palette-ask:hover { background: var(--accent-soft); }

/* ---------- menús ---------- */
.pop-menu {
  position: fixed; z-index: 90; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s var(--ease);
}
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 500; }
.pop-item:hover, .pop-item:focus-visible { background: var(--surface-2); outline: none; }
.pop-item .ic { color: var(--muted); }
.pop-item.danger, .pop-item.danger .ic { color: var(--danger); }
.pop-sep { height: 1px; background: var(--border); margin: 5px 6px; }
.pop-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 5px; font-weight: 700; }
.pop-head .role { font-size: 12px; color: var(--dim); font-weight: 500; }

/* ---------- modales ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 80; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal {
  width: min(430px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 24px; box-shadow: var(--shadow-lg); animation: pop .2s var(--ease);
}
.modal.wide { width: min(660px, 100%); }
.modal h3 { margin: 0 0 6px; font-size: 19px; }
.modal p.sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.modal .hint { margin: -4px 0 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.actions-col { display: flex; flex-direction: column; gap: 8px; }
.actions-col .btn { justify-content: flex-start; }
.modal-confirm { text-align: center; }
.modal-confirm .actions { justify-content: center; }
.confirm-ic { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-text); }
.confirm-ic.danger { background: var(--danger-soft); color: var(--danger); }

.seg { display: flex; gap: 3px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; }
.seg-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: none; border: 0; padding: 8px; border-radius: 9px; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13px; }
.seg-btn .ic svg { width: 15px; height: 15px; }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--surface); cursor: pointer; box-shadow: 0 0 0 1px var(--border-2); transition: transform .1s, box-shadow .15s; }
.swatch:hover { transform: scale(1.07); }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }
.swatch[data-swatch="brand"] { background: linear-gradient(135deg, #c8ff2e 0 50%, #6b4dff 50% 100%); }
.swatch[data-swatch="violet"] { background: linear-gradient(135deg, #6b4dff, #a855f7); }
.swatch[data-swatch="lime"] { background: linear-gradient(135deg, #a3e635, #16a34a); }
.swatch[data-swatch="blue"] { background: linear-gradient(135deg, #2563eb, #06b6d4); }
.swatch[data-swatch="amber"] { background: linear-gradient(135deg, #f59e0b, #e11d48); }
.swatch[data-swatch="pink"] { background: linear-gradient(135deg, #db2777, #9333ea); }

.import-pane { margin-bottom: 14px; }
.dropzone {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; border: 2px dashed var(--border-2);
  border-radius: 18px; background: var(--surface-2); cursor: pointer; color: var(--text); font-weight: 600;
}
.dropzone > .ic { color: var(--accent-text); }
.dropzone .hint { font-weight: 400; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); }
.import-ta { min-height: 150px; font-family: var(--mono); font-size: 12.5px; }

.session-list { display: flex; flex-direction: column; gap: 8px; }
.session-row { display: flex; align-items: center; gap: 12px; padding: 11px 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; }
.session-row > .ic { color: var(--muted); }
.session-row.current { border-color: color-mix(in oklab, var(--accent) 45%, transparent); background: var(--accent-soft); }
.session-info { flex: 1; min-width: 0; }
.session-info .nm { font-weight: 650; font-size: 14px; }
.session-info .sub { font-size: 12.5px; color: var(--dim); overflow-wrap: anywhere; }
.session-row .btn { box-shadow: none; }
.admin-status { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.pill { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 11px; border-radius: 999px; }
.pill b { color: var(--text); }
.models { width: 100%; font-size: 12px; color: var(--dim); font-family: var(--mono); margin-top: 4px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: min(520px, 92vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500; animation: pop .2s var(--ease); transition: opacity .35s, transform .35s;
}
.toast.out { opacity: 0; transform: translateY(-6px); }
.toast-msg { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast.error { border-color: color-mix(in oklab, var(--danger) 45%, transparent); }
.toast.error .toast-msg { color: var(--danger); }
.toast.ok .toast-ic { color: var(--ok); }
.toast.update .toast-ic { color: var(--accent-text); }
.toast-copy { width: 28px; height: 28px; }

/* ---------- móvil ---------- */
.bottom-nav, .drawer-backdrop { display: none; }

@media (max-width: 900px) {
  .mobile-only { display: inline-flex !important; }
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .main { grid-row: 1; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(312px, 86vw); z-index: 60; transform: translateX(-102%);
    transition: transform .28s var(--ease); box-shadow: var(--shadow-lg); padding-top: env(safe-area-inset-top);
    border-radius: 0 22px 22px 0;
  }
  .app.drawer-open .sidebar { transform: none; }
  .drawer-backdrop { position: fixed; inset: 0; z-index: 59; background: var(--overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
  .app.drawer-open .drawer-backdrop { display: block; }
  .sidebar .tabs { display: none; }
  .subj-list { max-height: 36vh; }

  .bottom-nav {
    display: flex; grid-row: 2; background: var(--glass); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border-top: 1px solid var(--border); padding: 5px 6px calc(5px + env(safe-area-inset-bottom)); z-index: 30;
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 0; padding: 4px 0;
    color: var(--dim); font-size: 11px; font-weight: 650; cursor: pointer; border-radius: 12px;
  }
  .bn-item .ic { padding: 3px 16px; border-radius: 999px; transition: background-color .2s; }
  .bn-item .ic svg { width: 21px; height: 21px; }
  .bn-item.active { color: var(--accent-text); }
  .bn-item.active .ic { background: var(--accent-soft); }

  .view-head { padding: 10px 12px 8px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .editor-head { padding: 8px 8px 0; padding-top: calc(8px + env(safe-area-inset-top)); }
  .editor-head .title-input { font-size: 18px; margin-left: 0; }
  .editor-meta { padding: 2px 12px 8px; gap: 6px; }
  .meta-date { display: none; }
  .search-bar { padding: 8px 10px; }
  .thread { padding: 10px 12px 14px; }
  .bubble { max-width: 86%; -webkit-touch-callout: none; }
  .bubble.image, .bubble.audio, .bubble.editing { width: 84%; }
  .bubble-more { display: none; } /* en el celular: mantener presionado */
  .chips { padding: 0 12px 8px; }
  .composer { margin: 0 8px 8px; }
  .rec-bar { margin: 0 8px 8px; }
  .fab { bottom: 78px; right: 14px; }

  .chat-thread { padding: 6px 12px 16px; }
  .msg.user { max-width: 86%; }
  .chats-toggle { display: inline-flex; box-shadow: none; }
  .convo-side {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(300px, 86vw); z-index: 60; transform: translateX(102%);
    transition: transform .28s var(--ease); box-shadow: var(--shadow-lg); padding-top: env(safe-area-inset-top); border-radius: 22px 0 0 22px;
  }
  .convo-side.open { transform: none; }
  .convo-backdrop.show { display: block; position: fixed; inset: 0; z-index: 59; background: var(--overlay); }
  .convo-close { display: inline-flex; }
  .convo-item .btn-icon { opacity: 1; }

  .card { margin: 0 12px 12px; padding: 16px; }
  .kind-grid { grid-template-columns: 1fr; gap: 8px; }
  .kind { flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px; }
  .kind > .ic { margin-bottom: 0; }
  .kind .kd { display: none; }
  .fc-card { height: 340px; }
  .fc-text { font-size: 18px; }

  input[type="text"], input[type="password"], input[type="search"], textarea, select { font-size: 16px; }
  #toasts { top: calc(10px + env(safe-area-inset-top)); left: 10px; right: 10px; transform: none; align-items: stretch; }
  .toast { max-width: 100%; }
  .palette-back { padding-top: calc(10px + env(safe-area-inset-top)); }
  .palette { max-height: 80dvh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.chat-view .composer textarea { padding-left: 14px; }

/* ---------- landing (sin sesión) ---------- */
.landing {
  height: 100%; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth;
  background:
    radial-gradient(900px 520px at 85% -5%, color-mix(in oklab, var(--accent-2) 16%, transparent), transparent 62%),
    radial-gradient(900px 520px at 5% 8%, color-mix(in oklab, var(--accent) 16%, transparent), transparent 60%),
    var(--bg);
}
.l-nav {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(20px, calc((100% - 1120px) / 2)); background: var(--glass);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); border-bottom: 1px solid var(--border);
}
.l-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.l-brand .brand-logo { width: 32px; height: 32px; border-radius: 10px; margin: 0; }
.l-nav-right { display: flex; align-items: center; gap: 6px; }
.l-icon-link { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 11px; color: var(--muted); }
.l-icon-link:hover { background: var(--surface-2); color: var(--text); }
.l-chip-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; }
.l-chip-btn:hover { color: var(--text); border-color: var(--border-2); }

.l-hero { padding: 72px 20px 40px; text-align: center; max-width: 1120px; margin: 0 auto; }
.l-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); box-shadow: var(--shadow-sm); animation: pop .5s var(--ease);
}
.l-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.l-hero h1 {
  font-size: clamp(40px, 7vw, 76px); line-height: 1.02; letter-spacing: -0.045em; font-weight: 800; margin: 22px auto 18px; max-width: 900px;
  animation: pop .6s var(--ease) .05s both;
}
.l-grad {
  background: linear-gradient(100deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.l-lead { font-size: clamp(16px, 2vw, 19px); color: var(--muted); max-width: 700px; margin: 0 auto; line-height: 1.6; animation: pop .6s var(--ease) .1s both; }
.l-ctas { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 30px; animation: pop .6s var(--ease) .15s both; }
.l-cta { padding: 12px 20px; font-size: 15px; border-radius: 14px; }

.l-showcase { position: relative; margin: 64px auto 0; max-width: 1060px; padding-right: 90px; }
.l-window {
  border-radius: 18px; overflow: hidden; border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in oklab, var(--accent) 10%, transparent);
}
.l-window-bar { display: flex; align-items: center; gap: 7px; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.l-window-bar i { width: 11px; height: 11px; border-radius: 50%; background: var(--border-2); }
.l-window-bar i:nth-child(1) { background: #ff5f57; } .l-window-bar i:nth-child(2) { background: #febc2e; } .l-window-bar i:nth-child(3) { background: #28c840; }
.l-window-bar span { margin: 0 auto; font-size: 12px; color: var(--dim); font-family: var(--mono); transform: translateX(-24px); }
.l-shot { display: block; width: 100%; height: auto; }
.l-phone {
  position: absolute; right: 0; bottom: -40px; width: 230px; border-radius: 34px; padding: 8px; background: #0b0d12;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}
.l-phone .l-shot { border-radius: 27px; }

.l-section { max-width: 1120px; margin: 0 auto; padding: 110px 20px 10px; text-align: center; }
.l-section h2, .l-os h2 { font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.035em; margin: 0 0 10px; font-weight: 800; }
.l-sub { color: var(--muted); font-size: 17px; margin: 0 auto 40px; max-width: 620px; }
.l-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; text-align: left; }
.l-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 24px; box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
}
.l-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in oklab, var(--accent) 35%, var(--border)); }
.l-card-ic { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 16px; }
.l-card-ic .ic svg { width: 22px; height: 22px; }
.l-card h3 { margin: 0 0 6px; font-size: 17px; }
.l-card p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; }

.l-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; text-align: left; margin-top: 34px; counter-reset: step; }
.l-step { position: relative; padding: 24px; border-radius: 22px; border: 1px dashed var(--border-2); }
.l-step-n {
  display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 12px; font-weight: 800;
  background: var(--accent); color: var(--on-accent); margin-bottom: 14px;
}
.l-step h3 { margin: 0 0 6px; font-size: 18px; }
.l-step p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; }

.l-os {
  max-width: 1080px; margin: 110px auto 0; padding: 40px; border-radius: 28px; display: flex; gap: 28px; align-items: center; justify-content: space-between;
  background:
    radial-gradient(500px 260px at 100% 0%, color-mix(in oklab, var(--accent-2) 18%, transparent), transparent 70%),
    radial-gradient(500px 260px at 0% 100%, color-mix(in oklab, var(--accent) 18%, transparent), transparent 70%),
    var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.l-os p { color: var(--muted); max-width: 560px; margin: 0 0 18px; line-height: 1.6; font-size: 16px; }
.l-stack { display: flex; flex-wrap: wrap; gap: 6px; }
.l-stack .chip { cursor: default; font-family: var(--mono); font-size: 12px; }
.l-os-cta { display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.l-os-cta .btn { padding: 11px 18px; border-radius: 14px; }

.l-foot {
  max-width: 1120px; margin: 90px auto 0; padding: 28px 20px 40px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 14px;
}
.l-foot-links { display: flex; gap: 18px; }
.l-link { color: var(--text-2); text-decoration: none; font-weight: 600; background: none; border: 0; cursor: pointer; font-size: inherit; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.l-link:hover { color: var(--accent-text); text-decoration: underline; }
.l-by .l-link { color: var(--accent-text); }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.l-grid .reveal:nth-child(3n + 2), .l-steps .reveal:nth-child(2) { transition-delay: .08s; }
.l-grid .reveal:nth-child(3n), .l-steps .reveal:nth-child(3) { transition-delay: .16s; }

.auth-foot { flex-direction: column; align-items: center; gap: 12px; }
.auth-back { font-size: 13px; color: var(--muted); }

@media (max-width: 900px) {
  .l-hero { padding: 44px 16px 20px; }
  .l-showcase { padding-right: 0; margin-top: 40px; }
  .l-phone { width: 34%; min-width: 120px; right: -6px; bottom: -28px; border-radius: 22px; padding: 5px; }
  .l-phone .l-shot { border-radius: 18px; }
  .l-grid, .l-steps { grid-template-columns: 1fr; }
  .l-section { padding-top: 80px; }
  .l-os { flex-direction: column; align-items: flex-start; margin: 80px 12px 0; padding: 26px; }
  .l-os-cta { flex-direction: row; flex-wrap: wrap; }
  .l-nav .l-chip-btn { display: none; }
  .l-window-bar span { display: none; }
}

/* ---------- demo ---------- */
.l-demo-note { max-width: 560px; margin: 14px auto 0; font-size: 13px; color: var(--dim); line-height: 1.5; animation: pop .6s var(--ease) .2s both; }
.demo-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 16px; font-size: 12.5px; flex-wrap: wrap;
  background: color-mix(in oklab, var(--accent) 10%, var(--surface)); border-bottom: 1px solid color-mix(in oklab, var(--accent) 25%, var(--border));
}
.demo-tag { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; cursor: pointer; font-weight: 700; color: var(--accent-text); padding: 2px 0; font-size: 12.5px; }
.demo-tag .ic svg { width: 14px; height: 14px; }
.demo-tag-short { display: none; }
.demo-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.demo-pill { padding: 1px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-variant-numeric: tabular-nums; }
.demo-pill.out { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 40%, transparent); }
.demo-link { margin-left: auto; font-weight: 700; color: var(--accent-text); text-decoration: none; }
.demo-link:hover { text-decoration: underline; }
.demo-list { margin: 0 0 12px; padding-left: 20px; color: var(--text-2); font-size: 14px; line-height: 1.55; }
.demo-list li { margin: 4px 0; }
@media (max-width: 900px) {
  .demo-bar { padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); gap: 6px; }
  .demo-pills .demo-pill:nth-child(n+2) { display: none; }
  .demo-bar { flex-wrap: nowrap; }
  .demo-tag-long { display: none; }
  .demo-tag-short { display: inline; }
  .demo-bar + .view .view-head, .demo-bar ~ .view .editor-head { padding-top: 8px; }
}

/* ---------- cuota de IA (panel de admin) ---------- */
.quota { width: 100%; margin: 6px 0 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.quota .mini-label { margin-top: 0; }
.quota-row { margin: 8px 0 10px; }
.quota-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 5px; }
.quota-name { font-weight: 600; }
.quota-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.quota-bar { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.quota-fill { height: 100%; border-radius: 99px; background: var(--accent-grad); transition: width .4s var(--ease); }
.quota-fill.warn { background: var(--warn); }
.quota-fill.bad { background: var(--danger); }
.quota-reset { font-size: 11.5px; color: var(--dim); margin-top: 3px; }
.quota .hint { font-size: 12px; margin-top: 4px; }
