:root {
  --bg: #fdf9ee;
  --surface: #ffffff;
  --ink: #171512;
  --ink-soft: #5c554a;
  --line: #e2d9c6;
  --brand: #8a4b00;
  --brand-ink: #ffffff;
  --accent: #0b6e4f;
  --ok: #0b6e4f;
  --error: #a3241c;
  --error-bg: #fdeceb;
  --card-bg: #fffdf7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 21, 18, 0.06), 0 8px 24px rgba(23, 21, 18, 0.07);
  --focus: #0b57d0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110d;
    --surface: #1f1b15;
    --ink: #f6f0e5;
    --ink-soft: #c4b9a7;
    --line: #3a3227;
    --brand: #f4c542;
    --brand-ink: #1a1408;
    --accent: #63e0b4;
    --ok: #63e0b4;
    --error: #ff9c94;
    --error-bg: #3a1a19;
    --card-bg: #26211a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
    --focus: #9dc4ff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: max(1rem, 16px);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.4rem; }
h1 { font-size: clamp(1.35rem, 2.4vw, 1.7rem); }
h2 { font-size: 1.2rem; }
p { margin: 0 0 0.85rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

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

code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  background: color-mix(in srgb, var(--line) 45%, transparent);
  padding: 0.1em 0.35em;
  border-radius: 5px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 0.75rem 1.25rem;
  z-index: 100;
  border-radius: 0 0 10px 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; gap: 0.9rem; align-items: center; }

.logo {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--brand) 18%, var(--surface));
  border: 1px solid var(--line);
  font-size: 1.5rem;
  flex: none;
}

.tagline { margin: 0; color: var(--ink-soft); font-size: 0.92rem; max-width: 48ch; }

.privacy {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ok);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 2.5rem) 3rem;
  display: grid;
  gap: 1.15rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.6rem);
  box-shadow: var(--shadow);
}

/* ---- frase ---- */

.sentence {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  min-height: 6.2rem;
  padding: 0.85rem;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 60%, var(--surface));
  align-content: flex-start;
  margin-bottom: 0.9rem;
}

.sentence .placeholder { margin: 0; color: var(--ink-soft); font-size: 0.95rem; align-self: center; }

.sentence .item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-bg);
  font-weight: 600;
  font-size: 0.98rem;
}
.sentence .item .glyph { font-size: 1.25rem; }

label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.3rem; }

.row { display: flex; gap: 0.6rem; margin-top: 0.4rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }

button {
  font: inherit;
  font-weight: 600;
  border-radius: 11px;
  border: 1px solid transparent;
  padding: 0.6rem 1.05rem;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--brand); color: var(--brand-ink); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover { border-color: var(--brand); color: var(--brand); }
button.big { font-size: 1.05rem; padding: 0.7rem 1.6rem; }

.rate-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  margin-top: 0.9rem;
  max-width: 34rem;
}
.rate-row label { margin: 0; }
.rate-row input[type="range"] { width: 100%; accent-color: var(--brand); }
.rate-row output { font-variant-numeric: tabular-nums; font-size: 0.9rem; color: var(--ink-soft); }

.status {
  margin: 0.9rem 0 0;
  padding: 0.7rem 0.95rem;
  border-radius: 10px;
  border-left: 4px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
  font-size: 0.94rem;
}
.status[data-kind="ok"] { border-color: var(--ok); }
.status[data-kind="error"] { border-color: var(--error); color: var(--error); background: var(--error-bg); }
.status[data-kind="info"] { border-color: var(--brand); }

/* ---- cartões ---- */

input[type="text"], input[type="search"], select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: color-mix(in srgb, var(--bg) 65%, var(--surface));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
input[type="text"]:focus, input[type="search"]:focus, select:focus { border-color: var(--focus); }
select { max-width: 26rem; }

.tabs { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.9rem 0; }

.tab {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.9rem;
}
.tab[aria-pressed="true"] {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 118px;
  padding: 0.8rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card-bg);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  line-height: 1.3;
}
.tile:hover { border-color: var(--brand); }
.tile .glyph { font-size: 2rem; line-height: 1; }
.tile .remove {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error);
  font-size: 0.95rem;
  line-height: 1;
}

.empty {
  grid-column: 1 / -1;
  padding: 1.2rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--ink-soft);
  text-align: center;
}

/* ---- edição ---- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
  margin: 0.8rem 0;
}

.toggle { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; margin: 0; }
.toggle input { width: 1.15rem; height: 1.15rem; accent-color: var(--brand); }

.prose ol { padding-left: 1.3rem; display: grid; gap: 0.4rem; }

.muted { color: var(--ink-soft); }
.small { font-size: 0.86rem; }

footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1.4rem clamp(1rem, 4vw, 2.5rem);
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
footer p { margin: 0.2rem 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media (max-width: 560px) {
  .topbar { padding: 0.9rem 1rem; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .tile { min-height: 104px; }
  .rate-row { grid-template-columns: 1fr auto; }
  .rate-row label { grid-column: 1 / -1; }
}

@media print {
  .topbar, footer, button, .skip-link, .rate-row, #edit-title, .form-grid, hr { display: none; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .tile { border-color: #999; }
}
