@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Fraunces;
  src: url("../fonts/fraunces-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Fraunces;
  src: url("../fonts/fraunces-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #efe7db;
  --card: #fffdf8;
  --ink: #1c1915;
  --ink-soft: #3f3a34;
  --line: #e0d5c4;
  --pine: #143f3c;
  --pine-2: #1f6a62;
  --foam: #e5f3f0;
  --clay: #a24b32;
  --amber: #8a5a10;
  --amber-bg: #fff1d2;
  --red: #8d2e2e;
  --red-bg: #fde8e4;
  --ok: #1e6b45;
  --ok-bg: #e5f5ec;
  --shadow: 0 16px 40px rgba(48, 32, 14, 0.08);
  --sans: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  --serif: Fraunces, Georgia, "Iowan Old Style", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 16px;
  scroll-padding-bottom: 140px;
}

button, a, input, textarea, label { scroll-margin-bottom: 140px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at -10% -20%, #f7f1e6 0%, transparent 55%),
    radial-gradient(800px 420px at 120% -10%, #e7f2ef 0%, transparent 50%),
    var(--paper);
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.5;
}

img { max-width: 100%; height: auto; }

button, input, textarea { font: inherit; color: inherit; }

a { color: #0e4f4a; }

:focus-visible {
  outline: 3px solid var(--pine-2);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 40;
  background: white;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 10px;
}

.skip:focus { top: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 0;
}

.brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  line-height: 1;
}

.mark-oto {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.mark-family {
  margin-top: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.who {
  margin: 0;
  max-width: 55%;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--foam);
  color: var(--pine);
  font-size: 0.95rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

main {
  width: min(100%, 44rem);
  margin: 0 auto;
  padding: 18px 16px calc(108px + env(safe-area-inset-bottom));
}

.view { display: flex; flex-direction: column; gap: 14px; }

.view h1, .view h2, .view h3, .view p { margin: 0; }

h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 1.3rem + 2vw, 2.6rem);
  letter-spacing: -0.03em;
  line-height: 1.12;
}

h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.02em;
}

h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }

.lead { color: var(--ink-soft); font-size: 1.05rem; }

.hint, .meta { color: var(--ink-soft); font-size: 0.98rem; }

.hero-mark {
  width: 72px;
  height: 72px;
  border-radius: 22px;
}

.stack { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }

.field .hint { font-weight: 400; }

input[type="text"],
input[type="date"],
input[type="number"],
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cfc3b0;
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
}

textarea { min-height: 120px; resize: vertical; }

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

legend { font-weight: 700; padding: 0; }

.question, .choices { display: flex; flex-direction: column; gap: 8px; }

.segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: #f3eee6;
}

.segment-two { grid-template-columns: 1fr 1fr; }

.segment label { position: relative; }

.segment input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 4px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.segment input:checked + span { background: var(--pine); color: white; }
.segment input[value="nao"]:checked + span { background: #3f3a34; color: white; }
.segment input[value=""]:checked + span {
  background: white;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.segment input:focus { outline: none; }
.segment input:focus-visible + span {
  outline: 3px solid var(--pine-2);
  outline-offset: 2px;
}

.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.choice:has(input:checked) {
  border-color: var(--pine);
  background: var(--foam);
}

.choice input {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.2rem;
  accent-color: var(--pine);
}

.choice span { display: flex; flex-direction: column; gap: 2px; }
.choice small { color: var(--ink-soft); font-weight: 400; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: white;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary { background: var(--pine); color: white; }
.btn-secondary { background: white; color: var(--pine); border-color: #cfc3b0; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-danger { background: var(--red); color: white; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .btn { flex: 1 1 180px; }

.chips { display: flex; gap: 8px; }

.chip {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  font-weight: 700;
  cursor: pointer;
}

.chip[aria-pressed="true"] { background: var(--pine); color: white; border-color: var(--pine); }

.list { display: flex; flex-direction: column; gap: 12px; }

.entry, .note, .empty {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.empty { display: flex; flex-direction: column; gap: 12px; }

.kicker {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kicker.night { color: var(--pine); }
.kicker.episode { color: var(--clay); }
.entry-title { font-weight: 700; }

.snippet {
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-actions { display: flex; gap: 8px; }
.entry-actions .btn { flex: 1; }

.id-line { color: var(--ink-soft); font-size: 0.92rem; overflow-wrap: anywhere; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
}

.text-link { font-weight: 700; }

.counts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.counts div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
}

.counts dt { color: var(--ink-soft); font-weight: 400; }
.counts dd {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 500;
  line-height: 1.1;
}

.flag {
  margin: 0;
  padding: 12px 14px;
  border-left: 6px solid var(--amber);
  border-radius: 12px;
  background: var(--amber-bg);
}

.flag.red { border-left-color: var(--red); background: var(--red-bg); }

.flag-block { display: flex; flex-direction: column; gap: 10px; }

.disclaimer {
  margin: 0;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: white;
  font-weight: 700;
}

.ok-line {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ok-bg);
  color: var(--ok);
  font-weight: 700;
}

.form-error {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #6e1f1f;
  background: var(--red-bg);
  color: #6e1f1f;
  font-weight: 700;
}

.form-error:focus { outline: none; }

.danger-zone { border-color: #e7c4c0; }

.json {
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border-radius: 12px;
  background: #1c1915;
  color: #f4efe6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
}

details summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }

.send-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 8px 18px;
  box-shadow: var(--shadow);
}

.qr-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: center;
  overflow-x: auto;
}

.qr-instruction {
  max-width: 22rem;
  font-family: var(--serif);
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem);
  font-weight: 500;
  line-height: 1.25;
}

.qr-frame canvas {
  flex: 0 0 auto;
  max-width: none;
  background: #fff;
  box-shadow: 0 0 0 8px #fff;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.qr-note { max-width: 36rem; text-align: center; }

.qr-warning { display: flex; flex-direction: column; gap: 12px; }

.tabbar {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 12px;
}

.tabbar a[aria-current="page"] { color: var(--pine); background: var(--foam); }
.tabbar svg { display: block; }

body.is-welcome .tabbar { display: none; }
body.is-welcome main { padding-bottom: 32px; }
body.is-welcome .toast { bottom: 24px; }

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(28rem, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--pine);
  color: white;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
}

.toast.is-visible { opacity: 1; }

dialog {
  width: min(440px, calc(100vw - 32px));
  border: 0;
  border-radius: 20px;
  padding: 22px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(28, 25, 21, 0.46); }
dialog h2 { margin: 0 0 8px; }
dialog p { margin: 0; color: var(--ink-soft); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.noscript {
  margin: 16px;
  padding: 12px;
  background: white;
  border-radius: 12px;
}

@media (min-width: 700px) {
  .counts { grid-template-columns: 1fr 1fr; }
  main { padding-left: 28px; padding-right: 28px; }
  .topbar { padding-left: 28px; padding-right: 28px; }
}

@media (min-width: 900px) {
  html { scroll-padding-bottom: 24px; }
  button, a, input, textarea, label { scroll-margin-bottom: 24px; }

  body:not(.is-welcome) .app-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    grid-template-areas: "nav top" "nav main";
  }

  body:not(.is-welcome) .tabbar { grid-area: nav; }
  body:not(.is-welcome) .topbar { grid-area: top; }
  body:not(.is-welcome) main { grid-area: main; padding-bottom: 48px; }

  .tabbar {
    position: sticky;
    top: 0;
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    padding: 22px 14px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.88);
  }

  .tabbar a {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 12px;
    font-size: 1rem;
  }

  .toast { bottom: 24px; }
}

@media print {
  .topbar, .tabbar, .skip, .toast, .no-print, .chips, .entry-actions { display: none !important; }
  body, .app-shell { display: block !important; background: white !important; }
  main { max-width: none !important; padding: 0 !important; }
  .entry, .note, .empty, .counts div { box-shadow: none !important; }
  a { color: inherit; text-decoration: none; }
}

@page { margin: 14mm; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toast { transition: none; }
}
