:root {
  --ground: #0c0b0a;
  --surface: #171513;
  --raised: #201d1a;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f3efe8;
  --muted: #9a938a;
  --delete: #ff5a4e;
  --keep: #39d98a;
  --accent: #e8b04b;
  --serif: "New York", "Iowan Old Style", "Charter", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --pad: 20px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
html, body { background: var(--ground); color: var(--text); font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
img, video { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) var(--pad) calc(env(safe-area-inset-bottom) + 96px); }

/* type */
.figure { font: 600 64px/1 var(--serif); letter-spacing: -0.02em; }
.h1 { font: 600 40px/1.05 var(--serif); letter-spacing: -0.015em; }
.h2 { font: 600 26px/1.15 var(--serif); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

.section { margin-top: 36px; }
.section > .eyebrow { display: block; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }

/* top bar */
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 12px; }
.bar .title { font-weight: 600; font-size: 17px; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--text); }
.iconbtn svg { width: 22px; height: 22px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--muted); font-size: 15px; }

/* buttons */
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 54px; border-radius: 6px; background: var(--text); color: var(--ground); font-weight: 600; font-size: 16px; text-decoration: none; }
.btn.delete { background: var(--delete); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn[disabled] { opacity: 0.4; cursor: default; }
.link { color: var(--accent); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }

/* rows: straight lines, no cards */
.rows { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; width: 100%; text-align: left; }
.row .main { flex: 1; min-width: 0; }
.row .main b { display: block; font-weight: 600; }
.row .main span { display: block; color: var(--muted); font-size: 14px; }
.row .arrow { color: var(--muted); }
.row svg { width: 22px; height: 22px; flex: none; }

/* forms */
.field { width: 100%; min-height: 54px; padding: 0 16px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); font-size: 17px; }
.field::placeholder { color: var(--muted); }
.stack { display: grid; gap: 12px; }
.error { color: var(--delete); font-size: 14px; }

/* progress */
.meter { height: 3px; background: var(--line); margin-top: 12px; }
.meter > i { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }

/* tabs inside gallery: underlined text, not pills */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-top: 8px; }
.tabs a { padding: 12px 0; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--text); border-color: var(--text); }

/* gallery */
.month { margin: 28px 0 10px; display: flex; justify-content: space-between; align-items: baseline; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 0 calc(var(--pad) * -1); }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(5, 1fr); margin: 0; } }
.tile { position: relative; aspect-ratio: 1; background: var(--surface); overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile .badge { position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 600; text-shadow: 0 1px 3px #000; }
.tile .flag { position: absolute; right: 6px; top: 6px; width: 10px; height: 10px; background: var(--delete); }
.tile .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 11px; padding: 6px; text-align: center; word-break: break-all; }

/* viewer */
.viewer { position: fixed; inset: 0; z-index: 20; background: #000; display: flex; flex-direction: column; }
.viewer .stage { flex: 1; display: grid; place-items: center; min-height: 0; }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .top { display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 6px) 12px 6px; }
.viewer .actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.viewer .actions button, .viewer .actions a { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; text-decoration: none; color: var(--text); }
.viewer .actions svg { width: 22px; height: 22px; }
.viewer .actions .danger { color: var(--delete); }

/* swipe */
.deck { position: relative; height: min(64dvh, 620px); margin-top: 12px; touch-action: none; }
.card { position: absolute; inset: 0; border-radius: 8px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); will-change: transform; user-select: none; -webkit-user-select: none; }
.card img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.card .shade { position: absolute; inset: 50% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, 0.78)); }
.card .info { position: absolute; left: 20px; right: 20px; bottom: 18px; }
.card .info .h2 { color: #fff; }
.card .info .meta { font-size: 13px; font-weight: 600; color: #fff; display: flex; gap: 10px; }
.card .stamp { position: absolute; top: 26px; font-size: 30px; font-weight: 800; letter-spacing: 0.08em; padding: 2px 12px; border: 4px solid currentColor; opacity: 0; }
.card .stamp.del { right: 22px; color: var(--delete); transform: rotate(12deg); }
.card .stamp.keep { left: 22px; color: var(--keep); transform: rotate(-12deg); }
.controls { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); margin-top: 18px; }
.controls button { min-height: 64px; display: grid; place-items: center; }
.controls svg { width: 26px; height: 26px; }
.controls .x { color: var(--delete); }
.controls .k { color: var(--keep); }
.controls .u { color: var(--muted); }
.controls button[disabled] { opacity: 0.3; }

/* code box for the shortcut key */
.code { font: 14px/1.4 ui-monospace, Menlo, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px; word-break: break-all; user-select: all; -webkit-user-select: all; }
ol.steps { padding-left: 22px; display: grid; gap: 10px; }
ol.steps li::marker { color: var(--muted); font-weight: 600; }
ol.steps code { font: 13px ui-monospace, Menlo, monospace; background: var(--surface); padding: 1px 6px; border-radius: 4px; word-break: break-all; }

/* bottom nav: three words, a line on top */
nav.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: rgba(12, 11, 10, 0.94); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabbar div { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
nav.tabbar a { min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
nav.tabbar a svg { width: 22px; height: 22px; }
nav.tabbar a[aria-current="page"] { color: var(--text); }

#toast { position: fixed; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 10px); z-index: 30; max-width: 560px; margin: 0 auto; background: var(--raised); border: 1px solid var(--line); border-radius: 6px; padding: 12px 16px; font-size: 14px; font-weight: 500; }

.empty { padding: 60px 0; text-align: center; color: var(--muted); }
.spin { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--text); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 0s !important; } }
