:root {
  --paper: #F7F2E6;
  --card: #FFFDF6;
  --ink: #1F2A22;
  --muted: #686E5F;
  --line: #DCD4C0;
  --brass: #9A6F1E;
  --brass-strong: #8A6218;
  --brass-ink: #FFF9EA;
  --danger: #8C3B2B;
  --radius: 10px;
  --pad: 18px;
  color-scheme: light;
}
.dark {
  --paper: #1B241E;
  --card: #222D26;
  --ink: #EFE9DA;
  --muted: #A3AB9B;
  --line: #334034;
  --brass: #D3A24A;
  --brass-strong: #D3A24A;
  --brass-ink: #1B241E;
  --danger: #E2907E;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { overflow-x: clip; margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
h1 { font-size: 28px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 22px; margin: 0 0 6px; }
h3 { font-size: 19px; margin: 0; line-height: 1.25; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }
a { color: var(--brass-strong); }
header.app {
  padding: calc(14px + env(safe-area-inset-top)) var(--pad) 10px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}
header.app .grow { flex: 1 1 auto; min-width: 0; }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:focus-visible, .btn:focus-visible, input:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
main {
  padding: 0 var(--pad);
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.card .grow { flex: 1 1 auto; min-width: 0; }
.card .count { font-family: Georgia, serif; font-size: 22px; color: var(--ink); }
.card .count small { display: block; font-family: "Segoe UI", sans-serif; font-size: 11px; color: var(--muted); margin-top: 2px; }
.card:active { background: var(--paper); }
.wish {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
}
.wish .desc { grid-column: 1 / -1; }
.wish .price { font-family: Georgia, serif; font-size: 16px; white-space: nowrap; }
.wish .row { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.pill {
  display: inline-block; font-size: 12px; padding: 4px 10px;
  border-radius: 999px; background: transparent; border: 1px solid var(--line); color: var(--muted);
}
.pill.taken { border-style: dashed; color: var(--ink); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 16px; width: 100%;
  border-radius: 8px; border: 1px solid var(--brass-strong);
  background: var(--brass-strong); color: var(--brass-ink);
  font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.small { width: auto; min-height: 38px; font-size: 14px; padding: 0 12px; }
.fab-row { margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.tabs {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--paper);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px 6px calc(12px + env(safe-area-inset-bottom));
}
.tab {
  background: none; border: 0; color: var(--muted);
  font: inherit; font-size: 12px; padding: 4px; cursor: pointer;
  text-decoration: none; text-align: center;
}
.tab.active { color: var(--ink); font-weight: 600; }
.section { font-family: "Segoe UI", sans-serif; font-size: 13px; font-weight: 600; color: var(--muted); margin: 6px 0 0; }
.row-actions { display: flex; gap: 8px; margin: -4px 0 4px; }
.row-actions .btn { width: auto; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 6px; }
.theme {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px 14px; margin: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.theme legend { font-size: 12px; color: var(--muted); padding: 0 6px; margin-left: -6px; }
.seg { display: flex; gap: 6px; }
.seg label { flex: 1 1 0; min-width: 0; position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.seg span {
  display: block; text-align: center; padding: 10px 6px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; line-height: 1.2; cursor: pointer; color: var(--ink);
}
.seg input:checked + span { background: var(--brass-strong); border-color: var(--brass-strong); color: var(--brass-ink); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 2px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field textarea {
  min-height: 46px; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); font: inherit; width: 100%;
}
.field textarea { min-height: 88px; resize: vertical; }
.quote {
  border-left: 2px solid var(--brass); padding-left: 12px;
  font-size: 14px; line-height: 1.5; color: var(--muted);
}
.help {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0 14px;
}
.help summary {
  cursor: pointer; padding: 14px 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  font-family: Georgia, serif; font-size: 18px; line-height: 1.25;
  list-style: none;
}
.help summary::-webkit-details-marker { display: none; }
.help summary::after {
  content: '+'; font-family: "Segoe UI", sans-serif;
  font-size: 20px; line-height: 1; color: var(--brass-strong);
}
.help[open] summary::after { content: '−'; }
.help summary:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
.help p, .help ul { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.help p:last-child, .help ul:last-child { margin-bottom: 14px; }
.help ul { padding-left: 18px; }
.help li { margin: 4px 0; }
.help strong { color: var(--ink); font-weight: 600; }
.help a { color: var(--brass-strong); }
.empty { padding: 24px 0; }
.empty h3 { margin-bottom: 6px; }
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; padding: 20px; z-index: 10;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card); border-radius: 14px; padding: 20px;
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px;
}
.modal-card input { min-height: 46px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--paper); color: var(--ink); }
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.error { color: var(--danger); font-size: 14px; }
.spinner { padding: 40px 0; text-align: center; color: var(--muted); }

/* сторис */
.story {
  position: fixed; inset: 0;
  background: var(--paper);
  display: flex; flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) 0 calc(18px + env(safe-area-inset-bottom));
}
.story-top {
  display: flex; justify-content: flex-end;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 0 18px 6px;
}
.story-top .btn.small { width: auto; min-height: 36px; padding: 0 14px; font-size: 13px; }
.story-art {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0 18px;
}
.story-img {
  max-width: 100%; max-height: 100%;
  border-radius: 18px;
  background: #F7F2E6;
  border: 1px solid var(--line);
}
.story-body {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 12px 24px 0; display: flex; flex-direction: column; gap: 10px;
}
.story-body h2 { font-size: 28px; margin: 0; }
.dots { display: flex; gap: 6px; justify-content: center; padding: 4px 0 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--brass); }
