/* Ecotono Snaps — tokens y estilos base.
   Fuente de verdad: design system "Ecotono Snaps" (tokens.json). */

/* Tema oscuro: por defecto. */
:root, [data-theme="dark"] {
    color-scheme: dark;
    --surface-000: #1b1c1f;
    --surface-100: #121315;
    --surface-200: #24262a;
    --canvas: #000000;
    --ink: #f2f2f3;
    --ink-muted: #a3a3ad;
    --border: #2e3035;
    --border-strong: #767a85;
    --brand: #ff7a4a;
    --on-brand: #111111;
    --brand-text: #ff8f66;
    --brand-tint: #3a2118;
    --success: #5fd38a;
    --success-bg: #12301f;
    --danger: #ff8a8a;
    --danger-bg: #3a1616;
    --recording: #ff6b6b;
    --focus: #f2f2f3;
    --shadow-drag: 0 12px 28px rgba(0, 0, 0, 0.6);
    --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.55);
    --backdrop: rgba(0, 0, 0, 0.6);
}

/* Tema claro. */
[data-theme="light"] {
    color-scheme: light;
    --surface-000: #ffffff;
    --surface-100: #f6f7f9;
    --surface-200: #eef0f3;
    --canvas: #0b0b0b;
    --ink: #111111;
    --ink-muted: #666677;
    --border: #e6e6e6;
    --border-strong: #8b8b99;
    --brand: #ff6b35;
    --on-brand: #111111;
    --brand-text: #c2410c;
    --brand-tint: #fff0eb;
    --success: #146c2e;
    --success-bg: #e8f7ee;
    --danger: #aa1111;
    --danger-bg: #fdecec;
    --recording: #e53e3e;
    --focus: #111111;
    --shadow-drag: 0 12px 28px rgba(17, 17, 17, 0.18);
    --shadow-float: 0 8px 24px rgba(17, 17, 17, 0.16);
    --backdrop: rgba(17, 17, 17, 0.35);
}

:root {
    --font-sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-12: 48px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 14px;
    --radius-pill: 999px;
}

/* ---------- Base ---------- */
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-sans); font-size: 14px; line-height: 21px; background: var(--surface-100); color: var(--ink); }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 22px; line-height: 28px; font-weight: 700; margin: 0 0 var(--space-2); }
h2 { font-size: 16px; line-height: 22px; font-weight: 700; margin: 0 0 var(--space-3); }
.muted { color: var(--ink-muted); font-size: 13px; line-height: 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.ico { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App chrome ---------- */
.nav { display: flex; gap: var(--space-4); align-items: center; padding: 10px var(--space-6); background: var(--surface-000); border-bottom: 1px solid var(--border); }
.nav a { color: var(--ink); font-weight: 600; font-size: 13px; }
.nav a.is-active { color: var(--brand-text); }
.nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: var(--ink); }
.nav .brand img { width: 26px; height: 26px; border-radius: var(--radius-sm); display: block; }
.nav form { margin: 0; }
.spacer { flex: 1; }
.wrap { max-width: 960px; margin: 28px auto; padding: 0 var(--space-5); }

/* ---------- Cards, lists, layout ---------- */
.card { background: var(--surface-000); border: 1px solid var(--border); border-radius: 12px; padding: var(--space-5); margin-bottom: var(--space-4); }
.row { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.col { flex: 1; min-width: 260px; }
ul.list { list-style: none; padding: 0; margin: 0; }
ul.list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
ul.list li:last-child { border-bottom: none; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12px; line-height: 16px; font-weight: 600; margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-md); font: 400 14px/21px var(--font-sans); background: var(--surface-000); color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--ink-muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; }

/* ---------- Buttons ---------- */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-md); border: 1.5px solid transparent; background: var(--brand); color: var(--on-brand); font: 600 13px/1 var(--font-sans); cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { text-decoration: none; filter: brightness(0.97); }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--surface-000); color: var(--ink); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--surface-200); filter: none; }
.btn-danger { background: var(--surface-000); color: var(--danger); border-color: var(--danger); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }

/* ---------- Badges & notices ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--radius-pill); font: 600 11px/1 var(--font-sans); background: var(--brand-tint); color: var(--brand-text); vertical-align: middle; }
.badge-neutral { background: var(--surface-200); color: var(--ink); }
.badge-success { background: var(--success-bg); color: var(--success); }
.flash { background: var(--success-bg); color: var(--success); padding: 10px 12px; border-radius: var(--radius-md); margin-bottom: var(--space-3); font-size: 13px; }
.error { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: var(--radius-md); margin-bottom: var(--space-3); font-size: 13px; }
.auth-brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.auth-brand img { width: 40px; height: 40px; border-radius: var(--radius-md); }

/* ---------- Step number ---------- */
.step-num { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--brand); color: var(--on-brand); font: 700 13px/1 var(--font-sans); flex: none; }
.step-num.quiet { background: var(--surface-200); color: var(--ink); }

/* ---------- Step media ---------- */
.step-media { background: var(--canvas); border-radius: var(--radius-lg); overflow: hidden; }
.step-media img, .step-media video { width: 100%; display: block; }

/* ---------- Markdown ---------- */
.md-body p { margin: 0 0 8px; }
.md-body p:last-child { margin-bottom: 0; }
.md-body ul, .md-body ol { margin: 0 0 8px; padding-left: 1.3em; }
.md-body code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-200); padding: 1px 5px; border-radius: 4px; }

/* ---------- Wordmark (Bricolage Grotesque, dos líneas) ---------- */
:root { --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif; }
.wordmark { display: inline-flex; flex-direction: column; font-family: var(--font-display); font-weight: 800; line-height: .92; letter-spacing: -0.02em; color: var(--ink); }
.wordmark-sm { font-size: 14px; }
.wordmark-lg { font-size: 28px; }

/* ---------- Armazón: barra lateral + contenido ---------- */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4) var(--space-3); background: var(--surface-000); border-right: 1px solid var(--border); overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; color: var(--ink); }
.side-brand:hover { text-decoration: none; }
.side-brand img { width: 28px; height: 28px; border-radius: var(--radius-sm); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-md); color: var(--ink); font-size: 14px; line-height: 20px; }
.side-link:hover { background: var(--surface-200); text-decoration: none; }
.side-link.is-active { background: var(--surface-200); font-weight: 600; }
.side-link .ico { color: var(--ink-muted); }
.side-link .count { margin-left: auto; color: var(--ink-muted); font-size: 12px; }
.side-link .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-section { display: flex; align-items: center; gap: 6px; margin: var(--space-4) 0 2px; padding: 0 10px; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-muted); }
.side-section .spacer { flex: 1; }
.side-accords { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; }
.side-accord { border: 0; }
.side-accord > summary {
  list-style: none; display: flex; align-items: center; gap: 6px; margin: 4px 6px 0; padding: 6px 8px;
  border-radius: var(--radius-md); font-size: 12px; font-weight: 650; color: var(--ink-muted); cursor: pointer; user-select: none;
}
.side-accord > summary::-webkit-details-marker { display: none; }
.side-accord > summary:hover { background: var(--surface-200); color: var(--ink); }
.side-accord > summary .count { margin-left: auto; font-weight: 600; opacity: .7; }
.side-accord-chevron { transition: transform .15s ease; flex: none; }
.side-accord[open] > summary .side-accord-chevron { transform: rotate(90deg); }
.side-accord .side-nav { padding-left: 4px; }
.side-accord .side-empty { padding: 4px 12px 8px; }
.side-dot { width: 18px; height: 18px; border-radius: 5px; flex: none; display: inline-flex; align-items: center; justify-content: center; font: 700 10px/1 var(--font-sans); background: var(--brand-tint); color: var(--brand-text); }
.side-empty { padding: 4px 10px; font-size: 13px; color: var(--ink-muted); }
.side-foot { margin-top: auto; padding-top: var(--space-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--space-3); min-height: 60px; padding: 10px var(--space-8); background: var(--surface-100); border-bottom: 1px solid var(--border); }
.top-title { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; margin: 0; min-width: 0; }
.top-title .ico { color: var(--ink-muted); }
.top-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: var(--space-8); max-width: 1280px; width: 100%; }
.menu-btn { display: none; }

/* ---------- Menú de usuario ---------- */
.umenu { position: relative; }
.umenu > summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 4px; border-radius: var(--radius-pill); cursor: pointer; color: var(--ink); font-size: 13px; font-weight: 600; }
.umenu > summary::-webkit-details-marker { display: none; }
.umenu > summary:hover, .umenu[open] > summary { background: var(--surface-200); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--brand); color: var(--on-brand); font: 700 12px/1 var(--font-sans); flex: none; }
.umenu-panel { position: absolute; right: 0; top: calc(100% + 6px); width: 260px; padding: 6px; background: var(--surface-000); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); z-index: 40; }
.umenu-head { display: flex; gap: 10px; align-items: center; padding: 8px 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.umenu-head .avatar { width: 36px; height: 36px; font-size: 14px; }
.umenu-name { font-weight: 700; font-size: 14px; line-height: 18px; }
.umenu-mail { font-size: 12px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.umenu-item { display: flex; width: 100%; align-items: center; gap: 10px; height: 36px; padding: 0 8px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: 400 14px/1 var(--font-sans); cursor: pointer; text-align: left; justify-content: flex-start; }
.umenu-item:hover { background: var(--surface-200); text-decoration: none; filter: none; }
.umenu-item .ico { color: var(--ink-muted); }
.umenu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.umenu-theme { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 14px; }
.umenu-theme .seg { margin-left: auto; }
.umenu form { margin: 0; }

/* ---------- Control segmentado ---------- */
.seg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.seg button { height: 26px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: 600 12px/1 var(--font-sans); }
.seg button:hover { background: var(--surface-200); filter: none; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface-000); }

/* ---------- Modal ---------- */
dialog.modal { width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface-000); color: var(--ink); box-shadow: var(--shadow-float); }
dialog.modal::backdrop { background: var(--backdrop); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 8px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Pestañas y tarjetas ---------- */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: var(--space-6); }
.tabs a { padding: 0 0 10px; color: var(--ink-muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.is-active { color: var(--ink); border-bottom-color: var(--brand); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-5); }
.tile { display: flex; flex-direction: column; gap: 10px; padding: var(--space-5); background: var(--surface-000); border: 1px solid var(--border); border-radius: 12px; color: var(--ink); min-height: 150px; position: relative; }
.tile:hover { border-color: var(--border-strong); text-decoration: none; }
a.tile { color: inherit; }
.tile-guide { padding-bottom: 12px; }
.tile-guide.is-pinned { outline: 1px solid color-mix(in srgb, var(--brand) 45%, transparent); }
.tile-hit { display: flex; flex-direction: column; gap: 10px; flex: 1; color: inherit; min-width: 0; }
.tile-hit:hover { text-decoration: none; }
.tile-media { margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-5)) 4px; aspect-ratio: 16 / 9; background: var(--canvas); border-radius: 12px 12px 0 0; overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--ink-muted); position: relative; }
.tile-media img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.tile-pin-badge { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 999px; background: var(--surface-000); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--brand); }
.tile-meta { display: flex; align-items: center; gap: 8px; color: var(--ink-muted); font-size: 13px; }
.tile-title { margin: 0; font-size: 16px; line-height: 22px; font-weight: 700; }
.tile-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--ink-muted); font-size: 13px; }
.tile-actions { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 3px; background: var(--surface-000); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-float); opacity: 0; transition: opacity .12s; }
.tile-guide:hover .tile-actions, .tile-guide:focus-within .tile-actions, .tile-guide.menu-open .tile-actions { opacity: 1; }
@media (hover: none) { .tile-actions { opacity: 1; } }
.tile-actions .inline-form { display: contents; }
.tile-act { width: 30px; height: 30px; padding: 0; background: transparent; color: var(--ink); border-radius: var(--radius-sm); }
.tile-act:hover { background: var(--surface-200); filter: none; }
.tile-act.is-on { color: var(--brand); }
.tile-act.is-on .ico { fill: currentColor; }
.tile-more { position: relative; }
.tile-menu {
  position: absolute; right: -4px; top: calc(100% + 8px); z-index: 5; min-width: 220px;
  padding: 6px; background: var(--surface-000); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float); display: flex; flex-direction: column; gap: 2px;
}
.tile-menu[hidden] { display: none; }
.tile-menu .inline-form { display: contents; }
.tile-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px;
  background: transparent; color: var(--ink); font-weight: 400; font-size: 14px; border-radius: var(--radius-md); justify-content: flex-start;
}
.tile-menu button:hover, .tile-menu button:focus-visible { background: var(--surface-200); filter: none; }
.tile-menu button .ico { color: var(--ink-muted); }
.tile-menu button.is-danger, .tile-menu button.is-danger .ico { color: var(--danger); }
.tile-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.empty-state { text-align: center; padding: var(--space-12) var(--space-5); border: 1px dashed var(--border-strong); border-radius: 12px; }
.empty-state h2 { margin-bottom: 4px; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: fixed; z-index: 50; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-float); }
    .shell.side-open .side { transform: none; }
    .menu-btn { display: inline-flex; }
    .top { padding: 10px 16px; }
    .content { padding: 20px 16px; }
}

/* El ícono tiene trazos negros: siempre sobre fondo claro para leerse en ambos temas. */
img.logo { background: #ffffff; padding: 2px; border-radius: var(--radius-sm); }

/* ---------- Captura con marcador de clic ---------- */
.shot { position: relative; display: block; }
.shot img { display: block; width: 100%; height: auto; }
.hotspot { position: absolute; width: clamp(18px, 3.2%, 34px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid var(--brand); border-radius: 50%; background: rgba(255, 107, 53, 0.25); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85); pointer-events: none; }
.hotspot[hidden] { display: none; }

/* ---------- Bloques: tip (azul) y alerta (ámbar) ---------- */
:root, [data-theme="dark"] { --tip: #7cc0ff; --tip-bg: #132a40; --warn: #ffc861; --warn-bg: #3a2c10; }
[data-theme="light"] { --tip: #1a64b0; --tip-bg: #e8f2fc; --warn: #8a5a00; --warn-bg: #fff4dc; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid transparent; }
.callout-tip { background: var(--tip-bg); border-color: color-mix(in srgb, var(--tip) 35%, transparent); }
.callout-alert { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.callout-icon { flex: none; margin-top: 2px; }
.callout-tip .callout-icon { color: var(--tip); }
.callout-alert .callout-icon { color: var(--warn); }
.callout-title { font-weight: 700; margin: 0 0 2px; }
.section-title { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.01em; margin: 8px 0 0; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ---------- Encabezado de la guía: pasos · lectura · edición · autor ---------- */
.guide-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 6px 0 0; color: var(--ink-muted); font-size: 13px; line-height: 20px; }
.guide-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.guide-author .avatar { font-size: 9px; }
