/* Fio — estilos base (funcionais; o design gráfico vem na fase seguinte) */
:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d232b; --muted: #6b7380; --line: #e3e1da; --soft: #efede7;
  --accent: #1f3a5f; --accent-ink: #ffffff; --accent-soft: #e4ebf4; --warn: #b4530a; --danger: #b42318; --ok: #1e7a45;
  --cold: #3b82c4; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --s-idea: #a855f7; --s-active: #16a34a; --s-waiting: #d97706; --s-paused: #64748b; --s-done: #0ea5e9; --s-archived: #a3a3a3;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --panel: #1c2027; --ink: #e6e8eb; --muted: #9aa3ae; --line: #2c323b; --soft: #232831;
    --accent: #8fb3e0; --accent-ink: #0f1a28; --accent-soft: #233246; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1rem; margin: 0 0 .7rem; }
input, textarea, select, button { font: inherit; color: inherit; }
input:not([type=checkbox]), textarea, select {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 2.6rem; line-height: 1.5; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--danger); min-height: 1.2em; }
.grow { flex: 1; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: .5rem; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: .35rem 0; border-bottom: 1px solid var(--soft); }
.plain li:last-child { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }

.btn {
  display: inline-flex; align-items: center; gap: .3rem; padding: .45rem .8rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { color: var(--danger); }
.btn.small { padding: .2rem .5rem; font-size: .82rem; }
.linklike { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }
.chip {
  padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  font-size: .85rem; white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding: .2rem 0 .4rem; scrollbar-width: none; }
.pill { font-size: .72rem; padding: .05rem .5rem; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.s-active { background: color-mix(in srgb, var(--s-active) 15%, transparent); color: var(--s-active); }
.pill.s-waiting { background: color-mix(in srgb, var(--s-waiting) 15%, transparent); color: var(--s-waiting); }
.pill.s-idea { background: color-mix(in srgb, var(--s-idea) 15%, transparent); color: var(--s-idea); }
.pill.s-done { background: color-mix(in srgb, var(--s-done) 15%, transparent); color: var(--s-done); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--s-paused); }
.dot.s-active { background: var(--s-active); } .dot.s-waiting { background: var(--s-waiting); } .dot.s-idea { background: var(--s-idea); }
.dot.s-done { background: var(--s-done); } .dot.s-archived { background: var(--s-archived); }
.badge { background: var(--warn); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .4rem; margin-left: auto; }
.badge:empty { display: none; }

/* ---------- captura (mobile) ---------- */
body.capture { min-height: 100dvh; display: flex; flex-direction: column; }
.cap-head {
  display: flex; align-items: center; gap: .5rem; padding: calc(.6rem + env(safe-area-inset-top)) .8rem .6rem;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2;
}
.cap-status { flex: 1; font-size: .8rem; color: var(--muted); text-align: center; }
.cap-status.ok { color: var(--ok); } .cap-status.offline, .cap-status.local { color: var(--warn); }
.cap-main { flex: 1; padding: .8rem; display: flex; flex-direction: column; gap: .8rem; max-width: 760px; width: 100%; margin: 0 auto; }
.cap-text {
  min-height: 45dvh; font-size: 1.1rem; border-radius: var(--radius); padding: .9rem; resize: none; border: 1px solid var(--line);
}
.cap-link { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; }
.cap-h { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: .3rem 0; }
.cap-recent { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
.cap-recent li { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; display: flex; flex-direction: column; cursor: pointer; }
.cap-snip { white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- login ---------- */
body.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); background: var(--panel); padding: 1.6rem; border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .8rem; }
.login-card h1 { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }

/* ---------- gestor ---------- */
body.app { display: flex; min-height: 100dvh; }
.side {
  width: 280px; flex: none; background: var(--panel); border-right: 1px solid var(--line); height: 100dvh; position: sticky; top: 0;
  display: flex; flex-direction: column; padding: .8rem .6rem; gap: .5rem; overflow: hidden;
}
.brand { display: flex; align-items: center; justify-content: space-between; padding: 0 .3rem; }
.logo { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--ink); display: flex; gap: .4rem; align-items: center; }
.search { padding: .4rem .6rem !important; }
.nav { display: flex; flex-direction: column; }
.nav a { display: flex; gap: .5rem; align-items: center; padding: .35rem .5rem; border-radius: 7px; text-decoration: none; color: var(--ink); }
.nav a:hover { background: var(--soft); }
.nav a.cur { background: var(--accent-soft); font-weight: 600; }
.nav.bottom { border-top: 1px solid var(--line); padding-top: .4rem; }
.tree-head { display: flex; justify-content: space-between; align-items: center; padding: .3rem .5rem 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-radius: 6px; }
.tree { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree-row { display: flex; align-items: center; gap: .2rem; padding: .15rem .4rem .15rem calc(.2rem + var(--d) * .9rem); border-radius: 6px; }
.tree-row:hover { background: var(--soft); }
.tree-row.cur { background: var(--accent-soft); }
.tree-row.dim { opacity: .55; }
.tree-row.over, .tree-head.over { outline: 2px dashed var(--accent); }
.caret { width: 1.1rem; flex: none; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; font-size: .75rem; transition: transform .15s; }
.caret.open { transform: rotate(90deg); }
.tree-link { flex: 1; display: flex; gap: .35rem; text-decoration: none; color: var(--ink); min-width: 0; font-size: .92rem; }
.tree-link .tt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cold-dot { width: 7px; height: 7px; border-radius: 50%; border: 2px solid var(--cold); flex: none; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: .5rem; padding: .6rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 3; }
.crumbs { flex: 1; display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; font-size: .9rem; min-width: 0; }
.crumbs a { text-decoration: none; color: var(--ink); }
.crumbs .sep { color: var(--muted); }
.main { padding: 1.2rem; max-width: 1280px; width: 100%; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.cols, .node-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.lbl { display: block; font-size: .8rem; color: var(--muted); margin: .7rem 0 .25rem; font-weight: 600; }

.hello .lead { color: var(--muted); margin-top: 0; }
.stats { display: flex; gap: .8rem; margin: 1rem 0 1.4rem; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; min-width: 120px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.stat b { font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .82rem; }
.stat.warn b { color: var(--warn); }
.date { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .82rem; min-width: 8.5rem; display: inline-block; }
.late .date { color: var(--danger); }

.resume-card { border: 1px solid var(--line); border-left: 3px solid var(--cold); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .6rem; cursor: pointer; }
.resume-card:hover { background: var(--soft); }
.resume-card header { display: flex; justify-content: space-between; gap: .5rem; }
.sit { margin: .35rem 0 0; white-space: pre-wrap; color: var(--ink); font-size: .9rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.next { margin: .3rem 0 0; color: var(--accent); font-size: .9rem; font-weight: 500; }
.idle { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.idle.cold { color: var(--cold); font-weight: 700; }

.filters { margin-bottom: 1rem; }
.map { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; align-items: start; }
.ncard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; cursor: pointer; box-shadow: var(--shadow); border-top: 3px solid var(--s-paused); }
.ncard.st-active { border-top-color: var(--s-active); } .ncard.st-waiting { border-top-color: var(--s-waiting); }
.ncard.st-idea { border-top-color: var(--s-idea); } .ncard.st-done { border-top-color: var(--s-done); } .ncard.st-archived { opacity: .6; }
.ncard.stale { box-shadow: 0 0 0 1px var(--cold) inset, var(--shadow); }
.ncard:hover { border-color: var(--accent); }
.ncard header { display: flex; gap: .4rem; align-items: center; }
.ncard header b { flex: 1; min-width: 0; }
.ncard footer { display: flex; gap: .7rem; margin-top: .5rem; flex-wrap: wrap; align-items: center; }
.ncard.sub { box-shadow: none; padding: .5rem .6rem; border-top-width: 2px; background: var(--bg); }
.ncard-kids { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.kids { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .6rem; }

.node-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.icon-input { width: 3.2rem !important; text-align: center; font-size: 1.5rem; padding: .2rem !important; border-color: transparent !important; background: transparent !important; }
.title-input { font-size: 1.6rem; font-weight: 700; border-color: transparent !important; background: transparent !important; padding: .2rem .4rem !important; }
.title-input:hover, .icon-input:hover { background: var(--panel) !important; }
.meta { gap: .8rem; margin-bottom: 1rem; font-size: .85rem; }
.meta label { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
.meta select, .meta input[type=date] { width: auto; padding: .25rem .4rem; }
.meta select { max-width: 220px; }
.check { cursor: pointer; }
.resume { border-left: 3px solid var(--accent); }

.todos { list-style: none; padding: 0; margin: 0 0 .4rem; }
.todos li { display: flex; gap: .4rem; align-items: center; padding: .15rem 0; }
.todos li.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-text { border-color: transparent !important; background: transparent !important; padding: .2rem .3rem !important; }
.todo-text:focus { background: var(--panel) !important; }
.todo-date { width: 9.5rem !important; padding: .15rem .3rem !important; font-size: .8rem; border-color: transparent !important; background: transparent !important; color: var(--muted); }
.todo-line { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); flex: none; }

.notes { list-style: none; padding: 0; margin: .8rem 0 0; display: flex; flex-direction: column; gap: .6rem; }
.note { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; }
.card .note { background: var(--bg); }
.note-body { white-space: pre-wrap; word-wrap: break-word; cursor: text; min-height: 1.4em; }
.note-meta { display: flex; gap: .4rem; align-items: center; margin-top: .4rem; flex-wrap: wrap; }
.small-select { width: auto !important; max-width: 200px; padding: .15rem .3rem !important; font-size: .8rem; }

.links { padding-left: 1.1rem; margin: .5rem 0; word-break: break-all; }
.drop { border: 2px dashed var(--line); border-radius: 8px; padding: .9rem; text-align: center; color: var(--muted); font-size: .85rem; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.files { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-direction: column; gap: .4rem; }
.files li { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.files img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.files a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; gap: 1rem; align-items: flex-start; padding: .6rem .4rem; border-bottom: 1px solid var(--line); }
.history li > .muted { min-width: 9rem; }
.history li.reverted { opacity: .5; }
.trash li { display: flex; gap: .6rem; align-items: center; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translate(-50%, 150%);
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; display: flex; gap: .8rem; align-items: center;
  transition: transform .2s, opacity .2s; z-index: 50; max-width: calc(100vw - 2rem); opacity: 0; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast .btn { background: transparent; color: var(--bg); border-color: currentColor; }

.only-mobile { display: none; }
.scrim { display: none; }
@media (max-width: 860px) {
  .only-mobile { display: inline-flex; }
  .side { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.side-open .side { transform: none; }
  body.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; }
  .cols, .node-grid { grid-template-columns: 1fr; }
  .main { padding: .8rem; }
  .top { padding: .5rem .8rem; }
  .title-input { font-size: 1.25rem; }
  .map { grid-template-columns: 1fr; }
}
