:root {
  --paper: #FAF6EE;
  --ink: #211D16;
  --ink-soft: #5C554A;
  --clay: #C1633A;
  --sage: #6B7A5E;
  --line: rgba(33,29,22,0.14);
  --card: #FFFFFF;
  --accent: #C1633A;
  --accent-ink: #FFFFFF;
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17140F; --ink: #F3EEE3; --ink-soft: #B7AE9E; --card: #211D16; --line: rgba(243,238,227,0.14);
  }
}
html, body { height: 100%; }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100%; display: flex; justify-content: center;
}
h1, h2, h3, .display { font-family: 'Fraunces', Georgia, serif; }
#app { width: 100%; max-width: 480px; min-height: 100vh; display: flex; flex-direction: column; position: relative; }

header.top { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 20px 10px; }
header.top .brand { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
header.top .brand span { color: var(--accent); }
header.top .pts { font-size: 13px; color: var(--ink-soft); }
main { flex: 1; padding: 4px 20px 100px; }
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform: translateY(0);} }

.onboard { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 28px; }
.onboard .chip-row { display:flex; gap:8px; margin-bottom: 22px; }
.onboard .chip-row i { width: 26px; height: 26px; border-radius: 7px; display:inline-block; }
.onboard h1 { font-size: 34px; line-height: 1.08; margin: 0 0 10px; font-weight: 600; }
.onboard p { color: var(--ink-soft); font-size: 15px; line-height: 1.5; margin: 0 0 26px; max-width: 34ch; }
.field { margin-bottom: 14px; }
.field label { display:block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; }
input[type="text"] {
  width: 100%; font-family: inherit; font-size: 17px; padding: 13px 14px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 999px; padding: 14px 22px; font-family: inherit;
  font-size: 15.5px; font-weight: 600; cursor: pointer; width: 100%;
  background: var(--ink); color: var(--paper); transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(0.97); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.swatch-hero {
  border-radius: 24px; padding: 30px 24px 26px; background: var(--accent); color: var(--accent-ink);
  margin: 10px 0 18px; position: relative; overflow: hidden;
}
.swatch-hero .eyebrow { font-size: 13px; opacity: .85; margin-bottom: 6px; }
.swatch-hero h2 { font-size: 32px; margin: 0 0 4px; font-weight: 600; }
.swatch-hero .hex { font-size: 13px; opacity: .8; letter-spacing: .02em; margin-bottom: 18px; }
.swatch-hero .meta { display:flex; gap: 18px; font-size: 13px; }
.swatch-hero .meta b { display:block; font-size: 20px; font-family: 'Fraunces', serif; font-weight: 600; }
.swatch-hero .ring { position: absolute; right: -30px; top: -30px; width: 140px; height: 140px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); }

.section-title { font-size: 14px; color: var(--ink-soft); margin: 22px 0 10px; }
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px; }
.row-between { display:flex; align-items:center; justify-content: space-between; }

.cycle-track { display:flex; gap: 4px; margin: 10px 0 4px; }
.cycle-track i { flex:1; height: 6px; border-radius: 3px; background: var(--line); }
.cycle-track i.done { background: var(--accent); }
.cycle-track i.today { background: var(--ink); }

.lb-preview .item { display:flex; align-items:center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.lb-preview .item:last-child { border-bottom: none; }
.lb-preview .rank { width: 20px; color: var(--ink-soft); font-size: 13px; }
.lb-preview .name { flex: 1; font-weight: 500; }
.lb-preview .score { color: var(--ink-soft); font-size: 13px; }

.progress-wrap { margin: 6px 0 16px; }
.progress-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--accent); transition: width .3s ease; }
.progress-label { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.photo-grid .tile { aspect-ratio: 1; border-radius: 12px; overflow: hidden; position: relative; background: var(--line); display:flex; align-items:center; justify-content:center; }
.photo-grid .tile img { width:100%; height:100%; object-fit: cover; display:block; }
.photo-grid .tile .loc-pin { position:absolute; bottom:5px; right:5px; width:18px; height:18px; border-radius:50%; background: rgba(0,0,0,.55); color:#fff; font-size:11px; display:flex; align-items:center; justify-content:center; }
.photo-grid .tile .rm { position:absolute; top:4px; right:4px; width:20px; height:20px; border-radius: 50%; background: rgba(0,0,0,.55); color:#fff; border:none; font-size:12px; line-height:1; }
.photo-grid .tile.add { border: 1.5px dashed var(--line); background: transparent; color: var(--ink-soft); font-size: 26px; cursor: pointer; }
.photo-grid .tile.add:active { transform: scale(0.96); }
#cameraInput { display: none; }

.hint { font-size: 13px; color: var(--ink-soft); line-height: 1.5; margin-top: 4px; }

#collageCanvas { width: 100%; border-radius: var(--radius); display: block; margin: 6px 0 16px; border: 1.5px solid var(--line); }
.share-row { display:flex; gap: 10px; }
.share-row .btn { flex: 1; }
.success-banner { background: var(--sage); color: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; font-size: 14.5px; display:flex; align-items:center; gap:10px; }

.lb-row { display:flex; align-items:center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 26px; font-family: 'Fraunces', serif; font-size: 17px; color: var(--ink-soft); }
.lb-rank.top1 { color: var(--clay); }
.lb-avatar { width: 34px; height: 34px; border-radius: 50%; display:flex; align-items:center; justify-content:center; font-size: 13px; font-weight: 600; color:#fff; flex-shrink:0; }
.lb-name { flex:1; font-weight: 500; font-size: 14.5px; }
.lb-you { font-size: 11px; color: var(--accent); display:block; margin-top:1px; }
.lb-score { font-family: 'Fraunces', serif; font-size: 17px; }
.lb-note { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 14px; line-height: 1.5; }

.gallery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gallery-grid .g-item { border-radius: 14px; overflow: hidden; border: 1.5px solid var(--line); background: var(--card); }
.gallery-grid .g-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display:block; }
.gallery-grid .g-item .g-cap { padding: 8px 10px; font-size: 12px; color: var(--ink-soft); }
.gallery-grid .g-item .g-cap b { color: var(--ink); font-weight: 600; }

nav.bottom { position: sticky; bottom: 0; left:0; right:0; background: var(--paper); border-top: 1px solid var(--line); display:flex; padding: 8px 10px 10px; }
nav.bottom button { flex:1; background:none; border:none; font-family: inherit; color: var(--ink-soft); font-size: 11.5px; padding: 6px 4px; display:flex; flex-direction:column; align-items:center; gap:4px; cursor:pointer; }
nav.bottom button .ic { font-size: 19px; }
nav.bottom button.active { color: var(--ink); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .25s ease, bottom .25s ease; z-index: 50; }
.toast.show { opacity: 1; bottom: 100px; }
