:root {
  --bg: #f6f1e7; --text: #1d1b17; --surface: #e9e0cd; --muted: #7d7566; --action: #2f4bd8; --on-action: #f6f1e7;
  --line: #d9cfba;
  --c0: #d4513a; --c1: #c99a1f; --c2: #3a64c8; --c3: #3a9a6a; --c4: #8a58b8; --c5: #d9772e; --c6: #2f8f9a; --c7: #b8508a;
  --serif: Fraunces, Georgia, 'Times New Roman', serif;
  --sans: Inter, -apple-system, system-ui, 'Helvetica Neue', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.4 var(--sans); }
body { padding: env(safe-area-inset-top) 0 0; }
main { max-width: 480px; margin: 0 auto; padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
h1 { font: 700 30px/1.05 var(--serif); letter-spacing: -0.01em; margin: 0; }
h2 { font: 700 20px/1.15 var(--serif); margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 18px; }
.back { display: inline-block; color: var(--action); font-weight: 500; margin-bottom: 8px; }

.field { display: block; width: 100%; background: var(--surface); border: 0; border-radius: 14px; padding: 12px 14px; color: var(--text); font: inherit; }
.field::placeholder { color: var(--muted); }
textarea.field { resize: vertical; min-height: 60px; }
.search-link { display: block; background: var(--surface); border-radius: 14px; padding: 12px 14px; color: var(--muted); margin-bottom: 14px; }

.card { border-radius: 18px; padding: 14px 16px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card b { font: 700 17px/1.1 var(--serif); display: block; }
.card span { font-size: 12px; opacity: 0.85; }
.card.action { background: var(--action); color: var(--on-action); }
.card.quiet { background: var(--surface); }
.pillbtn { background: var(--on-action); color: var(--action); border-radius: 20px; padding: 7px 14px; font-weight: 600; font-size: 13px; }
.card.quiet .pillbtn { background: var(--text); color: var(--bg); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { border-radius: 18px; padding: 12px; min-height: 116px; display: flex; flex-direction: column; justify-content: flex-end; color: #fff; text-align: left; background: var(--c0); }
.tile b { font: 700 18px/1.1 var(--serif); overflow-wrap: anywhere; }
.tile span { font-size: 12px; opacity: 0.92; }
.tile em { font-style: normal; font-size: 11px; margin-top: 6px; background: rgba(255, 255, 255, 0.24); align-self: flex-start; padding: 2px 8px; border-radius: 10px; }
.tile.new { background: none; border: 1.5px dashed var(--muted); color: var(--muted); align-items: center; justify-content: center; text-align: center; }
.tile.unsorted { background: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.empty b { display: block; font: 700 20px var(--serif); color: var(--text); margin-bottom: 6px; }
.btn { display: inline-block; background: var(--action); color: var(--on-action); border-radius: 16px; padding: 12px 18px; font-weight: 600; margin-top: 12px; }
.btn.ghost { background: var(--surface); color: var(--text); }
.btn.danger { background: #b3321f; }

.seg { display: flex; gap: 4px; background: var(--surface); border-radius: 14px; padding: 3px; margin: 12px 0; overflow-x: auto; }
.seg button { flex: 1; text-align: center; padding: 8px 6px; border-radius: 11px; font-size: 12px; white-space: nowrap; color: var(--muted); }
.seg button.on { background: var(--action); color: var(--on-action); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font-size: 12px; padding: 5px 11px; border-radius: 16px; background: var(--surface); }
.chip.on { background: var(--text); color: var(--bg); }

.row { display: flex; gap: 12px; background: var(--surface); border-radius: 16px; padding: 10px; margin-bottom: 8px; align-items: stretch; }
.row .thumb { width: 58px; min-height: 70px; border-radius: 12px; flex: none; display: grid; place-items: center; color: #fff; font: 700 20px var(--serif); }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.row .meta { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.row .go { align-self: center; font-size: 12px; font-weight: 600; color: var(--action); padding: 6px 4px; }
.tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 10.5px; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--muted); }
.tag.hot { background: var(--action); color: var(--on-action); }
.tag.guess { background: transparent; border: 1px dashed var(--muted); }

.tabs { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 456px; margin: 0 auto; height: 58px; background: var(--text); color: var(--bg); border-radius: 24px; display: flex; justify-content: space-around; align-items: center; font-size: 11px; box-shadow: 0 8px 24px rgba(29, 27, 23, 0.25); z-index: 5; }
.tabs a { padding: 8px 6px; opacity: 0.65; }
.tabs a.on { opacity: 1; font-weight: 600; }
.tabs .plus { width: 48px; height: 48px; border-radius: 50%; background: var(--action); color: var(--on-action); font: 600 28px/48px var(--sans); margin-top: -22px; box-shadow: 0 6px 16px rgba(47, 75, 216, 0.4); }

.dim { position: fixed; inset: 0; background: rgba(29, 27, 23, 0.45); z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto; background: var(--bg); border-radius: 28px 28px 0 0; padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; z-index: 11; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.lbl { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 7px 13px; border-radius: 18px; background: var(--surface); font-size: 13px; }
.pill.on { background: var(--action); color: var(--on-action); font-weight: 600; }
.msg { font-size: 13px; color: #b3321f; margin-top: 6px; }
.ok { color: #2d7a52; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: var(--text); }

.stack-card { background: var(--surface); border-radius: 20px; padding: 16px; margin-bottom: 14px; }
.stack-card .cap { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9em; overflow: hidden; margin: 8px 0; }
.progress { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.sentinel { height: 1px; }

.preview .embed { width: 100%; height: 62vh; border: 0; border-radius: 16px; background: var(--surface); }
.row .thumb { border: 0; }
