:root {
  --bg: #fff7ec;
  --surface: #ffffff;
  --surface-2: #fbeedc;
  --ink: #1f1a14;
  --muted: #76695a;
  --line: #ecdcc6;
  --accent: #ff5a36;
  --accent-ink: #ffffff;
  --accent-soft: #ffe2d8;
  --good: #1f9d63;
  --warn: #c27a00;
  --danger: #d33a2c;
  --tile: #f7ead8;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(60 30 0 / .06), 0 8px 24px rgb(60 30 0 / .07);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f; --surface: #211c17; --surface-2: #2a241d; --ink: #f6ece0; --muted: #b3a493;
    --line: #3a3128; --accent: #ff7452; --accent-ink: #1a0f0a; --accent-soft: #4a2418;
    --tile: #2a241d; --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16130f; --surface: #211c17; --surface-2: #2a241d; --ink: #f6ece0; --muted: #b3a493;
  --line: #3a3128; --accent: #ff7452; --accent-ink: #1a0f0a; --accent-soft: #4a2418;
  --tile: #2a241d; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
h1, h2, h3, .brand { font-family: "Bricolage Grotesque", system-ui, sans-serif; letter-spacing: -0.02em; }
h1 { font-size: 2.2rem; margin: .4rem 0; font-weight: 800; }
h2 { font-size: 1.5rem; margin: 0 0 .4rem; font-weight: 800; }
h3 { font-size: 1.15rem; margin: 0; font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }
code { font-size: .85em; background: var(--surface-2); padding: .1em .35em; border-radius: 6px; word-break: break-all; }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; padding: .75rem 1.1rem; border-radius: 999px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  transition: transform .08s ease, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: .45rem .85rem; font-size: .875rem; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: 28px; padding: 32px 24px; box-shadow: var(--shadow); text-align: center; }
.logo-blob { width: 64px; height: 64px; margin: 0 auto; border-radius: 22px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 32px; transform: rotate(-8deg); }
form { display: grid; gap: 14px; margin-top: 18px; text-align: left; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
input:not([type=file]):not([type=checkbox]), select {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: .7rem .85rem; width: 100%;
}
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: .9rem; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo-dot { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 15px; transform: rotate(-8deg); }
.tabs { display: flex; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tabs a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; padding: .4rem .85rem; border-radius: 999px; white-space: nowrap; }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
@media (max-width: 420px) { .brand { font-size: 0; gap: 0; } .brand .logo-dot { font-size: 15px; } }

/* library */
.view { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.count { margin: 0; font-weight: 700; margin-right: auto; }
.chips { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.chip { font: inherit; font-size: .85rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .35rem .8rem; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
#sort { width: auto; padding: .4rem .7rem; font-size: .85rem; border-radius: 999px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; } }
.tile {
  position: relative; aspect-ratio: 1; border: 0; padding: 8%; border-radius: var(--radius);
  background: var(--tile); cursor: pointer; display: block; width: 100%;
  transition: transform .12s ease;
}
.tile:hover { transform: translateY(-2px) rotate(-1deg); }
.tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .badge { position: absolute; top: 6px; right: 6px; font-size: .65rem; font-weight: 700; background: var(--surface); color: var(--ink); border-radius: 999px; padding: 1px 6px; box-shadow: var(--shadow); }
#sentinel { height: 1px; }
.empty { text-align: center; padding: 64px 16px; }
.empty .big { font-family: "Bricolage Grotesque", sans-serif; font-size: 1.6rem; font-weight: 800; margin: 0; }

/* add */
.panel { background: var(--surface); border-radius: 24px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.howto { background: var(--surface-2); border-radius: 14px; padding: 10px 14px; margin: 12px 0; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { padding-left: 1.2rem; margin: .6rem 0 0; display: grid; gap: .4rem; }
.dropzone {
  display: grid; justify-items: center; gap: 4px; text-align: center; padding: 32px 16px;
  border: 2px dashed var(--line); border-radius: 20px; cursor: pointer; font-weight: 400; transition: .15s;
}
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dz-icon { font-size: 2rem; color: var(--accent); }
.dz-title { font-weight: 700; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .2s; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 12px 0; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font-family: "Bricolage Grotesque", sans-serif; font-size: 1.5rem; }
.stat span { font-size: .8rem; color: var(--muted); }
.stat.good b { color: var(--good); }
.stat.warn b { color: var(--warn); }
.review-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.review-head .row { margin: 0; }
.review-grid .tile { outline: 3px solid transparent; }
.review-grid .tile[aria-pressed="true"] { outline-color: var(--accent); }
.review-grid .tile[aria-pressed="false"] img { opacity: .35; filter: grayscale(1); }
.review-grid .tile .flag { position: absolute; left: 6px; bottom: 6px; right: 6px; font-size: .62rem; font-weight: 700; background: var(--warn); color: #fff; border-radius: 6px; padding: 1px 4px; text-align: center; }
.review-grid .tile .check { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; color: var(--accent-ink); }
.review-grid .tile[aria-pressed="true"] .check { background: var(--accent); border-color: var(--accent); }
.sticky-cta { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 12px); display: flex; justify-content: center; margin-top: 16px; }
.sticky-cta .btn { box-shadow: var(--shadow); min-width: 220px; }

/* sheet */
.sheet {
  border: 0; padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px); background: var(--surface); color: var(--ink);
  border-radius: 28px 28px 0 0; width: 100%; max-width: 520px; margin: auto auto 0; box-shadow: var(--shadow);
}
@media (min-width: 700px) { .sheet { margin: auto; border-radius: 28px; } }
.sheet::backdrop { background: rgb(0 0 0 / .45); }
.sheet-close { position: absolute; top: 10px; right: 10px; margin: 0; }
.sheet-close button { border: 0; background: var(--surface-2); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 1rem; }
.sheet-img { background: var(--tile); border-radius: 22px; padding: 24px; display: grid; place-items: center; }
.sheet-img img { width: min(280px, 70vw); aspect-ratio: 1; object-fit: contain; }
#sheet-meta { text-align: center; margin: 12px 0; }
.sheet-actions { display: grid; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translate(-50%, 150%);
  background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 999px; font-weight: 600; font-size: .9rem;
  transition: transform .25s ease; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.whoami { font: inherit; font-size: .8rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: .35rem .7rem; cursor: pointer; white-space: nowrap; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; }
.topbar { flex-wrap: nowrap; }
@media (max-width: 520px) { .tabs a { padding: .4rem .6rem; } .whoami { max-width: 22vw; } }
.activity { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 2px; }
.activity li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.activity .who { font-weight: 700; }
.activity time { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; padding-left: 8px; }
.activity .thumbs { display: flex; gap: 2px; }
.activity .thumbs img { width: 28px; height: 28px; object-fit: contain; }
.activity .text { min-width: 0; }
