:root {
  /* Paper. Layout: one phone-width column; chrome stays ink-on-beige so the picked color and the photos are the only color on screen. */
  --bg: #DCD8D0;
  --panel: #ECE9E3;
  --ink: #181715;
  --mute: #666159;
  --line: #181715;
  --desk: #C6C1B7;
  --desk2: #BDB8AD;
  --pick: #8a857c;
  --bw: 1.5px;
  --hard: 2px 2px 0 var(--ink);
  --r: 3px;
  --edge: color-mix(in srgb, var(--ink) 38%, transparent);
  /* type: display face for names and big numbers, ui face for everything else */
  --display: "Bitter", Rockwell, "Roboto Slab", Georgia, serif;
  --dstyle: italic; --dweight: 900; --dtrack: -0.01em; --dstroke: 0px;
  --d1: 42px; --d2: 22px; --d3: 17px; --d4: 25px;
  --ui: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs: 15px; --fs-s: 13.5px; --fs-xs: 12px; --ubold: 700;
  color-scheme: light;
}
/* Dark is Paper with the sheet and the ink swapped. Same outlines, same hard shadows. */
:root[data-look="dark"] {
  --bg: #1F1D1A;
  --panel: #2B2824;
  --ink: #E7E2D8;
  --mute: #A19B90;
  --line: #E7E2D8;
  --desk: #131210;
  --desk2: #191715;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--desk); color: var(--ink);
  font: var(--fs)/1.35 var(--ui);
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
  display: flex; justify-content: center;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3, h4, p { margin: 0; }

#app {
  position: relative; width: 100%; max-width: 520px; height: 100%;
  background: var(--bg); overflow: hidden; display: flex; flex-direction: column;
}
@media (min-width: 600px) {
  body { background: conic-gradient(var(--desk2) 25%, var(--desk) 0 50%, var(--desk2) 0 75%, var(--desk) 0) 0 0 / 4px 4px; align-items: center; }
  #app { height: calc(100% - 48px); max-height: 900px; border: var(--bw) solid var(--line); box-shadow: 6px 6px 0 var(--ink); }
}

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.icon svg, .fab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn {
  border: var(--bw) solid var(--ink); border-radius: var(--r); background: var(--panel);
  padding: 9px 14px; box-shadow: var(--hard); font-weight: var(--ubold);
}
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn.primary { background: var(--ink); color: var(--bg); }
.seg { display: inline-flex; border: var(--bw) solid var(--line); border-radius: var(--r); overflow: hidden; flex: none; }
.seg button { padding: 5px 9px; font-size: var(--fs-s); }
.seg button + button { border-left: var(--bw) solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: var(--bw) solid var(--line); border-radius: var(--r); padding: 5px 8px; font-size: var(--fs-s); display: inline-flex; gap: 7px; align-items: baseline; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chip small { opacity: .72; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.titlebar { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 14px; border-bottom: var(--bw) solid var(--line); flex: none; min-height: 40px; }
.titlebar b { font-weight: var(--ubold); white-space: nowrap; }
.titlebar .other { display: inline-flex; align-items: center; gap: 6px; border: var(--bw) solid var(--line); border-radius: var(--r); padding: 2px 7px 2px 5px; font-size: var(--fs-s); white-space: nowrap; }
.titlebar .other i { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px var(--ink); }
.titlebar .chip0 { width: 18px; height: 18px; border-radius: 3px; background: var(--pick); box-shadow: 0 0 0 var(--bw) var(--ink); flex: none; }
.stripes { flex: 1; height: 13px; background: repeating-linear-gradient(var(--ink) 0 1.5px, transparent 1.5px 4px); opacity: .85; }
.info {
  flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.2px solid var(--mute); color: var(--mute);
  font: italic 700 9.5px/1 Georgia, "Times New Roman", serif; display: inline-grid; place-items: center; vertical-align: middle; position: relative;
}
.info::after { content: ""; position: absolute; inset: -10px; } /* bigger tap target */
.info[aria-expanded="true"] { background: var(--mute); color: var(--panel); }
#tip {
  position: absolute; z-index: 48; background: var(--ink); color: var(--bg); padding: 9px 11px; border-radius: var(--r);
  font-size: var(--fs-s); line-height: 1.4; box-shadow: 2px 2px 0 color-mix(in srgb, var(--ink) 35%, transparent); pointer-events: none;
}

/* ---------- color buttons: filled dots with a hard shadow; the picked one shows as a ring ---------- */
.rings { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; overflow-x: auto; padding: 7px 5px; scrollbar-width: none; }
.rings::-webkit-scrollbar { display: none; }
.rings .sep { flex: none; width: var(--bw); height: 22px; background: var(--line); opacity: .5; margin: 0 2px; }
.sw { flex: none; position: relative; min-width: 30px; height: 36px; display: grid; place-items: center; }
.sw i { display: block; position: relative; width: 25px; height: 25px; border-radius: 50%; border: var(--bw) solid var(--ink); background: var(--c); box-shadow: var(--hard); }
.sw.on i::after { content: ""; position: absolute; inset: 5.5px; border-radius: 50%; background: var(--bg); border: var(--bw) solid var(--ink); }
.sw.saved::after { content: ""; position: absolute; top: 0; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1.5px var(--bg); }

/* ---------- albums ---------- */
#home { overflow-y: auto; padding: 26px 16px 28px; gap: 18px; }
#home > * { flex: none; }
#home h1 { font: var(--dstyle) var(--dweight) var(--d1)/1 var(--display); letter-spacing: var(--dtrack); -webkit-text-stroke: var(--dstroke) currentColor; }
#home .sub { color: var(--mute); margin-top: 6px; }
.listhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: -6px; }
.listhead > span { color: var(--mute); }
.listhead .views { display: flex; gap: 8px; }
.listhead .views { align-items: center; }
.picbtn { flex: none; width: 32px; height: 30px; border: var(--bw) solid var(--line); border-radius: var(--r); display: grid; place-items: center; }
.picbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.picbtn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.albums { display: flex; flex-direction: column; gap: 16px; }
.albums.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; align-items: start; }
.albums.compact { gap: 10px; }
.albums.compact .mosaic { display: none; }
.card { display: block; width: 100%; text-align: left; background: var(--panel); border: var(--bw) solid var(--line); box-shadow: var(--hard); border-radius: var(--r); overflow: hidden; }
.card:active { transform: translate(2px, 2px); box-shadow: none; }
.card .mosaic { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; height: 70px; background: var(--bg); border-bottom: var(--bw) solid var(--line); }
.card .mosaic img { width: 100%; height: 70px; object-fit: cover; display: block; }
.card .mosaic .blank { display: grid; place-items: center; grid-column: 1 / -1; grid-row: 1 / -1; color: var(--mute); }
.albums.grid .mosaic { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; height: auto; aspect-ratio: 1.25; }
.albums.grid .mosaic img { height: 100%; min-height: 0; }
.card .palbar { display: flex; height: 9px; border-top: var(--bw) solid var(--line); }
.card .palbar:not(:last-child) { border-top: 0; border-bottom: var(--bw) solid var(--line); }
.albums.compact .palbar { height: 11px; }
.card .palbar i { display: block; }
.card .meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 12px 10px; }
.card .meta b { font: var(--dstyle) var(--dweight) var(--d3)/1.15 var(--display); letter-spacing: var(--dtrack); -webkit-text-stroke: var(--dstroke) currentColor; overflow-wrap: anywhere; }
.card .meta .n { color: var(--mute); white-space: nowrap; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 5px; }
.card .meta .n svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.albums.grid .meta { flex-direction: column; align-items: flex-start; gap: 3px; padding: 8px 10px 9px; }
.albums.grid .meta b { font-size: calc(var(--d3) * .94); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.opt .lab { font-weight: var(--ubold); }
.homefoot { color: var(--mute); font-size: var(--fs-s); display: flex; flex-direction: column; gap: 6px; }
.homefoot p:empty { display: none; }

/* ---------- album ---------- */
.bar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 4px; padding: 10px 8px 4px; flex: none; }
.bar h2 { text-align: center; font: var(--dstyle) var(--dweight) var(--d2)/1.15 var(--display); letter-spacing: var(--dtrack); -webkit-text-stroke: var(--dstroke) currentColor; overflow-wrap: anywhere; text-wrap: balance; }
.emo { font-style: normal; letter-spacing: 0; -webkit-text-stroke: 0; display: inline-block; margin-right: 5px; }
.strip { display: flex; align-items: center; gap: 6px; padding: 4px 11px 6px; flex: none; }
.plus { flex: none; border: var(--bw) solid var(--line); border-radius: var(--r); padding: 4px 7px; font-size: var(--fs-s); white-space: nowrap; background: var(--panel); }
.plus[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.status { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 16px 8px; min-height: 36px; flex: none; }
.status .count { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status .count i + i { margin-left: -5px; }
.status .count i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--pick); box-shadow: 0 0 0 1px var(--ink); }
.progress { height: 3px; margin: 0 16px 6px; background: color-mix(in srgb, var(--ink) 18%, transparent); flex: none; }
.progress i { display: block; height: 100%; background: var(--ink); width: 0; }
#grid { flex: 1; min-height: 0; overflow-y: auto; padding: 0 16px 96px; }
.sec h3 { display: flex; justify-content: space-between; align-items: baseline; font: var(--ubold) var(--fs-s) var(--ui); margin: 12px 1px 6px; }
.sec:first-child h3 { margin-top: 2px; }
.sec h3 span { font-weight: 400; color: var(--mute); font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 3px; overflow: hidden; background: var(--panel); display: block; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .tag { position: absolute; left: 3px; bottom: 3px; font-size: var(--fs-xs); line-height: 1; padding: 2px 3px 1px; background: var(--bg); color: var(--ink); border-radius: 2px; font-variant-numeric: tabular-nums; }
.empty { margin: 28px 0; padding: 26px 18px; border: var(--bw) dashed var(--line); border-radius: var(--r); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.empty b { font-weight: var(--ubold); }
.empty p { color: var(--mute); max-width: 30ch; }
.tiles.selecting .tile::before, .selecting .tile::before { content: ""; position: absolute; top: 5px; right: 5px; width: 17px; height: 17px; border-radius: 50%; border: var(--bw) solid var(--ink); background: var(--bg); z-index: 1; }
.selecting .tile.sel::before { background: var(--ink); box-shadow: inset 0 0 0 3px var(--bg); }
.selecting .tile.sel { outline: 3px solid var(--ink); outline-offset: -3px; }
.selecting .tile { -webkit-touch-callout: none; user-select: none; }
#selbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--panel); border-top: 2px solid var(--ink); padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.selrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.selrow b { font-weight: var(--ubold); }
.selrow .lnk { padding: 4px 0 4px 16px; text-decoration: underline; text-underline-offset: 3px; }
.selrow.acts { justify-content: flex-start; flex-wrap: wrap; }
.selrow .btn:disabled { opacity: .4; box-shadow: none; }
#app.selecting .fab { display: none; }
#album.drop #grid { outline: 2px dashed var(--ink); outline-offset: -8px; }

.fab {
  position: absolute; right: 16px; bottom: 18px; z-index: 30; width: 54px; height: 54px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--ink); box-shadow: var(--hard); display: grid; place-items: center;
}
.fab.left { right: auto; left: 16px; z-index: 5; }
.fab:active { transform: translate(2px, 2px); box-shadow: none; }
#fab svg circle { fill: var(--pick); }

/* ---------- settings sheet ---------- */
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 58%;
  background: var(--panel); border-top: 2px solid var(--ink);
  display: flex; flex-direction: column; transition: transform .22s ease-out;
}
#app.in-detail #sheet { max-height: calc(56% - 54px); }
#sheet.closed { transform: translateY(104%); visibility: hidden; transition: transform .2s ease-in, visibility 0s .2s; }
.sheet-body { overflow-y: auto; padding: 12px 16px 22px; display: flex; flex-direction: column; gap: 16px; }
.group h4 { font: var(--ubold) var(--fs-s) var(--ui); margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.sheet-body .info { margin-right: 6px; } /* centred over the reset arrows */
.row { display: grid; grid-template-columns: 82px 1fr 44px 26px; align-items: center; gap: 8px; min-height: 30px; }
.rst { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.rst svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rst:disabled { opacity: .25; cursor: default; }
.row label { color: var(--mute); }
.row output { display: flex; justify-content: flex-end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row output i { font-style: normal; display: inline-block; }
.row output .nm { min-width: 2ch; text-align: right; }
.row output .un { width: .62em; text-align: left; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 9px; border-radius: 5px; background: var(--track, transparent); border: var(--bw) solid var(--line); }
input[type="range"]::-moz-range-track { height: 9px; border-radius: 5px; background: var(--track, transparent); border: var(--bw) solid var(--line); box-sizing: border-box; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); border: 2px solid var(--ink); margin-top: -6px; box-shadow: 1px 1px 0 var(--ink); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--panel); border: 2px solid var(--ink); box-shadow: 1px 1px 0 var(--ink); }
.checkrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; font-weight: var(--ubold); font-size: var(--fs-s); }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 0; border: var(--bw) solid var(--ink); border-radius: 2px; background: var(--bg); display: grid; place-items: center; }
.check input:checked::after { content: ""; width: 10px; height: 10px; background: var(--ink); }
.presets { display: flex; flex-direction: column; gap: 6px; }
.presets:empty { display: none; }
.preset { display: grid; grid-template-columns: 22px 1fr 32px; align-items: center; gap: 10px; }
.preset .dot { width: 22px; height: 22px; border-radius: 4px; box-shadow: 0 0 0 var(--bw) var(--ink); }
.preset .name { text-align: left; padding: 6px 0; }
.preset .name small { color: var(--mute); margin-left: 6px; }

/* ---------- photo page ---------- */
#detail { position: absolute; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
.dhead { text-align: center; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dhead b { font-weight: var(--ubold); }
.dhead a { font-size: var(--fs-s); color: var(--mute); text-underline-offset: 2px; }
.stage { position: relative; flex: none; height: 44%; display: grid; place-items: center; padding: 0 16px; }
.stage img, .stage canvas { grid-area: 1 / 1; display: block; outline: var(--bw) solid var(--line); }
.stage canvas { image-rendering: pixelated; }
.stage img, .stage canvas { cursor: crosshair; }
#dMark { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 2px solid var(--ink); box-shadow: 0 0 0 2px var(--bg), var(--hard); pointer-events: none; z-index: 2; }
.dbody { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 96px; display: flex; flex-direction: column; gap: 14px; }
.dtop { display: flex; align-items: center; gap: 10px; }
.stats { display: grid; grid-template-columns: 1.25fr 1fr 1fr; border: var(--bw) solid var(--line); border-radius: var(--r); background: var(--panel); }
.stats div { padding: 8px 10px 9px; min-width: 0; }
.stats div + div { border-left: var(--bw) solid var(--line); }
.stats b { font-variant-numeric: lining-nums; display: block; font: var(--dstyle) var(--dweight) var(--d4)/1.1 var(--display); letter-spacing: var(--dtrack); -webkit-text-stroke: var(--dstroke) currentColor; }
.stats span { color: var(--mute); font-size: var(--fs-xs); }
.pal { display: flex; height: 26px; border: var(--bw) solid var(--line); border-radius: var(--r); overflow: hidden; }
.pal button { display: block; min-width: 4px; height: 100%; }
.pal button:focus-visible { outline-offset: -3px; }
.cap { color: var(--mute); font-size: var(--fs-s); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.cap .info { color: var(--ink); }

/* ---------- menu, dialog, toast ---------- */
#menu { position: absolute; top: 50px; right: 12px; z-index: 45; min-width: 190px; background: var(--panel); border: var(--bw) solid var(--ink); box-shadow: var(--hard); border-radius: var(--r); }
#menu button { display: block; width: 100%; text-align: left; padding: 11px 13px; }
#menu button + button { border-top: var(--bw) solid color-mix(in srgb, var(--line) 35%, transparent); }
#dialog { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: color-mix(in srgb, #000 42%, transparent); }
.box { width: 100%; max-width: 340px; background: var(--panel); border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.box-body { padding: 14px 14px 4px; display: flex; flex-direction: column; gap: 12px; }
.box-body input[type="text"] { width: 100%; padding: 9px 10px; border: var(--bw) solid var(--ink); border-radius: var(--r); background: var(--bg); }
.box-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px; }
.box-body p { line-height: 1.4; }
.emos { display: flex; flex-wrap: wrap; gap: 4px; }
.emos button { width: 34px; height: 34px; border-radius: var(--r); font-size: 19px; border: var(--bw) solid transparent; }
.emos button[aria-pressed="true"] { border-color: var(--ink); background: var(--bg); }
#toast { position: absolute; left: 16px; right: 16px; bottom: 86px; z-index: 46; background: var(--ink); color: var(--bg); padding: 10px 12px; border-radius: var(--r); font-size: var(--fs-s); }

@media (prefers-reduced-motion: reduce) { #sheet, #sheet.closed { transition: none; } }
