:root {
  --bg: #f7f4ee;
  --card: #ffffff;
  --ink: #14213d;
  --muted: #5d6475;
  --line: #e4ded3;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --ok-bg: #e5f4ea;
  --err-bg: #fbe6e1;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151f;
    --card: #1a2030;
    --ink: #eef0f5;
    --muted: #9aa3b5;
    --line: #2a3246;
    --ok-bg: #1d3527;
    --err-bg: #3d2320;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { white-space: nowrap; display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; font-size: 18px; }
.top nav { display: flex; align-items: center; gap: 14px; font-size: 15px; white-space: nowrap; }
.top nav a:not(.btn) { text-decoration: none; color: var(--muted); }

.btn, button.btn {
  display: inline-block; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  padding: 10px 18px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; }
button.link.danger { color: var(--accent); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); }
.tabs a.on { background: var(--ink); color: var(--bg); }
.sorter { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.sorter a { color: var(--muted); }
.sorter a.on { color: var(--ink); font-weight: 600; text-decoration: none; }

.card {
  display: grid; grid-template-columns: 168px 1fr auto; gap: 14px; align-items: start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
}
.thumb { position: relative; display: block; text-decoration: none; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nothumb { display: grid; place-items: center; height: 100%; font-size: 32px; font-weight: 700; color: var(--muted); }
.play {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.7); color: #fff;
  font-size: 11px; padding: 2px 7px; border-radius: 4px;
}
.card h2 { font-size: 16px; margin: 0 0 2px; line-height: 1.3; }
.card h2 a { text-decoration: none; }
.meta { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.note { font-size: 14px; margin: 0 0 4px; overflow-wrap: anywhere; }
.vote {
  display: flex; flex-direction: column; align-items: center; min-width: 44px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 10px; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.vote span { font-weight: 700; font-size: 15px; color: var(--ink); }
.vote.on { border-color: var(--accent); color: var(--accent); }
.vote.ro { cursor: default; }
.vote.wide { flex-direction: row; gap: 6px; padding: 10px 16px; border-radius: 999px; font-size: 15px; }

.item h1 { font-size: 22px; margin: 14px 0 4px; }
.embed { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.hero { width: 100%; border-radius: var(--radius); display: block; margin-bottom: 12px; }
.hero.video { aspect-ratio: 16 / 9; object-fit: cover; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 12px 0; }
.notes { padding-left: 18px; }
.notes li { margin-bottom: 8px; overflow-wrap: anywhere; }
.danger-zone { margin-top: 28px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel h1 { margin-top: 0; font-size: 22px; }
.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.stack { display: flex; flex-direction: column; gap: 14px; margin: 12px 0; }
.stack.narrow { margin-left: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label small { font-weight: 400; color: var(--muted); }
input, textarea {
  font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); width: 100%;
}
.flash { padding: 10px 14px; border-radius: 8px; background: var(--ok-bg); margin: 0 0 12px; }
.flash.error { background: var(--err-bg); }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 14px; overflow-wrap: anywhere; }
code.token { display: block; padding: 10px; font-size: 13px; }
code.copy { cursor: pointer; }
code.copied { border-color: #3a9d5d; }
code.copied::after { content: "  ✓ copied"; color: #3a9d5d; }
.howto { border-top: 1px solid var(--line); padding: 12px 0; }
.howto summary { font-weight: 700; font-size: 17px; cursor: pointer; }
.howto li { margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.empty { text-align: center; padding: 40px 0; color: var(--muted); }
.pager { display: flex; justify-content: space-between; padding: 8px 0 24px; }

@media (max-width: 560px) {
  .card { grid-template-columns: 1fr auto; }
  .thumb { grid-column: 1 / -1; }
  .top { padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 16px; gap: 6px; }
  .top nav { gap: 10px; font-size: 14px; }
}

/* --- topics ---------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 14px; font-weight: 500;
  text-decoration: none; cursor: pointer; user-select: none;
}
.chip.small { padding: 2px 10px; font-size: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; }
.chip.with-x { padding-right: 4px; }
.chip.with-x a { text-decoration: none; }
.chip.with-x form { display: inline; }
.chip .x { border: 0; background: none; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 4px; cursor: pointer; }
.add-topic { display: inline-flex; gap: 6px; }
.add-topic input { width: 140px; padding: 4px 10px; font-size: 14px; border-radius: 999px; }
.trail { color: var(--muted); font-size: 14px; margin: 0 0 4px; }
.trail a { color: inherit; }
.topic-head h1 { margin: 0 0 6px; font-size: 24px; }
.topic-head { margin-bottom: 14px; }
.edit { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.tree { list-style: none; padding-left: 0; margin: 0; }
.tree .tree { padding-left: 20px; border-left: 2px solid var(--line); margin: 4px 0 4px 6px; }
.tree li { padding: 5px 0; }
.tree li > a:first-child { font-weight: 600; text-decoration: none; }
select { font: inherit; font-size: 16px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line); }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
label.check input { width: auto; margin-top: 4px; }

/* --- the share page -------------------------------------------------------- */
.share { padding-bottom: 8px; }
.share-preview { display: grid; grid-template-columns: 128px 1fr; gap: 12px; align-items: start; }
.share-preview.no-thumb { grid-template-columns: 1fr; }
.share-preview img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; display: block; }
.share-title {
  font-weight: 700; font-size: 16px; line-height: 1.3; margin: 0 0 4px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.note-box { position: relative; margin-top: 6px; }
.note-box textarea { padding-right: 52px; }
.mic {
  position: absolute; right: 8px; bottom: 10px; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); display: grid; place-items: center; cursor: pointer;
}
.mic.live { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(228, 87, 46, .25); } }
@media (prefers-reduced-motion: reduce) { .mic.live { animation: none; } }
fieldset.chips { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.chips legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 8px; }
fieldset.chips legend small { font-weight: 400; color: var(--muted); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-list .chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-list .chip:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-list .chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip.suggested { border-color: var(--accent); }
.chip-new { width: 140px; padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.instant-bar { background: var(--ok-bg); padding: 10px 14px; border-radius: 8px; margin: 0; }
.post-bar {
  position: sticky; bottom: 0; padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--card) 30%);
}
.menu-demo { display: flex; flex-direction: column; max-width: 260px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.menu-demo span { padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 15px; }
.menu-demo span:last-child { border-bottom: 0; }
.option { background: var(--bg); border-radius: 10px; padding: 4px 14px; margin: 10px 0; }
.option summary { cursor: pointer; padding: 8px 0; }
