/* Votum: calm paper-and-ink look. No web fonts, no images in CSS (the CSP allows only same-origin files). */

:root {
  color-scheme: light dark;

  --bg: #f4f1e8;
  --surface: #fffdf7;
  --sunken: #ebe6d9;
  --ink: #221f1a;
  --muted: #5f594d;
  --line: #d9d2c0;
  --line-strong: #b5ac96;
  --accent: #2d5b4b;
  --on-accent: #fbf9f3;
  --accent-soft: #dcebe4;
  --danger: #9b2c1d;
  --danger-soft: #f5ddd6;
  --warn: #7a4f06;
  --warn-soft: #f6e6c2;
  --ok: #1f5a3c;
  --focus: #b3541a;
  --shadow: 0 1px 2px rgb(34 31 26 / 8%), 0 4px 14px rgb(34 31 26 / 6%);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 14px;
  --topbar: 52px;
  --tabs: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171613;
    --surface: #211f1b;
    --sunken: #12110f;
    --ink: #ece7da;
    --muted: #a8a193;
    --line: #38342c;
    --line-strong: #5a5447;
    --accent: #86cdb4;
    --on-accent: #0f211b;
    --accent-soft: #23382f;
    --danger: #f0a090;
    --danger-soft: #3f2420;
    --warn: #f0cd7c;
    --warn-soft: #3d3014;
    --ok: #97d6b3;
    --focus: #f2a672;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 14px rgb(0 0 0 / 30%);
  }
}

/* status colours: tinted background with matching text, the word is always written out */
[data-status="neu"] { --st-bg: #e8e4d8; --st-fg: #4a4538; }
[data-status="gesichtet"] { --st-bg: #dde8f2; --st-fg: #26466a; }
[data-status="geplant"] { --st-bg: #e6e0f1; --st-fg: #4b3a78; }
[data-status="in-arbeit"] { --st-bg: #f6e6c2; --st-fg: #6a4708; }
[data-status="blockiert"] { --st-bg: #f5d9d2; --st-fg: #8a2a1a; }
[data-status="erledigt"] { --st-bg: #d6eadf; --st-fg: #1f5a3c; }
[data-status="verworfen"] { --st-bg: #e3e0da; --st-fg: #5c564c; }

@media (prefers-color-scheme: dark) {
  [data-status="neu"] { --st-bg: #2c2a24; --st-fg: #cfc8b6; }
  [data-status="gesichtet"] { --st-bg: #1f2f40; --st-fg: #a9c8ea; }
  [data-status="geplant"] { --st-bg: #2c2640; --st-fg: #cabdf0; }
  [data-status="in-arbeit"] { --st-bg: #3d3014; --st-fg: #f0cd7c; }
  [data-status="blockiert"] { --st-bg: #402119; --st-fg: #f2a899; }
  [data-status="erledigt"] { --st-bg: #1b3a2b; --st-fg: #97d6b3; }
  [data-status="verworfen"] { --st-bg: #2a2824; --st-fg: #a09a8c; }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden; /* the columns scroll, not the page */
}

[hidden] { display: none !important; }

a { color: var(--accent); text-underline-offset: 0.18em; }

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

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

.skip:focus {
  position: fixed;
  z-index: 50;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 8px;
}

.noscript { padding: 16px; }
.muted { color: var(--muted); }

/* ---- shell ----------------------------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: calc(var(--topbar) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
}

.brand-mark { display: block; border-radius: 7px; }

.brand-name {
  font: 600 1.5rem/1 var(--serif);
  letter-spacing: 0.01em;
}

.new-link { display: none; }

.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.pill {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--warn);
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font: 600 0.875rem/1 var(--sans);
  cursor: pointer;
}

/* On the phone one screen at a time. */
.side, .main {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.main { outline: none; }
body[data-view="list"] .main { display: none; }
body:not([data-view="list"]) .side { display: none; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: calc(var(--tabs) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.tabs a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

/* ---- controls -------------------------------------------------------------------------------- */

label, .label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

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

input[type="text"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1rem; /* 16px minimum: iOS does not zoom into the field */
  line-height: 1.4;
}

textarea { resize: vertical; }

input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }

select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-quiet { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-quiet:hover:not(:disabled) { background: var(--sunken); }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 0.9375rem; font-weight: 600; }
.btn-large { min-height: 58px; font-size: 1.125rem; border-radius: 16px; width: 100%; }
.btn-danger { color: var(--danger); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--sunken); }
.icon-btn:disabled { opacity: 0.4; }

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

.chip {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { background: var(--sunken); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.chip[data-status][aria-pressed="true"] {
  background: var(--st-bg);
  border-color: var(--st-fg);
  color: var(--st-fg);
  box-shadow: inset 0 0 0 1px var(--st-fg);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--st-bg);
  color: var(--st-fg);
  font-size: 0.8125rem;
  font-weight: 650;
  line-height: 1.5;
  white-space: nowrap;
}

.ref { font: 0.8125rem var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }

.section-title {
  margin: 0 0 10px;
  color: var(--muted);
  font: 700 0.75rem/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.list-message { margin: 0; padding: 20px 16px; color: var(--muted); }
.list-message.is-error, .is-error { color: var(--danger); }
.item .list-message.is-error { background: var(--danger-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.note { margin: 6px 0 0; color: var(--warn); font-size: 0.875rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ---- capture --------------------------------------------------------------------------------- */

#view > .capture, #view > .queue-panel { max-width: 720px; margin-inline: auto; }

.capture {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
  padding: 16px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

.field { min-width: 0; }
.field.grow { display: flex; flex: 1 1 auto; flex-direction: column; }
.field.grow textarea {
  flex: 1 1 auto;
  min-height: 9.5rem;
  font-size: 1.0625rem;
  line-height: 1.5;
  resize: none;
}

.more summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.more-body { display: grid; gap: 14px; padding: 6px 0 4px; }

.actions {
  position: sticky;
  bottom: 0;
  margin: 0 -16px;
  padding: 8px 16px 12px;
  background: linear-gradient(to bottom, transparent, var(--bg) 14px);
}
.actions-row { display: flex; align-items: center; gap: 12px; }
.hint { display: none; color: var(--muted); font-size: 0.8125rem; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .hint { display: inline; } .btn-large { width: auto; flex: 1; } }

.confirm { min-height: 1.5em; margin: 0 0 8px; font-weight: 600; }
.confirm:empty { min-height: 0; margin: 0; }
.confirm.is-ok { color: var(--ok); }
.confirm.is-warn { color: var(--warn); }
.confirm.is-error { color: var(--danger); }
.confirm .check { font-weight: 800; }
.confirm a { color: inherit; }

.queue-panel { padding: 8px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
.queue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.queue-item {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--warn);
  border-radius: 12px;
  background: var(--surface);
}
.queue-item[data-rejected="true"] { border-left-color: var(--danger); }
.queue-text { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.queue-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 0; color: var(--muted); font-size: 0.8125rem; }
.queue-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---- list ------------------------------------------------------------------------------------ */

.list-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.list-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.list-title-row h1 { margin: 0; font: 600 1.5rem/1.2 var(--serif); outline: none; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters input[type="search"] { grid-column: 1 / -1; }

.rows { list-style: none; margin: 0; padding: 0; }

.row {
  display: block;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.row:hover { background: var(--sunken); }
.row[aria-current="page"] { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.row-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; color: var(--muted); font-size: 0.8125rem; }
.row-meta .age { margin-left: auto; }
.tag { padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 6px; font-size: 0.75rem; font-weight: 600; }

.more-btn { display: flex; margin: 16px auto 24px; }

/* ---- entry ----------------------------------------------------------------------------------- */

.item {
  max-width: 720px;
  margin-inline: auto;
  padding: 8px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
}
.item[aria-busy="true"] .chips { opacity: 0.55; pointer-events: none; }

.back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
}

.item-head { margin-bottom: 20px; }
.item-ref-row { display: flex; align-items: center; gap: 10px; }
.item-title { margin: 6px 0 8px; font: 600 1.625rem/1.25 var(--serif); overflow-wrap: anywhere; outline: none; }
.item-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 0; color: var(--muted); font-size: 0.875rem; }

.group { margin-bottom: 22px; }
.pair { display: grid; gap: 22px; }
.section-row { display: flex; align-items: center; justify-content: space-between; }
.section-row .section-title { margin: 0; }

.item-text {
  margin-top: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.item textarea { min-height: 7rem; }
.item .field { margin-bottom: 12px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.tl { position: relative; padding: 0 0 16px 14px; }
.tl::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-strong);
  border: 2px solid var(--bg);
}
.tl[data-kind="comment"]::before { background: var(--accent); }
.tl[data-kind="commit"]::before { background: var(--warn); }
.tl[data-kind="close"]::before { background: var(--ok); }
.tl-head { font-size: 0.9375rem; overflow-wrap: anywhere; }
.tl-head time { color: var(--muted); font-size: 0.8125rem; white-space: nowrap; }
.tl-comment {
  margin-top: 6px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tl-commit { margin-top: 4px; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.sha { font-family: var(--mono); }

.gitea-link { margin: 24px 0 0; }
.gitea-link a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

/* ---- messages -------------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs) + env(safe-area-inset-bottom) + 12px);
  z-index: 40;
  max-width: min(92vw, 420px);
  margin: 0;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.toast.error { background: var(--danger); color: var(--bg); }

.blocker {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(20 18 14 / 60%);
}
.blocker-card {
  max-width: 440px;
  padding: 22px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.blocker-card h2 { margin: 0 0 8px; font: 600 1.375rem/1.25 var(--serif); }
.blocker-card p { margin: 0 0 6px; }

/* ---- laptop: list on the left, capture or entry on the right --------------------------------- */

@media (min-width: 900px) {
  .shell {
    grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar { grid-column: 1 / -1; padding-inline: 24px; }
  .tabs { display: none; }

  body[data-view="list"] .main { display: block; }
  body:not([data-view="list"]) .side { display: block; }

  .side { border-right: 1px solid var(--line); background: var(--bg); }
  .main { background: var(--bg); }

  .new-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 650;
    text-decoration: none;
  }
  .capture { padding: 32px 32px 0; }
  .actions { margin: 0 -32px; padding: 8px 32px 24px; }
  .queue-panel { padding: 8px 32px 32px; }
  .item { padding: 24px 32px 48px; }
  .item .back { display: none; }
  .item-title { font-size: 1.875rem; }
  .pair { grid-template-columns: 1fr 1fr; }
  .toast { bottom: 24px; }
}

@media (min-width: 900px) and (max-width: 1100px) {
  .shell { grid-template-columns: 320px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .row, .icon-btn { transition: background-color 0.12s, filter 0.12s; }
}

@media print {
  .tabs, .side, .topbar { display: none; }
  body { overflow: visible; }
}
