/* Remanso — identidade em docs/MANIFESTO.md
   Regra: nenhuma cor de alerta, nenhuma animação longa, nada pulsando. */

:root {
  --papel: #F2EEE5;
  --papel-2: #E8E2D5;
  --papel-3: #DDD6C6;
  --tinta: #1F1E1B;
  --tinta-suave: #6B675E;
  --agua: #4F6B68;
  --barro: #9A7457;
  --linha: rgba(31, 30, 27, .14);

  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r: 10px;
  --t: 160ms ease;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --papel: #1B1A17;
  --papel-2: #24221E;
  --papel-3: #2E2B26;
  --tinta: #E9E4D8;
  --tinta-suave: #9C968A;
  --agua: #8FB0AB;
  --barro: #C49A7A;
  --linha: rgba(233, 228, 216, .14);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papel: #1B1A17; --papel-2: #24221E; --papel-3: #2E2B26;
    --tinta: #E9E4D8; --tinta-suave: #9C968A; --agua: #8FB0AB; --barro: #C49A7A;
    --linha: rgba(233, 228, 216, .14);
    color-scheme: dark;
  }
}

@media (prefers-reduced-motion: reduce) { :root { --t: 0ms linear; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--papel);
  color: var(--tinta);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--tinta-suave); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.btn {
  border: 1px solid var(--linha);
  background: transparent;
  border-radius: 999px;
  padding: .45em 1.05em;
  transition: background var(--t), border-color var(--t);
}
.btn:hover { background: var(--papel-2); }
.btn.primary { background: var(--agua); border-color: var(--agua); color: var(--papel); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.quiet { border-color: transparent; color: var(--tinta-suave); }
.btn:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--agua); outline-offset: 2px; }

input[type="text"], input[type="date"], input[type="time"], input[type="number"], textarea, select {
  background: var(--papel);
  border: 1px solid var(--linha);
  border-radius: 8px;
  padding: .45em .65em;
  width: 100%;
}
textarea { resize: vertical; min-height: 6em; }
label { display: block; font-size: .85rem; color: var(--tinta-suave); margin-bottom: .25em; }

/* ---------- Estrutura ---------- */
.shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.side {
  border-right: 1px solid var(--linha);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.2rem; padding: 0 8px; }
.mark { width: 24px; height: 24px; fill: none; stroke: var(--tinta); stroke-width: 2; }
.mark line { stroke: var(--agua); stroke-linecap: round; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  text-align: left; background: none; border: 0; border-radius: 8px;
  padding: .55em .8em; color: var(--tinta-suave);
  transition: background var(--t), color var(--t);
}
.nav button:hover { background: var(--papel-2); color: var(--tinta); }
.nav button.is-active { background: var(--papel-2); color: var(--tinta); }
.theme-toggle { margin-top: auto; align-self: flex-start; background: none; border: 0; font-size: 1.2rem; color: var(--tinta-suave); padding: 8px; }

.main { padding: 22px clamp(16px, 4vw, 48px) 80px; max-width: 1100px; width: 100%; }
.top { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.status { margin: 0; color: var(--tinta-suave); font-size: .92rem; }

/* Troca de conta */
.switcher { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  border: 1px solid var(--linha); background: transparent; border-radius: 999px;
  padding: .3em .85em; font-size: .88rem; color: var(--tinta-suave);
  display: inline-flex; gap: .45em; align-items: center;
  transition: background var(--t), color var(--t);
}
.chip:hover { color: var(--tinta); }
.chip.is-active { background: var(--tinta); color: var(--papel); border-color: var(--tinta); }
.chip .net { font-family: var(--mono); font-size: .72rem; opacity: .7; text-transform: uppercase; }

/* ---------- Barra de ferramentas da view ---------- */
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.bar .left, .bar .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--linha); border-radius: 999px; padding: 2px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: .3em .9em; color: var(--tinta-suave); font-size: .88rem; }
.seg button.is-active { background: var(--papel-2); color: var(--tinta); }

/* ---------- Grade ---------- */
.grid {
  --cols: 3; --ratio: 3 / 4;
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 3px;
  max-width: 560px; user-select: none;
}
.grid.wide { --cols: 2; max-width: 760px; gap: 10px; }
.tile {
  position: relative; aspect-ratio: var(--ratio); overflow: hidden;
  background: var(--papel-3); border-radius: 2px; touch-action: none;
}
.grid.wide .tile { border-radius: 6px; }
.tile img, .tile .tone { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.draft { cursor: grab; }
.tile.draft::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border: 1.5px dashed color-mix(in srgb, var(--papel) 85%, transparent);
  outline: 1px solid color-mix(in srgb, var(--tinta) 25%, transparent); outline-offset: -1px;
}
.tile .tag {
  position: absolute; left: 6px; bottom: 6px; z-index: 1;
  font: 500 .7rem/1 var(--mono); padding: 4px 6px; white-space: nowrap; max-width: calc(100% - 12px); overflow: hidden; border-radius: 4px;
  background: color-mix(in srgb, var(--papel) 88%, transparent); color: var(--tinta);
}
.tile .kind { position: absolute; right: 6px; top: 6px; font-size: .7rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.tile.dragging { opacity: .25; }
.tile.drop-target { outline: 2px solid var(--agua); outline-offset: -2px; }
.ghost {
  position: fixed; pointer-events: none; z-index: 50; width: 120px; aspect-ratio: var(--ratio, 3/4);
  border-radius: 4px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.25); transform: rotate(-2deg);
}
.ghost img, .ghost .tone { width: 100%; height: 100%; object-fit: cover; }
.grid-hint { font-size: .85rem; margin: 10px 0 0; }
.grid-empty { padding: 40px 0; }

/* ---------- Fila ---------- */
.cadence {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px;
  background: var(--papel-2); border-radius: var(--r); padding: 16px; margin-bottom: 18px; align-items: end;
}
.meter { height: 4px; background: var(--papel-3); border-radius: 4px; overflow: hidden; margin: 6px 0 18px; max-width: 420px; }
.meter > span { display: block; height: 100%; background: var(--agua); }
.queue { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--linha); }
.queue li {
  display: grid; grid-template-columns: 92px 48px 1fr auto; gap: 14px; align-items: center;
  padding: 10px 2px; border-bottom: 1px solid var(--linha);
}
.queue .when { font-family: var(--mono); font-size: .82rem; color: var(--tinta-suave); line-height: 1.3; }
.queue .thumb { width: 48px; aspect-ratio: 3/4; border-radius: 3px; overflow: hidden; background: var(--papel-3); }
.queue .thumb img, .queue .thumb .tone { width: 100%; height: 100%; object-fit: cover; }
.queue .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue .over { opacity: .5; }
.note-line { font-size: .85rem; color: var(--tinta-suave); margin-top: 6px; }

/* ---------- Resumo ---------- */
.calm-card {
  background: var(--papel-2); border-radius: var(--r); padding: 28px; max-width: 520px;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 26px; max-width: 520px; }
.stat { border-top: 1px solid var(--linha); padding-top: 10px; }
.stat .v { font: 400 1.5rem/1.2 var(--mono); }
.stat .k { font-size: .82rem; color: var(--tinta-suave); }
.table { width: 100%; max-width: 720px; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 400; color: var(--tinta-suave); font-size: .8rem; padding: 6px 8px; border-bottom: 1px solid var(--linha); }
.table td { padding: 8px; border-bottom: 1px solid var(--linha); }
.table td.num, .table th.num { text-align: right; }
.comments { list-style: none; padding: 0; margin: 0; max-width: 620px; }
.comments li { padding: 12px 0; border-bottom: 1px solid var(--linha); }
.comments .who { font-size: .82rem; color: var(--tinta-suave); }
.reply { display: flex; gap: 8px; margin-top: 8px; }
.reply input { flex: 1; }
.reply-sent { font-size: .85rem; color: var(--agua); margin-top: 6px; }

/* ---------- Planner ---------- */
.planner { display: grid; grid-template-columns: 210px 1fr; gap: 22px; min-height: 70vh; }
.pages { display: flex; flex-direction: column; gap: 2px; }
.pages button.page {
  text-align: left; border: 0; background: none; border-radius: 8px; padding: .5em .7em; color: var(--tinta-suave);
}
.pages button.page.is-active { background: var(--papel-2); color: var(--tinta); }
.pages .page small { display: block; font-family: var(--mono); font-size: .7rem; opacity: .7; }
.page-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.page-title { font-family: var(--serif); font-size: 1.5rem; border: 0 !important; background: transparent !important; padding: 0 !important; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tools .sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.tools .sw.is-active { border-color: var(--tinta); box-shadow: inset 0 0 0 2px var(--papel); }
.tools .sep { width: 1px; height: 20px; background: var(--linha); margin: 0 4px; }
.canvas-wrap {
  position: relative; border: 1px solid var(--linha); border-radius: var(--r); overflow: hidden;
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, var(--linha) 31px 32px),
    var(--papel);
  height: 520px; touch-action: none;
}
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }

/* ---------- Contas ---------- */
.nets { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.net-card { border: 1px solid var(--linha); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.net-card .acc { display: flex; justify-content: space-between; align-items: center; font-size: .92rem; }
.net-card .state { font-size: .78rem; color: var(--tinta-suave); }

/* ---------- Editor (dialog) ---------- */
.sheet {
  border: 0; border-radius: 14px; padding: 0; width: min(620px, 94vw);
  background: var(--papel); color: var(--tinta); box-shadow: 0 30px 80px rgba(0,0,0,.25);
}
.sheet::backdrop { background: rgba(20, 19, 17, .35); }
.sheet form { display: grid; grid-template-columns: 160px 1fr; gap: 18px; padding: 22px; }
.sheet .preview { aspect-ratio: 3/4; border-radius: 6px; overflow: hidden; background: var(--papel-3); }
.sheet .preview img, .sheet .preview .tone { width: 100%; height: 100%; object-fit: cover; }
.sheet .fields { display: flex; flex-direction: column; gap: 12px; }
.sheet .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet .actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--tinta); color: var(--papel); padding: .6em 1.1em; border-radius: 999px; font-size: .9rem;
  z-index: 60; opacity: 0; transition: opacity var(--t);
}
.toast.show { opacity: 1; }

.sheet.ask { width: min(400px, 92vw); }
.sheet.ask form { display: flex; flex-direction: column; gap: 14px; }
.sheet.ask .actions { justify-content: flex-end; }

/* ---------- Celular ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 40;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--linha); background: var(--papel); gap: 0;
  }
  .brand { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav button { font-size: .85rem; padding: .5em .6em; }
  .theme-toggle { margin: 0; }
  .main { padding-bottom: 100px; }
  .planner { grid-template-columns: 1fr; }
  .pages { flex-direction: row; overflow-x: auto; }
  .queue li { grid-template-columns: 70px 40px 1fr auto; gap: 10px; }
  .sheet form { grid-template-columns: 1fr; }
  .sheet .preview { max-width: 140px; }
  .canvas-wrap { height: 420px; }
}
