:root {
  --bg: #f7f5f1; --panel: #ffffff; --panel2: #f3f0ea; --line: #e6e1d8; --line2: #d9d3c7;
  --text: #1c1917; --muted: #6f6860; --faint: #a39c92;
  --accent: #c2410c; --accent-hover: #a83a0b; --accent-bg: #fdeee2; --accent-text: #9a3412; --on-accent: #fff;
  --sel: #fbeadb; --hover: #f1ede6; --danger: #c81e1e; --ok: #15803d; --warn: #b45309;
  --shadow: 0 1px 2px rgb(28 25 23 / .05), 0 8px 28px rgb(28 25 23 / .10);
  --radius: 10px; --side: 244px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #12100e; --panel: #1a1816; --panel2: #221f1c; --line: #2c2824; --line2: #3a3530;
  --text: #f1eee9; --muted: #a8a198; --faint: #6e6860;
  --accent: #f97316; --accent-hover: #fb8a3c; --accent-bg: #3b2010; --accent-text: #fdba74; --on-accent: #1a0d04;
  --sel: #33200f; --hover: #24211d; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px rgb(0 0 0 / .5);
} }
:root[data-theme="dark"] {
  --bg: #12100e; --panel: #1a1816; --panel2: #221f1c; --line: #2c2824; --line2: #3a3530;
  --text: #f1eee9; --muted: #a8a198; --faint: #6e6860;
  --accent: #f97316; --accent-hover: #fb8a3c; --accent-bg: #3b2010; --accent-text: #fdba74; --on-accent: #1a0d04;
  --sel: #33200f; --hover: #24211d; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px rgb(0 0 0 / .5);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 6px; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 5px; background: var(--panel); color: var(--muted); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .grow { flex: 1; min-width: 0; } .row { display: flex; align-items: center; gap: 8px; }
.scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }

/* botones y campos */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel); font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input { width: 100%; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel); outline: none; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
label.field { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* acceso */
.auth { height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth form { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.auth h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: var(--on-accent); }
.err { color: var(--danger); font-size: 13px; }

/* estructura */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); height: 100dvh; }
.shell.has-doc { grid-template-columns: var(--side) minmax(330px, 27%) minmax(0, 1fr); }
.side { background: var(--panel2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 14px 14px 8px; display: flex; align-items: center; justify-content: space-between; }
.side-body { flex: 1; padding: 4px 8px 12px; }
.nav { display: flex; align-items: center; gap: 9px; width: 100%; height: 31px; padding: 0 9px; border-radius: 7px; color: var(--muted); font-weight: 500; text-align: left; }
.nav:hover { background: var(--hover); color: var(--text); }
.nav.on { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.nav .count { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav.on .count { color: var(--accent-text); }
.nav .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin: 0 3.5px; }
.side h4 { margin: 16px 9px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); display: flex; justify-content: space-between; align-items: center; }
.side-foot { border-top: 1px solid var(--line); padding: 8px; display: grid; gap: 2px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* lista */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); border-right: 1px solid var(--line); }
.topbar { padding: 12px 16px 8px; display: grid; gap: 8px; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; color: var(--faint); }
.search input { width: 100%; height: 38px; padding: 0 70px 0 34px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel); outline: none; font-size: 14.5px; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.search .hint { position: absolute; right: 9px; display: flex; gap: 4px; pointer-events: none; }
.filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 26px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line2); font-size: 12.5px; color: var(--muted); white-space: nowrap; max-width: 200px; }
.chip span { overflow: hidden; text-overflow: ellipsis; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent-bg); border-color: transparent; color: var(--accent-text); font-weight: 500; }
.chip input[type=date] { border: 0; background: none; outline: none; font-size: 12.5px; width: 108px; color: inherit; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px 0 6px; border-radius: 6px; font-size: 11.5px; font-weight: 500; background: color-mix(in srgb, var(--c) 14%, var(--panel)); color: color-mix(in srgb, var(--c) 72%, var(--text)); white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.tag button { margin-left: 2px; opacity: .6; line-height: 1; } .tag button:hover { opacity: 1; }
.list-head { display: flex; align-items: center; gap: 8px; padding: 0 16px 6px; font-size: 12.5px; color: var(--muted); }
.list { flex: 1; padding: 0 8px 80px; }
.doc { display: flex; gap: 12px; padding: 9px 10px; border-radius: 10px; cursor: default; position: relative; scroll-margin: 60px; }
.doc + .doc { margin-top: 1px; }
.doc:hover { background: var(--hover); }
.doc.cur { background: var(--panel); box-shadow: 0 0 0 1px var(--line2); }
.doc.open { background: var(--sel); box-shadow: none; }
.doc.picked { background: var(--accent-bg); }
.thumb { width: 44px; height: 58px; border-radius: 5px; background: var(--panel); border: 1px solid var(--line); object-fit: cover; object-position: top; flex: none; display: grid; place-items: center; color: var(--faint); font: 600 9.5px var(--mono); text-transform: uppercase; overflow: hidden; }
.doc .check { position: absolute; left: 6px; top: 6px; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line2); background: var(--panel); display: none; place-items: center; color: var(--on-accent); }
.doc:hover .check, .doc.picked .check, .selecting .check { display: grid; }
.doc.picked .check { background: var(--accent); border-color: var(--accent); }
.doc .body { min-width: 0; flex: 1; display: grid; gap: 2px; align-content: center; }
.doc .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.005em; }
.doc .sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .snip { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
mark { background: color-mix(in srgb, var(--accent) 26%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.doc .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; max-height: 20px; overflow: hidden; }
.doc .date { color: var(--faint); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; padding-top: 2px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; padding: 4px 8px; }
.grid .doc { flex-direction: column; gap: 8px; padding: 8px; margin: 0; background: var(--panel); border: 1px solid var(--line); }
.grid .doc.open { border-color: var(--accent); } .grid .doc.picked { background: var(--accent-bg); }
.grid .thumb { width: 100%; height: auto; aspect-ratio: 3/3.7; border-radius: 6px; font-size: 14px; }
.grid .date { padding: 0; }
.empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 40px; }
.empty .big { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; color: var(--faint); }
.empty h3 { margin: 0 0 4px; color: var(--text); font-size: 15.5px; }

/* detalle */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 316px; min-width: 0; min-height: 0; background: var(--panel); }
.viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.viewer-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--panel2); }
.seg button { height: 26px; padding: 0 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.pages { flex: 1; background: var(--panel2); padding: 22px; display: grid; gap: 18px; justify-items: center; align-content: start; }
.pages img { width: min(100%, 900px); aspect-ratio: 1 / 1.414; height: auto; object-fit: contain; background: #fff; border-radius: 3px; box-shadow: 0 1px 3px rgb(0 0 0 / .18), 0 10px 30px rgb(0 0 0 / .12); }
.textview { flex: 1; padding: 26px 32px 60px; white-space: pre-wrap; font: 13.5px/1.65 var(--mono); color: var(--text); background: var(--panel); overflow-wrap: anywhere; }
.meta { padding: 14px 16px 60px; display: grid; gap: 14px; align-content: start; }
.meta .title-input { width: 100%; border: 1px solid transparent; background: none; font-size: 17px; font-weight: 650; letter-spacing: -.015em; padding: 5px 7px; margin: 0 -7px; width: calc(100% + 14px); border-radius: 8px; outline: none; text-overflow: ellipsis; }
.meta .title-input:hover { background: var(--hover); } .meta .title-input:focus { background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.prop { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: start; gap: 6px; font-size: 13px; position: relative; }
.prop > .k { color: var(--muted); padding-top: 5px; display: flex; gap: 6px; align-items: center; }
.prop > .v { min-height: 28px; padding: 3px 7px; margin-left: -7px; border-radius: 7px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; text-align: left; width: calc(100% + 7px); }
button.v:hover, .prop input.v:hover { background: var(--hover); }
.prop input.v { border: 1px solid transparent; background: none; outline: none; height: 28px; }
.prop input.v:focus { border-color: var(--accent); background: var(--panel); }
.section { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.section h5 { margin: 0; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.summary { font-size: 13px; line-height: 1.55; color: var(--text); background: var(--panel2); border-radius: 9px; padding: 10px 12px; }
.note { background: var(--panel2); border-radius: 9px; padding: 8px 10px; font-size: 13px; white-space: pre-wrap; position: relative; }
.note small { display: block; color: var(--faint); margin-top: 3px; }
.note button { position: absolute; top: 6px; right: 6px; color: var(--faint); display: none; } .note:hover button { display: block; }
.facts { font-size: 12px; color: var(--muted); display: grid; gap: 3px; overflow-wrap: anywhere; }
.facts b { font-weight: 500; color: var(--text); }

/* selector emergente */
.pop { position: absolute; z-index: 30; top: calc(100% + 4px); left: 90px; right: 0; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--shadow); padding: 5px; }
.pop input { width: 100%; height: 30px; border: 0; outline: none; background: none; padding: 0 7px; }
.pop .opts { max-height: 240px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.opt { display: flex; align-items: center; gap: 8px; width: 100%; height: 29px; padding: 0 7px; border-radius: 6px; text-align: left; font-size: 13px; }
.opt.hi { background: var(--hover); } .opt .tick { margin-left: auto; color: var(--accent); }
.opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* barra de edición masiva */
.bulk { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 14px; border-radius: 13px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-weight: 500; }
.bulk .btn { background: none; border-color: transparent; color: inherit; } .bulk .btn:hover { background: color-mix(in srgb, var(--bg) 16%, transparent); }
.bulk .sep { width: 1px; height: 18px; background: color-mix(in srgb, var(--bg) 25%, transparent); margin: 0 4px; }
.bulk .pop { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; width: 270px; color: var(--text); }
.bulk .rel { position: relative; }

/* modales, paleta, avisos */
.veil { position: fixed; inset: 0; z-index: 50; background: rgb(15 12 10 / .42); backdrop-filter: blur(2px); display: grid; place-items: start center; padding: 9vh 16px 16px; }
.palette { width: min(580px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.palette input { width: 100%; height: 50px; border: 0; outline: none; background: none; padding: 0 18px; font-size: 16px; border-bottom: 1px solid var(--line); }
.palette .opts { max-height: 46vh; padding: 6px; }
.palette .opt { height: 36px; padding: 0 10px; font-size: 14px; } .palette .opt small { margin-left: auto; color: var(--faint); }
.modal { width: min(880px, 100%); height: min(680px, 82vh); background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; box-shadow: var(--shadow); display: grid; grid-template-columns: 196px minmax(0, 1fr); overflow: hidden; }
.modal.narrow { width: min(520px, 100%); height: auto; display: block; padding: 22px; }
.modal aside { background: var(--panel2); border-right: 1px solid var(--line); padding: 14px 8px; display: grid; gap: 2px; align-content: start; }
.modal aside h3 { margin: 2px 9px 10px; font-size: 14px; }
.modal section { padding: 22px 26px 40px; min-width: 0; }
.modal h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.015em; } .modal h2 + p { margin: 0 0 18px; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--faint); font-size: 11.5px; padding: 6px 6px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .05em; }
.table td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .input { height: 30px; } .table input[type=color] { width: 26px; height: 26px; padding: 0; border: 0; background: none; cursor: pointer; }
.code { font: 12.5px/1.55 var(--mono); background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 26px; } .keys div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: grid; gap: 8px; width: min(340px, calc(100vw - 36px)); }
.toast { background: var(--panel); border: 1px solid var(--line2); border-radius: 11px; box-shadow: var(--shadow); padding: 10px 12px; display: flex; gap: 9px; align-items: flex-start; font-size: 13px; animation: rise .18s ease-out; }
.toast.bad { border-color: var(--danger); } .toast .ok { color: var(--ok); } .toast .bad { color: var(--danger); } .toast .warn { color: var(--warn); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.jobs { position: fixed; left: 12px; bottom: 96px; z-index: 45; width: 330px; max-height: 60vh; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.job { display: flex; gap: 9px; padding: 7px 8px; border-radius: 8px; font-size: 13px; align-items: flex-start; }
.job .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .job small { display: block; color: var(--muted); white-space: normal; }
.drop { position: fixed; inset: 0; z-index: 70; background: color-mix(in srgb, var(--accent) 14%, rgb(15 12 10 / .5)); backdrop-filter: blur(3px); display: grid; place-items: center; pointer-events: none; }
.drop div { border: 2px dashed var(--accent); background: var(--panel); border-radius: 22px; padding: 44px 60px; font-size: 18px; font-weight: 600; text-align: center; box-shadow: var(--shadow); }
.drop small { display: block; font-weight: 400; color: var(--muted); font-size: 13.5px; margin-top: 4px; }

/* documentación de la API */
.apidoc .op { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; overflow: hidden; }
.apidoc summary { display: flex; gap: 10px; align-items: center; padding: 9px 12px; cursor: pointer; list-style: none; font-size: 13px; }
.apidoc summary::-webkit-details-marker { display: none; }
.apidoc .method { font: 600 11px var(--mono); padding: 2px 7px; border-radius: 5px; text-transform: uppercase; min-width: 54px; text-align: center; background: var(--panel2); }
.method.get { color: var(--ok); } .method.post { color: var(--accent-text); } .method.patch { color: var(--warn); } .method.delete { color: var(--danger); }
.apidoc .path { font: 12.5px var(--mono); } .apidoc .opbody { padding: 4px 14px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.apidoc .opbody p { white-space: pre-wrap; color: var(--muted); } .apidoc h3 { margin: 22px 0 2px; font-size: 14px; text-transform: capitalize; }

.only-narrow { display: none; }
@media (max-width: 1180px) {
  .shell.has-doc { grid-template-columns: var(--side) minmax(0, 1fr); } .shell.has-doc .main { display: none; }
  .only-narrow { display: inline-flex; }
}
@media (max-width: 860px) {
  .detail { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(52vh, 1fr) auto; overflow: auto; } .viewer { border-right: 0; min-height: 52vh; }
}
@media (max-width: 720px) {
  .shell, .shell.has-doc { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 48; transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow); }
  .side.open { transform: none; } .menu-btn { display: inline-flex !important; }
  .modal { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } .modal aside { display: flex; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); } .modal aside h3 { display: none; }
  .keys { grid-template-columns: 1fr; } .bulk { left: 8px; right: 8px; transform: none; overflow: auto; }
}
.menu-btn { display: none; }
