/* Tokens de DESIGN.md (cores, texto com contraste AA, elevacao, espacamento). */
:root {
  --ink-900: #171310;
  --ink-700: #46403a;
  --ink-500: #766e64;
  --ink-300: #d9d2c7;
  --surface: #ede8e0;
  --paper: #faf7f2;
  --accent: #b4552f;
  --accent-text: #a04a28;
  --on-accent: #ffffff;
  --muted-text: #6b6359;
  --success: #15803d;
  --success-bg: #e4f3e9;
  --success-text: #146c36;
  --warning: #b45309;
  --warning-bg: #fbeddc;
  --warning-text: #9a4508;
  --error: #b91c1c;
  --error-bg: #fbe4e2;
  --error-text: #b91c1c;
  --info: #2c5282;
  --info-bg: #e3ecf5;
  --info-text: #2c5282;
  --elevation-1: 0 8px 24px rgba(23, 19, 16, 0.12);
  --scrim: rgba(23, 19, 16, 0.32);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --s-2xs: 4px;
  --s-sm: 8px;
  --s-md: 16px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-2xl: 48px;
  --font-ui: "Instrument Sans", system-ui, sans-serif;
  --font-data: "DM Sans", system-ui, sans-serif;
  --font-read: "Fraunces", Georgia, serif;
  --ease-move: cubic-bezier(0.45, 0, 0.55, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink-900: #f3eee6;
    --ink-700: #d6cec2;
    --ink-500: #a89e91;
    --ink-300: #3a322b;
    --surface: #201a15;
    --paper: #171310;
    --accent: #d97757;
    --accent-text: #e38a6c;
    --on-accent: #171310;
    --muted-text: #b0a598;
    --success-bg: #12291b;
    --success-text: #7fd19c;
    --warning-bg: #2f2111;
    --warning-text: #f0b374;
    --error-bg: #331615;
    --error-text: #f19a93;
    --info-bg: #15223a;
    --info-text: #9fbde6;
    --scrim: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink-900);
  font: 400 14px/1.55 var(--font-ui);
  caret-color: var(--accent);
}
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent-text); }
h1, h2, h3 { font-weight: 500; margin: 0 0 var(--s-sm); }
h1 { font-size: 26px; }
h2 { font-size: 22px; }
.section-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-text);
  margin: var(--s-md) 0 var(--s-sm);
}
.muted { color: var(--muted-text); }
.num, table, .deadline, time { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: var(--s-md); top: var(--s-md); background: var(--paper); padding: var(--s-sm); z-index: 10; }

/* Botoes e formularios (UI em Instrument Sans, raio sm, alvo >= 44px). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-sm);
  min-height: 44px; padding: 0 var(--s-md);
  border: 1px solid var(--ink-300); border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-900);
  font: 500 14px var(--font-ui); cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-text { border-color: transparent; color: var(--accent-text); padding: 0 var(--s-sm); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
form.inline { display: inline; }
label { display: block; font-weight: 500; margin: var(--s-md) 0 var(--s-2xs); }
input[type="text"], input[type="email"], input[type="url"], input[type="password"], input[type="date"], input[type="time"], textarea, select {
  width: 100%; min-height: 44px; padding: var(--s-sm) var(--s-md);
  border: 1px solid var(--ink-300); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink-900); font: 400 14px var(--font-ui);
}
textarea { min-height: 96px; }
.form-narrow { max-width: 560px; }
.hint { font-size: 13px; color: var(--muted-text); margin: var(--s-2xs) 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-sm); margin-top: var(--s-lg); align-items: center; }

/* Estados (2B): rotulo em texto + token; nunca so cor. */
.tag { display: inline-block; padding: 1px var(--s-sm); border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; }
.tone-neutral { color: var(--muted-text); background: var(--surface); }
.tone-info { color: var(--info-text); background: var(--info-bg); }
.tone-warning { color: var(--warning-text); background: var(--warning-bg); }
.tone-error { color: var(--error-text); background: var(--error-bg); }
.tone-success { color: var(--success-text); background: var(--success-bg); }
.deadline.warn { color: var(--warning-text); }
.deadline.late { color: var(--error-text); }

/* Banners (2C, 2D): persistentes, com texto e uma acao. */
.banner {
  display: flex; flex-wrap: wrap; gap: var(--s-md); align-items: center; justify-content: space-between;
  padding: var(--s-md); border-radius: var(--radius-sm); margin-bottom: var(--s-md);
}
.banner p { margin: 0; }
.site-banner { border-radius: 0; margin: 0; }

/* Tabelas e listas: linhas com hairline, nunca pilhas de cards (4C). */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 600 12px var(--font-ui); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted-text); }
th, td { padding: var(--s-sm); border-bottom: 1px solid var(--ink-300); vertical-align: top; }
thead th { position: sticky; top: 0; background: var(--paper); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { border-bottom: 1px solid var(--ink-300); }

/* Casca: sidebar 220 + fila 260 + painel fluido (DESIGN.md, 6A). */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--ink-300); padding: var(--s-md); background: var(--paper); }
.sidebar .brand { font: 500 17px var(--font-read); margin-bottom: var(--s-md); display: block; color: var(--ink-900); text-decoration: none; }
.sidebar nav ul { list-style: none; margin: 0 0 var(--s-sm); padding: 0; }
.sidebar nav a { display: flex; justify-content: space-between; min-height: 36px; align-items: center; padding: 0 var(--s-sm); border-radius: var(--radius-sm); color: var(--ink-700); text-decoration: none; }
.sidebar nav a[aria-current="page"] { background: var(--surface); color: var(--ink-900); font-weight: 600; }
.sidebar .site-switcher select { min-height: 40px; }
.topbar { display: none; }
.page { padding: var(--s-lg); min-width: 0; }
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--s-md); margin-bottom: var(--s-lg); }
.logout { margin-top: var(--s-xl); }

.workspace { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 2 * var(--s-lg)); margin: calc(-1 * var(--s-lg)); }
.queue { border-right: 1px solid var(--ink-300); padding: var(--s-md); overflow-y: auto; }
.queue a.item { display: grid; grid-template-columns: auto 1fr auto; gap: var(--s-sm); padding: var(--s-sm); min-height: 44px; text-decoration: none; color: var(--ink-900); border-radius: var(--radius-sm); }
.queue a.item[aria-current="true"] { background: var(--surface); }
.queue .ref { font-family: var(--font-data); color: var(--muted-text); }
.queue .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel { padding: var(--s-lg); display: grid; grid-template-columns: minmax(0, 480px) minmax(220px, 300px); gap: var(--s-xl); align-content: start; }
.panel > .banner, .panel > header { grid-column: 1 / -1; }

/* Superficie de leitura: Fraunces, coluna de 480px. */
.reading { font: 400 18px/1.7 var(--font-read); max-width: 480px; }
.reading h1 { font: 500 28px/1.25 var(--font-read); margin-bottom: var(--s-md); }
.reading h2 { font: 500 22px/1.3 var(--font-read); margin: var(--s-xl) 0 var(--s-sm); }
.reading h3 { font: 500 19px/1.35 var(--font-read); margin: var(--s-lg) 0 var(--s-sm); }
.reading img, .featured { max-width: 100%; height: auto; border-radius: var(--radius-md); }
.qa { font-size: 13px; }
.qa details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: var(--s-sm); align-items: center; padding: var(--s-sm) 0; border-bottom: 1px solid var(--ink-300); }

/* Unidades isoladas (card): painel de job, dialogo, drawer. */
.card { background: var(--surface); border-radius: var(--radius-md); padding: var(--s-md); }
dialog { border: 0; border-radius: var(--radius-lg); padding: var(--s-lg); box-shadow: var(--elevation-1); background: var(--paper); color: var(--ink-900); max-width: 520px; width: calc(100% - 32px); }
dialog::backdrop { background: var(--scrim); }
.decision-bar { display: flex; flex-wrap: wrap; gap: var(--s-sm); margin-top: var(--s-lg); padding-top: var(--s-md); border-top: 1px solid var(--ink-300); }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: grid; grid-template-columns: 20px 1fr; gap: var(--s-sm); padding: var(--s-sm) 0; border-bottom: 1px solid var(--ink-300); }
.center-page { max-width: 440px; margin: 12vh auto; padding: 0 var(--s-md); }
.center-page .brand { font: 500 26px var(--font-read); display: block; margin-bottom: var(--s-lg); }

@media (prefers-reduced-motion: no-preference) {
  .job-step.current .dot { animation: pulse 1.2s var(--ease-move) infinite; }
}
@keyframes pulse { 50% { opacity: 0.35; } }

/* 768-1199: sidebar vira menu no cabecalho. */
@media (max-width: 1199px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: block; position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 5; box-shadow: var(--elevation-1); overflow-y: auto; }
  .topbar { display: flex; align-items: center; gap: var(--s-sm); padding: var(--s-sm) var(--s-md); border-bottom: 1px solid var(--ink-300); }
  .panel { grid-template-columns: minmax(0, 480px); }
}

/* <768: uma coluna por vez; barra fixa de 48px com as acoes. */
@media (max-width: 767px) {
  .page { padding: var(--s-md); }
  .workspace { grid-template-columns: 1fr; margin: calc(-1 * var(--s-md)); }
  .workspace.has-item .queue { display: none; }
  .workspace:not(.has-item) .panel { display: none; }
  .panel { padding: var(--s-md); gap: var(--s-md); }
  .reading { font-size: 17px; }
  .decision-bar { position: sticky; bottom: 0; background: var(--paper); padding: var(--s-sm) 0; }
  .decision-bar .btn { flex: 1 1 100%; min-height: 48px; }
  .desktop-only { display: none; }
}
@media (min-width: 768px) { .mobile-only { display: none; } }
.rows a.item { display: grid; grid-template-columns: 80px 1fr auto; gap: var(--s-sm); padding: var(--s-sm); min-height: 44px; align-items: center; color: var(--ink-900); text-decoration: none; }
.rows a.item:hover { background: var(--surface); }

/* Gates (1B): rodape fixo com hairline, sem sombra (5B). */
.gate { padding-bottom: 96px; }
.gate-footer { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: var(--s-sm); align-items: center; padding: var(--s-md) 0; background: var(--paper); border-top: 1px solid var(--ink-300); margin-top: var(--s-lg); }
.blocker { padding: var(--s-sm) 0; color: var(--warning-text); }
.proposal section { margin-bottom: var(--s-xl); }
.proposal h2 .count { font-family: var(--font-data); color: var(--muted-text); font-size: 14px; font-weight: 400; margin-left: var(--s-sm); }
.source-excerpt { color: var(--muted-text); font-style: italic; }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-md); }
.job-panel { max-width: 560px; margin-bottom: var(--s-lg); }
.job-step.done .dot { color: var(--success-text); }
.job-step.failed .dot { color: var(--error-text); }
.meter { display: grid; grid-template-columns: 90px 1fr auto; gap: var(--s-sm); align-items: center; padding: var(--s-sm) 0; border-bottom: 1px solid var(--ink-300); }
.meter .bar { height: 4px; background: var(--surface); border-radius: 2px; overflow: hidden; }
.meter .bar span { display: block; height: 100%; background: var(--accent); }
@media (max-width: 767px) {
  .side-by-side { grid-template-columns: 1fr; }
  .gate .editor { display: none; }
}

/* Edicao no rascunho (7A): a mesma coluna de leitura; o bloco ativo ganha a linha de acento na margem. */
.editor-toolbar { display: flex; gap: var(--s-sm); padding: var(--s-sm) 0; position: sticky; top: 0; background: var(--paper); border-bottom: 1px solid var(--ink-300); z-index: 1; }
.editable-block { display: block; width: 100%; border: 0; border-left: 2px solid transparent; padding: var(--s-2xs) var(--s-sm); margin: var(--s-sm) 0 var(--s-sm) calc(-1 * var(--s-sm)); background: transparent; color: var(--ink-900); font: 400 18px/1.7 var(--font-read); resize: vertical; }
.editable-block.kind-heading { font: 500 22px/1.3 var(--font-read); }
.editable-block:focus { outline: none; border-left-color: var(--accent); background: var(--surface); }
.editable-block:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.readonly-block { opacity: 0.8; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Ajustes da revisao visual (T17). */
.item-meta { display: flex; flex-wrap: wrap; gap: var(--s-sm); align-items: center; margin: 0 0 var(--s-sm); }
.decision-bar { position: sticky; bottom: 0; background: var(--paper); z-index: 1; }
.proposal > section, .proposal > details { margin-top: var(--s-xl); }
.blocker a { color: var(--warning-text); text-decoration: none; display: block; min-height: 32px; }
.blocker a:hover { text-decoration: underline; }
fieldset { border: 1px solid var(--ink-300); border-radius: var(--radius-sm); padding: var(--s-sm) var(--s-md); margin: var(--s-md) 0 0; display: flex; flex-wrap: wrap; gap: var(--s-2xs) var(--s-md); }
fieldset legend { font-weight: 500; padding: 0 var(--s-2xs); }
label.check, fieldset label { display: inline-flex; align-items: center; gap: var(--s-2xs); margin: 0; min-height: 44px; font-weight: 400; }
div.editable-block { min-height: 1.7em; white-space: normal; }
