@font-face {
  font-family: "Heebo";
  src: url("/static/fonts/Heebo.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Frank Ruhl Libre";
  src: url("/static/fonts/FrankRuhlLibre.ttf") format("truetype");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #6b7280;
  --line: #e3e1db;
  --primary: #1b2a41;
  --primary-text: #ffffff;
  --accent: #c9a24a;
  --ok-bg: #e8f5ec;
  --ok: #1d6b3a;
  --warn-bg: #fff4dc;
  --warn: #8a5a00;
  --error-bg: #fde8e8;
  --error: #a61b1b;
  --radius: 12px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Heebo", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--primary); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px;
  background: var(--primary); color: var(--primary-text);
}
.topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.topbar a, .topbar select { color: inherit; }

.page { max-width: 720px; margin: 0 auto; padding: 16px; }
h2 { font-size: 1.1rem; margin: 24px 0 8px; }
h3 { font-size: 1rem; margin: 16px 0 4px; }

.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: .85rem;
}
.bottom-nav a .ico { font-size: 1.4rem; line-height: 1; }
.bottom-nav a.active { color: var(--primary); font-weight: 700; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: 0; }
.req { color: var(--error); }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
input, select, textarea {
  font: inherit; color: inherit;
  width: 100%; padding: 12px; min-height: 48px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
legend { font-weight: 500; margin-bottom: 4px; }
.chip { flex-direction: row; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.chip input { width: auto; min-height: 0; }
details summary { cursor: pointer; color: var(--primary); }
details.new-source { display: flex; flex-direction: column; gap: 12px; }
details.new-source[open] > label { margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  font: inherit; font-weight: 600; text-decoration: none;
  color: var(--primary); background: var(--surface);
  border: 1px solid var(--primary); border-radius: 10px; cursor: pointer;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-danger { color: var(--error); border-color: var(--error); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-link { border: 0; background: none; text-decoration: underline; min-height: 0; padding: 4px; }
.btn-big { justify-content: space-between; min-height: 64px; font-size: 1.1rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.badge { background: var(--accent); color: #1b2a41; border-radius: 999px; padding: 0 10px; font-weight: 700; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1 1 0; }
.actions.sticky {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  background: var(--bg); padding: 8px 0;
}

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--error-bg); color: var(--error); }

.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.counter {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-decoration: none; color: var(--text);
}
.counter { font-size: .85rem; padding: 12px 10px; }
.counter strong { font-size: 1.8rem; line-height: 1.1; color: var(--primary); }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.logout { margin-top: 24px; text-align: center; }

.subnav, .filters { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; }
.subnav a, .filters a {
  white-space: nowrap; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--text);
}
.subnav a.active, .filters a.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; text-decoration: none; color: var(--text);
}
.row-meta { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pager { display: flex; justify-content: space-between; margin-top: 12px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: #eceae4; color: var(--text); }
.tag-alert { background: var(--error); color: #fff; font-weight: 700; }
.status { font-weight: 600; }
.status-pending, .status-awaiting_approval, .status-preparing { color: var(--warn); }
.status-approved, .status-published, .status-succeeded { color: var(--ok); }
.status-rejected, .status-failed { color: var(--error); }

.quote-text { font-family: "Frank Ruhl Libre", serif; font-size: 1.25rem; line-height: 1.6; white-space: pre-wrap; }
.quote-text.big { font-size: 1.5rem; }
.locked { border: 1px dashed var(--muted); border-radius: 10px; padding: 8px; background: #f1f0ec; }
.locked-label { font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.locked textarea { background: transparent; border: 0; cursor: not-allowed; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; padding: 0; }
ul.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.alert { color: var(--error); }
.summary.done { border-color: var(--ok); }

.alert-banner { background: var(--error); color: #fff; border-radius: 10px; padding: 10px 14px; font-weight: 700; }
.preview { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); display: block; }
.preparing { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 5; background: #eceae4; border-radius: 8px; color: var(--muted); }
.paused { background: var(--error); color: #fff; }

@media (min-width: 900px) {
  .page { padding: 24px; }
}

.actions form { flex: 1 1 0; display: flex; }
.actions form .btn { flex: 1; }
.caption { white-space: pre-wrap; background: #f1f0ec; border-radius: 8px; padding: 10px; }
.rights-form .row { flex-wrap: nowrap; }
.rights-form select { flex: 1; }
.rights-form .btn { flex: 0 0 auto; }
select.alert { border-color: var(--error); color: var(--error); }
.pause-form { margin-top: 24px; }
.pause-form .btn { width: 100%; }
.filter-form { margin-bottom: 8px; }
.page > .alert-banner { margin-bottom: 12px; }
