/* Aparencia baseada nas medidas do Dontpad (ensaio de 14/11/2026):
   textarea em tela cheia, Arial 15px, texto #111 sobre branco, padding 9px 9px 30px, sem borda;
   fundo da pagina #f5f5f5; status no canto superior direito. Tema escuro e excecao aprovada (R10). */
:root {
  --bg: #f5f5f5;
  --paper: #fff;
  --ink: #111;
  --muted: #777;
  --line: #e2e2e2;
  --hover: #ececec;
  --accent: #2a6fdb;
  --ok: #3a9d5d;
  --warn: #d49a1f;
  --err: #cc3b3b;
  --sel: #b4d5fe;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161616;
  --paper: #1d1d1d;
  --ink: #e4e4e4;
  --muted: #9a9a9a;
  --line: #333;
  --hover: #2a2a2a;
  --accent: #79a8f2;
  --ok: #5fbf80;
  --warn: #e0b04a;
  --err: #ec6a6a;
  --sel: #2f4a73;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, Tahoma, Verdana, sans-serif;
  font-size: 15px;
}

/* ---- editor ---- */
body.editor { display: flex; overflow: hidden; }
#main { flex: 1; min-width: 0; height: 100%; }
#text {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 9px 9px 30px;
  border: 0;
  outline: none;
  resize: none;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  line-height: normal;
  tab-size: 4;
}
#text:disabled { background: var(--paper); color: var(--ink); opacity: 1; }
#text::selection { background: var(--sel); }
body.modifier-down #text { cursor: pointer; }

/* ---- menu superior discreto (R11) ---- */
#bar {
  position: fixed;
  top: 6px;
  right: 22px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  border-radius: 6px;
  background: var(--paper);
  opacity: 0.4;
  transition: opacity 0.15s;
  font-size: 12px;
  color: var(--muted);
  z-index: 10;
}
#bar:hover, #bar:focus-within { opacity: 1; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
#bar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  cursor: pointer;
}
#bar button:hover { background: var(--hover); color: var(--ink); }
#bar button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#bar button[aria-pressed="true"] { color: var(--ink); }
#bar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
#bar svg .fill { fill: currentColor; stroke: none; }
#presence, #status { display: inline-flex; align-items: center; gap: 3px; padding: 0 5px; white-space: nowrap; }
#presence svg { width: 14px; height: 14px; }
#status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
#status[data-state="saved"] .dot { background: var(--ok); }
#status[data-state="pending"] .dot { background: var(--warn); }
#status[data-state="offline"] .dot { background: var(--warn); box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--warn); }
#status[data-state="error"] .dot { background: var(--err); }
#status[data-state="error"] { color: var(--err); }

/* ---- arvore lateral recolhivel (R27, R40) ---- */
#tree {
  flex: 0 0 240px;
  height: 100%;
  overflow: auto;
  padding: 10px 6px 30px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
}
#tree[hidden] { display: none; }
#tree ul { list-style: none; margin: 0; padding: 0; }
#tree ul ul { padding-left: 14px; }
#tree .row { display: flex; align-items: center; min-height: 24px; border-radius: 4px; }
#tree .row:hover { background: var(--hover); }
#tree .tog {
  flex: 0 0 18px;
  height: 20px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
}
#tree .tog:disabled { cursor: default; visibility: hidden; }
#tree a {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
  padding: 2px 4px;
}
#tree a.empty { color: var(--muted); }
#tree a[aria-current="page"] { font-weight: bold; }
#tree .note { color: var(--muted); padding: 2px 22px; font-style: italic; }

/* ---- aviso ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  z-index: 20;
}
#toast.error { background: var(--err); color: #fff; }

/* ---- tela estreita ---- */
@media (max-width: 640px) {
  #bar { right: 8px; top: 4px; }
  #status-text { display: none; }
  #tree { position: fixed; inset: 0 auto 0 0; width: min(80vw, 280px); z-index: 15; box-shadow: 2px 0 8px rgba(0,0,0,.2); }
}

/* ---- pagina inicial ---- */
body.home { display: flex; align-items: center; justify-content: center; padding: 16px; }
.home-box { width: 100%; max-width: 520px; text-align: center; }
.home-box h1 { font-size: 34px; font-weight: normal; margin: 0 0 18px; }
.home-form { display: flex; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.home-form label { padding: 0 2px 0 10px; color: var(--muted); white-space: nowrap; }
.home-form input { flex: 1; min-width: 0; padding: 10px 6px; border: 0; outline: none; background: none; color: var(--ink); font: inherit; }
.home-form button { padding: 10px 14px; border: 0; border-left: 1px solid var(--line); background: var(--hover); color: var(--ink); font: inherit; cursor: pointer; }
.home-box p { color: var(--muted); font-size: 13px; margin-top: 14px; }
.home-theme { position: fixed; top: 8px; right: 12px; border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 12px; }
