/* Roadmap: cuaderno de bitácora. Papel cálido, tinta, títulos con serifa, etiquetas en
   monoespaciada y un acento terracota. Modo oscuro: carbón cálido. Sin nada de fuera (la CSP no
   deja cargar fuentes): pilas de fuentes del sistema. */

:root {
  --paper: #f4efe6;
  --card: #fffcf6;
  --ink: #221d17;
  --ink-2: #4b4237;
  --muted: #877b6c;
  --rule: #e2d9ca;
  --rule-2: #d3c8b6;
  --accent: #b8461d;
  --accent-soft: #f6dfd2;
  --mine: #9a5b00;
  --mine-soft: #fbecc9;
  --ok: #3d7a4b;
  --ok-soft: #dcecdc;
  --danger: #b3261e;
  /* Estados: siempre con su nombre al lado, nunca solo el color. */
  --st-activo: #b8461d;
  --st-pruebas: #b07a12;
  --st-publicado: #3d7a4b;
  --st-pausa: #7b7a76;
  --st-idea: #7a5c9a;
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16130f;
    --card: #1f1b16;
    --ink: #f1ebe1;
    --ink-2: #d0c6b7;
    --muted: #9b8f7f;
    --rule: #332d25;
    --rule-2: #443c32;
    --accent: #ef8a5c;
    --accent-soft: #3a2519;
    --mine: #f0b54a;
    --mine-soft: #362a14;
    --ok: #7cc58b;
    --ok-soft: #1d3022;
    --danger: #ff8a7f;
    --st-activo: #ef8a5c;
    --st-pruebas: #e3b14b;
    --st-publicado: #7cc58b;
    --st-pausa: #a19c94;
    --st-idea: #b597d6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.005em; line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* --- Cabecera ------------------------------------------------------------------------------- */
.top { display: flex; align-items: center; gap: 1rem; max-width: 1240px; margin: 0 auto;
  padding: 1rem 16px .6rem; padding-top: max(1rem, env(safe-area-inset-top)); border-bottom: 1px solid var(--rule); }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); font: 600 1.25rem var(--serif); }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; border-radius: 6px; }
.top-links { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; font: .8rem var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.top-links a, .top-links .link { color: var(--muted); font: inherit; letter-spacing: inherit; text-transform: inherit; }
.top-links a[aria-current="page"] { color: var(--ink); }
.top-links form { display: contents; }

main { max-width: 1240px; margin: 0 auto; padding: 1.4rem 16px 3rem; }
main.bare { max-width: 440px; padding-top: 10vh; }
.app-version { margin-top: 2.5rem; color: var(--muted); font: .72rem var(--mono); letter-spacing: .05em; }

/* --- Piezas comunes ------------------------------------------------------------------------- */
.panel, .card { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 1.1rem 1.2rem; margin: 0 0 1rem; }
.label-head, .label { font: 600 .74rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 .8rem; }
.mono-label { font: .74rem var(--mono); color: var(--muted); letter-spacing: .03em; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head-actions { display: flex; gap: .5rem; }
.split, .cols { display: grid; gap: 1rem; }
@media (min-width: 900px) { .split, .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Formularios y botones */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; color: var(--ink-2); }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule-2); border-radius: 10px; padding: .6rem .7rem; min-height: 44px; }
textarea { resize: vertical; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.row.compact { grid-template-columns: 1fr auto; align-items: end; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px;
  padding: .55rem 1.05rem; border-radius: 999px; border: 1px solid transparent; font: 600 .92rem var(--sans);
  cursor: pointer; color: var(--ink); background: transparent; }
button.primary, .button.primary { background: var(--ink); color: var(--paper); }
button.primary:hover { background: var(--accent); }
button.secondary, .button.secondary, .button.ghost { border-color: var(--rule-2); background: var(--card); }
button.secondary:hover, .button.ghost:hover { border-color: var(--accent); text-decoration: none; }
button.link, .link { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); font-weight: 500; cursor: pointer; }
.danger-text { color: var(--danger) !important; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.actions form { display: contents; }
.flash { padding: .7rem .9rem; border-radius: 10px; margin: 0 0 1rem; border: 1px solid; font-size: .92rem; }
.flash.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.flash.error { background: color-mix(in srgb, var(--danger) 12%, var(--card)); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.segmented { display: flex; border: 1px solid var(--rule-2); border-radius: 999px; padding: 3px; margin: 0; gap: 2px; }
.segmented label { flex: 1; display: block; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.segmented span { display: block; text-align: center; padding: .45rem .5rem; border-radius: 999px; font-size: .85rem; cursor: pointer; color: var(--ink-2); }
.segmented input:checked + span { background: var(--ink); color: var(--paper); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
h2.inline { display: inline; }

/* --- Resumen -------------------------------------------------------------------------------- */
.hero { padding: .6rem 0 1.4rem; }
.kicker { font: .76rem var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: .5rem; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.7rem); font-weight: 500; max-width: 22ch; }
.hero em { font-style: normal; color: var(--accent); font-weight: 700; }
.hero em.mine { color: var(--mine); }
.hero-sub { font: .82rem var(--mono); color: var(--muted); }
.mine-panel { border-color: color-mix(in srgb, var(--mine) 45%, var(--rule)); background: color-mix(in srgb, var(--mine-soft) 55%, var(--card)); }
.mine-panel .label-head { color: var(--mine); }

.board-section { margin: 1.4rem 0 1rem; }
.lanes { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .lanes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1150px) { .lanes { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
.lane { display: flex; flex-direction: column; gap: .7rem; }
.lane-head { display: flex; align-items: center; gap: .5rem; font: 600 .78rem var(--mono); text-transform: uppercase;
  letter-spacing: .09em; color: var(--ink-2); margin: 0; padding-bottom: .4rem; border-bottom: 1px solid var(--rule); }
.lane-head .count { margin-left: auto; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; background: var(--st-pausa); }
.dot.st-activo { background: var(--st-activo); } .dot.st-pruebas { background: var(--st-pruebas); }
.dot.st-publicado { background: var(--st-publicado); } .dot.st-idea { background: var(--st-idea); }
.project-card { display: flex; flex-direction: column; gap: .35rem; padding: .9rem 1rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--rule); border-radius: 12px; }
.project-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.project-name { font: 600 1.12rem var(--serif); }
.project-now { color: var(--ink-2); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { font: .72rem var(--mono); padding: .1rem .45rem; border-radius: 6px; background: var(--paper); border: 1px solid var(--rule); color: var(--ink-2); }
.chip.live { border-color: color-mix(in srgb, var(--st-publicado) 45%, var(--rule)); }
.project-foot { display: flex; flex-wrap: wrap; gap: .25rem .7rem; margin-top: .2rem; font: .72rem var(--mono); color: var(--muted); }
.project-foot .when { margin-left: auto; }
.mine-count { color: var(--mine); font-weight: 700; }
.archived-list { margin: 1rem 0; }
.archived-list ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.add-form > summary { display: inline-flex; }
.add-form[open] > summary { margin-bottom: .7rem; }
.add-form[open] { flex-basis: 100%; }

/* Línea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { display: grid; grid-template-columns: 4.2rem 1fr auto; gap: .6rem; align-items: baseline; padding: .45rem 0 .45rem 1rem;
  border-left: 2px solid var(--rule); position: relative; font-size: .92rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .85rem; width: 10px; height: 10px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--rule-2); }
.timeline li.who-claude::before { border-color: var(--accent); }
.timeline li.who-tu::before { border-color: var(--ok); }
.tl-who { font: 600 .7rem var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.who-claude .tl-who { color: var(--accent); }
.who-tu .tl-who { color: var(--ok); }
.tl-text { color: var(--ink-2); overflow-wrap: anywhere; }
.tl-text a { color: inherit; }
.tl-text a:hover { color: var(--accent); }
.tl-when { font: .72rem var(--mono); color: var(--muted); white-space: nowrap; }

/* --- Tareas ---------------------------------------------------------------------------------- */
.items { list-style: none; margin: 0; padding: 0; }
.item { padding: .6rem 0; border-top: 1px dashed var(--rule-2); }
.item:first-child { border-top: 0; padding-top: 0; }
.item-main { display: flex; gap: .7rem; align-items: flex-start; }
.item-main form { display: contents; }
.tick { flex: 0 0 auto; width: 24px; height: 24px; min-height: 0; padding: 0; margin-top: .1rem; border-radius: 6px;
  border: 1.5px solid var(--rule-2); background: var(--card); color: var(--ok); font-weight: 700; line-height: 1; }
.tick:hover { border-color: var(--ok); }
.item.done .tick { background: var(--ok-soft); border-color: var(--ok); }
.item.done .item-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.item-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.item-title { overflow-wrap: anywhere; }
.item-project { font-weight: 600; color: var(--ink); }
.item-note { color: var(--muted); font-size: .85rem; white-space: pre-line; overflow-wrap: anywhere; }
.item-edit { margin: .25rem 0 0 2.15rem; }
.item-edit > summary { display: inline; font-size: .8rem; }
.item-edit[open] > summary { display: block; margin-bottom: .5rem; }
.prio { font: .66rem var(--mono); padding: .05rem .4rem; border-radius: 4px; text-transform: uppercase; letter-spacing: .06em;
  vertical-align: middle; border: 1px solid var(--rule-2); color: var(--muted); }
.prio-alta { border-color: var(--accent); color: var(--accent); }
.prio-media { border-color: var(--mine); color: var(--mine); }

/* --- Proyecto -------------------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; font: 600 .7rem var(--mono); text-transform: uppercase;
  letter-spacing: .08em; padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--rule-2); color: var(--ink-2); vertical-align: middle; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--st-pausa); }
.badge.st-activo::before { background: var(--st-activo); } .badge.st-pruebas::before { background: var(--st-pruebas); }
.badge.st-publicado::before { background: var(--st-publicado); } .badge.st-idea::before { background: var(--st-idea); }
h1 .badge { margin-left: .5rem; }
.project-info p { white-space: pre-line; }
.pairs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem 1.2rem; margin: 0; }
.pairs div { display: flex; flex-direction: column; }
.pairs dt { font: .7rem var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pairs dd { margin: .1rem 0 0; font-weight: 600; }
.now { margin-top: 1rem; padding: .8rem 1rem; border-left: 3px solid var(--accent); background: var(--paper); border-radius: 0 10px 10px 0; }
.now p { margin: .25rem 0 0; white-space: pre-line; }

/* --- Ajustes y acceso ------------------------------------------------------------------------ */
.tokens { list-style: none; margin: 0 0 1rem; padding: 0; }
.tokens li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem 0; border-top: 1px dashed var(--rule-2); }
.tokens li:first-child { border-top: 0; }
.tokens li.archived { opacity: .55; }
.token-once code { display: block; margin-top: .4rem; padding: .55rem; border-radius: 8px; background: var(--card);
  font: .85rem var(--mono); overflow-wrap: anywhere; user-select: all; }
.auth { text-align: left; }
.logo { font: 600 2rem var(--serif); margin-bottom: 1.2rem; }
.qr { background: #fff; padding: .6rem; border-radius: 10px; width: max-content; margin: 0 auto 1rem; }
.qr svg { display: block; width: 200px; height: 200px; }
.secret, .code { font-family: var(--mono); letter-spacing: .08em; }
.code { font-size: 1.4rem; text-align: center; }

@media (max-width: 420px) {
  h1 { font-size: 1.6rem; }
  .row { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 3.6rem 1fr; }
  .tl-when { grid-column: 2; }
}
