:root {
  --bg: #f7f1e7;
  --card: #fffdf9;
  --ink: #2b2420;
  --muted: #7a6b5c;
  --line: #e6dccd;
  --accent: #9a4f2c;
  --accent-ink: #fffaf3;
  --soft: #f1e6d6;
  --warn-bg: #fbeae6;
  --warn: #a8322d;
  --ok: #4f6b3a;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1916;
    --card: #27211d;
    --ink: #efe7dc;
    --muted: #a8998a;
    --line: #3a322b;
    --accent: #d98a5f;
    --accent-ink: #1d1916;
    --soft: #322a24;
    --warn-bg: #3a2220;
    --warn: #f0928a;
    --ok: #a7c48d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
button, textarea, input { font: inherit; color: inherit; }

.wrap { max-width: 820px; margin: 0 auto; padding: 0 16px 80px; }

header.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin: 0 -16px 16px; padding: 12px 16px 0;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font: 700 24px/1.2 var(--serif); letter-spacing: -0.01em; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; padding: 8px 12px 10px; white-space: nowrap;
  color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab .n { font-size: 13px; opacity: .8; margin-left: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; color: var(--ink);
  min-height: 40px; line-height: 1.2;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 14px;
}
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.badge {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  background: var(--soft); color: var(--ink); padding: 2px 8px; border-radius: 999px;
}
.card h2 { font: 700 19px/1.3 var(--serif); margin: 8px 0 6px; overflow-wrap: anywhere; }
.card h2 a { color: inherit; text-decoration: none; }
.card h2 a:hover { text-decoration: underline; }
.summary { color: var(--ink); margin: 6px 0 0; }
.thumb { display: block; margin-top: 10px; max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); object-fit: cover; object-position: top; }

.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 16px 0 6px; font-weight: 600; }

textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  padding: 10px 12px; resize: vertical; min-height: 60px;
}
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }

.angle { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.angle:first-of-type { border-top: 0; }
.angle-head { font-weight: 700; }
.angle .yours { font-size: 12px; color: var(--accent); font-weight: 600; margin-left: 6px; }
.angle p { margin: 4px 0; }
details > summary { cursor: pointer; color: var(--muted); font-size: 14px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "+ "; }
details[open] > summary::before { content: "\2212  "; }
.detail-grid { font-size: 14px; margin: 6px 0 0; }
.detail-grid div { margin: 4px 0; }
.detail-grid b { color: var(--muted); font-weight: 600; }
.check { color: var(--warn); }

.flag {
  background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: 15px;
}
.flag textarea { margin-top: 8px; background: var(--card); color: var(--ink); }
.working { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-top: 12px; font-size: 15px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .9s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.draft { background: var(--soft); border-radius: 12px; padding: 12px; margin-top: 10px; }
.draft textarea { background: var(--card); min-height: 280px; font-size: 15px; line-height: 1.55; }
.draft .notes { font-size: 14px; color: var(--muted); white-space: pre-wrap; margin-top: 8px; }
.draft .angle-used { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font: 700 20px var(--serif); color: var(--ink); margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 15px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; }

/* Capture and login pages */
.page { max-width: 560px; margin: 0 auto; padding: 24px 16px 40px; }
.page h1 { font: 700 26px/1.2 var(--serif); margin: 8px 0 4px; }
.page .lede { color: var(--muted); margin: 0 0 16px; }
.preview { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.preview img { max-width: 100%; max-height: 40vh; border-radius: 10px; display: block; }
.preview .src { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.preview .ttl { font: 700 17px/1.3 var(--serif); overflow-wrap: anywhere; }
.page textarea.big { min-height: 160px; font-size: 17px; background: var(--card); }
.page .btn.primary { width: 100%; min-height: 50px; font-size: 17px; margin-top: 12px; }
.done { text-align: center; padding-top: 12vh; }
.done .tick { font: 700 44px var(--serif); color: var(--ok); }
input[type=password] {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  padding: 12px; font-size: 17px; min-height: 48px;
}
.error { color: var(--warn); margin: 8px 0; }
