:root {
  --bg: #1d1c1a;
  --panel: #2a2926;
  --panel-2: #34332f;
  --line: #45433e;
  --text: #ece8e1;
  --muted: #9d978c;
  --accent: #ef4f93;
  --accent-ink: #1d1c1a;
  --good: #63c174;
  --ok: #d8b84a;
  --far: #d9774b;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* .btn and friends set display, which would beat the hidden attribute */
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: rgba(29, 28, 26, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { display: flex; align-items: center; gap: 8px; font-size: 18px; margin: 0; letter-spacing: 0.02em; }
.topbar h1 img { display: block; }
.tabs { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: 0; padding: 6px 14px; border-radius: 999px; white-space: nowrap; flex: none;
  color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: default; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 6px 12px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--panel-2); color: var(--text); }

.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-size: 14px; }

/* Match view */
.match-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .match-layout { grid-template-columns: 1fr; } }

.photo-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.radius { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.radius input { width: 90px; }

.canvas-wrap {
  position: relative; min-height: 260px;
  background: repeating-conic-gradient(#262522 0 25%, #2d2c29 0 50%) 0 0 / 20px 20px;
  border-radius: 8px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.canvas-wrap.dragover { outline: 2px dashed var(--accent); outline-offset: -6px; }
.canvas-inner { position: relative; line-height: 0; }
.canvas-inner:has(#photo:not(.loaded)) { display: none; }
#photo { display: block; max-width: 100%; max-height: 70vh; cursor: crosshair; touch-action: manipulation; }
#photo:not(.loaded) { display: none; }
.drop-hint { text-align: center; padding: 30px 20px; }
.marker {
  z-index: 3;
  position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1.5px #000, inset 0 0 0 1.5px #000; pointer-events: none;
}
.marker.white { border-style: dashed; border-color: #ffe14d; }

.photo-footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; }
.photo-footer #auto-palette { margin-left: auto; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.palette button {
  width: 38px; height: 38px; border-radius: 8px; border: 2px solid transparent; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.3);
}
.palette button.active { border-color: #fff; }
.manual { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 13px; }
.manual input[type=color] { width: 36px; height: 30px; border: 0; padding: 0; background: none; }
.manual input[type=text] { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; width: 100%; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: none; color: var(--muted);
}
.chip.on { background: var(--panel-2); color: var(--text); border-color: var(--muted); }

.results h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.target { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.target .sw { width: 64px; height: 64px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.35); flex: none; }
.target code { font-size: 13px; }
.empty { padding: 30px 0; text-align: center; }

.match-list { display: flex; flex-direction: column; gap: 6px; }
.match {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center;
  padding: 6px; border-radius: 8px; background: var(--panel-2); cursor: pointer;
}
.match:hover { outline: 1px solid var(--line); }
.match .compare { display: flex; width: 44px; height: 44px; border-radius: 7px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.match .compare span { flex: 1; }
.match .name { font-weight: 600; line-height: 1.2; }
.match .sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.de { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.de b { display: block; font-size: 15px; }
.de.good b { color: var(--good); } .de.ok b { color: var(--ok); } .de.far b { color: var(--far); }

.owned-mark { color: var(--accent); }
.opacity { display: inline-flex; gap: 2px; vertical-align: middle; }
.opacity i { width: 4px; height: 11px; border-radius: 2px; border: 1px solid currentColor; }
.opacity i.f { background: currentColor; }

.recipe { background: var(--panel-2); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.recipe-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.recipe .bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin: 8px 0 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.recipe .bar span { display: block; }
.recipe .pair { display: flex; gap: 6px; align-items: center; }
.recipe .pair .sw { width: 26px; height: 26px; border-radius: 6px; }
.recipe ul { margin: 0; padding-left: 18px; font-size: 14px; }
.recipe .note { font-size: 12px; color: var(--muted); margin-top: 6px; }

.triad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.triad > div { background: var(--panel-2); border-radius: 8px; padding: 8px; font-size: 13px; cursor: pointer; }
.triad .sw { height: 36px; border-radius: 6px; margin-bottom: 6px; }
.triad small { display: block; color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }

/* Library */
.lib-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; position: sticky; top: 56px; z-index: 5; }
.lib-toolbar input[type=search], .lib-toolbar select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
.lib-toolbar input[type=search] { flex: 1 1 180px; min-width: 0; }
.library h2 { font-size: 15px; margin: 22px 0 10px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; position: relative; }
.card:hover { border-color: var(--muted); }
.swatch { height: 78px; position: relative; }
.card .meta { padding: 6px 8px 8px; font-size: 12px; line-height: 1.25; }
.card .meta b { display: block; font-size: 13px; font-weight: 600; }
.card .own {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.45); color: #fff; cursor: pointer; font-size: 14px; line-height: 26px; padding: 0;
}
.card .own.on { background: var(--accent); color: var(--accent-ink); }
.card .star { position: absolute; top: 6px; left: 8px; font-size: 14px; text-shadow: 0 0 3px rgba(0,0,0,.6); }
.card .opacity { position: absolute; bottom: 6px; right: 8px; color: rgba(0,0,0,.7); }
.card.light .opacity { color: rgba(0,0,0,.7); }
.card.dark .opacity { color: rgba(255,255,255,.75); }

/* Detail dialog */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
.detail-hero { height: 120px; position: relative; }
.detail-body { padding: 14px 16px 18px; }
.detail-body h2 { margin: 0 0 2px; font-size: 20px; }
.detail-body dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin: 12px 0; }
.detail-body dt { color: var(--muted); }
.detail-body dd { margin: 0; }
.detail-actions { display: flex; gap: 8px; margin-top: 12px; }
.close { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.5); border: 0; color: #fff; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.4); max-width: calc(100vw - 32px);
}
a { color: var(--accent); }
.brand-note { font-size: 13px; width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
h3.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.panel > h3.sec:first-child { margin-top: 0; }

/* Project bar (Foto) */
.project-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; padding: 8px 12px; }
.project-bar label { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; }
.project-bar select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; max-width: 220px; }
#proj-info { font-size: 13px; }

.emark {
  position: absolute; transform: translate(-50%, -50%); min-width: 22px; height: 22px; padding: 0 4px;
  border-radius: 11px; border: 2px solid #fff; box-shadow: 0 0 0 1.5px #000;
  font: 700 11px/18px system-ui, sans-serif; color: #fff; text-align: center; text-shadow: 0 0 2px #000, 0 0 2px #000;
  pointer-events: none; transition: transform .15s;
}
.emark.hl { transform: translate(-50%, -50%) scale(1.5); z-index: 2; }
.marker { z-index: 3; }

.match.with-add { grid-template-columns: 44px 1fr auto auto; }
.add-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px;
  min-width: 32px; height: 32px; cursor: pointer; font-size: 13px; padding: 0 10px;
}
.add-btn:hover { border-color: var(--accent); color: var(--accent); }
.recipe-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

/* Settings */
.settings-block { margin-bottom: 16px; }
.settings-block h2 { font-size: 17px; margin: 0 0 4px; }
.settings-block > p { margin: 0 0 12px; font-size: 14px; }
.brand-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.brand-item {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid transparent; opacity: .6;
}
.brand-item.on { border-color: var(--accent); opacity: 1; }
.brand-item input { width: 18px; height: 18px; accent-color: var(--accent); }
.brand-item small { display: block; color: var(--muted); font-size: 12px; }
.inv-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.inv-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0 12px; }
.inv-toolbar input { flex: 1 1 200px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 0; }
.inv-brand { border-top: 1px solid var(--line); padding: 8px 0; }
.inv-brand-head { display: flex; gap: 6px; align-items: center; }
.inv-toggle { background: none; border: 0; cursor: pointer; padding: 6px 0; font-size: 15px; text-align: left; }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; margin-top: 6px; }
.inv-item {
  display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 7px; cursor: pointer;
  font-size: 13px; color: var(--muted); border: 1px solid transparent; min-width: 0;
}
.inv-item:hover { background: var(--panel-2); }
.inv-item.on { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.inv-item input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.inv-sw { width: 20px; height: 20px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.inv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Projects */
.proj-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.proj-head h2 { margin: 0; font-size: 20px; flex: 1; }
.proj-name {
  font-size: 18px; font-weight: 700; background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 4px 8px; min-width: 0; flex: 1 1 200px;
}
.proj-name:hover, .proj-name:focus { border-color: var(--line); background: var(--panel); outline: none; }
.btn.danger:hover { border-color: #d9534f; color: #ff8a85; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.proj-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; }
.proj-card:hover { border-color: var(--muted); }
.proj-thumb { height: 140px; background: var(--panel-2) center / cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.proj-meta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.proj-meta b { font-size: 15px; }
.proj-dots { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }
.proj-dots i { width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.proj-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .proj-layout { grid-template-columns: 1fr; } }
.proj-photo { position: relative; line-height: 0; }
.proj-photo img { width: 100%; border-radius: 8px; }
.notes-label { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.notes-label textarea { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--text); font: inherit; resize: vertical; }
.entries { display: flex; flex-direction: column; gap: 6px; }
.entry { display: grid; grid-template-columns: auto auto 1fr auto auto; gap: 10px; align-items: center; background: var(--panel-2); border-radius: 8px; padding: 8px; }
.enum { width: 24px; height: 24px; border-radius: 12px; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.7); }
.entry-sw { display: flex; border-radius: 6px; overflow: hidden; height: 36px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.entry-sw span { width: 18px; }
.entry-sw span:first-child { width: 26px; }
.entry-body { min-width: 0; }
.entry-text { font-size: 13px; line-height: 1.35; }
.entry-note { width: 100%; margin-top: 4px; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 3px 6px; font-size: 13px; color: var(--muted); }
.entry-note:hover, .entry-note:focus { border-color: var(--line); color: var(--text); outline: none; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 6px; }
.icon-btn:hover { color: #ff8a85; }
.needed { display: flex; flex-direction: column; gap: 4px; }
.needed-item { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.needed-item:hover { background: var(--panel-2); }
.needed-item .tag { margin-left: auto; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.needed-item.missing .tag { background: rgba(217,119,75,.2); color: var(--far); }
.warn { color: var(--far); text-transform: none; letter-spacing: 0; }
.good-text { color: var(--good); text-transform: none; letter-spacing: 0; }

@media (max-width: 600px) {
  .topbar { gap: 10px; padding: 8px 10px; }
  .topbar h1 span { display: none; }
  .tab { padding: 6px 10px; }
  .entry { grid-template-columns: auto 1fr auto auto; }
  .entry .entry-sw { display: none; }
  .inv-grid { grid-template-columns: 1fr; }
  .inv-item { padding: 8px; }
  main { padding: 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .lib-toolbar { position: static; }
  .lib-toolbar select { flex: 1 1 140px; }
}

.code { font: 11px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--muted); letter-spacing: .02em; }
.inv-item .code { margin-left: auto; padding-left: 6px; flex: none; }
.approx { font-size: 11px; color: var(--ok); white-space: nowrap; }
.inv-item .approx { margin-left: 4px; }

/* Zoom & pan */
.canvas-wrap { overflow: hidden; }
.canvas-inner { transform-origin: 0 0; --iz: 1; touch-action: none; cursor: crosshair; }
.canvas-inner.panning { cursor: grabbing; }
#photo { touch-action: none; }
.marker { width: 22px; height: 22px; margin: 0; transform: translate(-50%, -50%); }
.marker.white { width: 22px; height: 22px; transform: translate(-50%, -50%) scale(var(--iz, 1)); }
.emark { transform: translate(-50%, -50%) scale(var(--iz, 1)); }
.emark.hl { transform: translate(-50%, -50%) scale(calc(1.5 * var(--iz, 1))); }
.seg.zoom button { min-width: 34px; font-variant-numeric: tabular-nums; }
#zoom-val { font-size: 12px; }

/* In-page prompt/confirm */
dialog.ask { width: min(420px, calc(100vw - 32px)); }
.ask-body { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.ask-body h2 { margin: 0; font-size: 18px; }
.ask-body p { margin: 0; color: var(--muted); font-size: 14px; }
.ask-body input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 16px; }
.ask-body input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.ask-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn.danger-fill { background: #c9473f; border-color: #c9473f; color: #fff; font-weight: 600; }

/* Sync indicator */
.sync-status {
  order: 3; margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
  font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.sync-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-status.on i { background: var(--good); }
.sync-status.busy i { background: var(--ok); }
.sync-status.offline i { background: var(--far); }
.sync-status.local i { background: transparent; border: 1px solid var(--muted); }
@media (max-width: 600px) { .sync-status span { display: none; } .sync-status { padding: 6px; } }

/* Project tags */
.ptag {
  --tag-h: 330;
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: hsl(var(--tag-h) 45% 30% / .45); color: hsl(var(--tag-h) 80% 85%);
  border: 1px solid hsl(var(--tag-h) 45% 50% / .5); white-space: nowrap;
}
.ptags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.ptags.editor { align-items: center; margin: -4px 0 14px; gap: 6px; }
.ptags.editor .ptag { font-size: 13px; padding: 3px 4px 3px 10px; }
.ptag-x { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 4px; font-size: 11px; opacity: .7; }
.ptag-x:hover { opacity: 1; }
#pd-tag-input {
  flex: 1 1 180px; min-width: 0; background: transparent; border: 1px dashed var(--line); border-radius: 999px;
  padding: 4px 12px; font-size: 13px;
}
#pd-tag-input:focus { outline: none; border-color: var(--accent); border-style: solid; }
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; font-size: 13px; }
.ptag.filter { cursor: pointer; opacity: .65; font-size: 13px; padding: 4px 11px; }
.ptag.filter.on { opacity: 1; box-shadow: 0 0 0 2px hsl(var(--tag-h) 70% 65%); }
.ptag.filter small { opacity: .7; font-size: 11px; }

/* Project photos */
.proj-photos { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.proj-photos:empty { display: none; }
.pthumb {
  position: relative; width: 52px; height: 52px; border-radius: 8px; border: 2px solid transparent; padding: 0;
  background: var(--panel-2) center / cover no-repeat; cursor: pointer; flex: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.pthumb.on { border-color: var(--accent); }
.pthumb i {
  position: absolute; right: 2px; bottom: 2px; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  background: rgba(0,0,0,.7); color: #fff; font: 700 10px/16px system-ui, sans-serif; font-style: normal;
}
.pthumb.add { display: inline-flex; align-items: center; justify-content: center; font-size: 22px; color: var(--muted); border: 1px dashed var(--line); }
.pthumb.add:hover { color: var(--accent); border-color: var(--accent); }
.pgallery { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.entry { cursor: default; }
.entry:has(.enum) { cursor: pointer; }
.ask-actions.stacked { flex-direction: column; align-items: stretch; }

/* Zones */
.target .zone-btn { margin-left: auto; align-self: center; }
.sec-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-top: 0; }
.sec-row h3.sec { margin: 0; }
.entry-note.zone-name { color: var(--text); font-weight: 600; }
dialog.zone { width: min(520px, calc(100vw - 24px)); }
.zone-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 48px); }
.zone-head { display: flex; align-items: center; gap: 10px; }
.zone-head h2 { margin: 0; font-size: 18px; }
.zone-head .sw { width: 28px; height: 28px; border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.zone-body input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 16px; }
.zone-body input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.z-picked { display: flex; flex-direction: column; gap: 4px; }
.z-picked p { margin: 4px 0; font-size: 13px; }
.z-row { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 8px; padding: 5px 6px; font-size: 14px; }
.z-row select { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; font-size: 13px; }
.z-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.z-results { overflow-y: auto; min-height: 120px; max-height: 38vh; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 6px; }
.z-cand { display: flex; align-items: center; gap: 8px; background: none; border: 0; border-radius: 7px; padding: 6px; cursor: pointer; text-align: left; font-size: 14px; }
.z-cand:hover, .z-cand:focus { background: var(--panel-2); outline: none; }
.icon-btn:disabled { opacity: .3; cursor: default; }
@media (max-width: 600px) { .target { flex-wrap: wrap; } .target .zone-btn { margin-left: 0; width: 100%; } }

/* Zone draft */
.zdraft { border: 1px solid var(--accent); border-radius: 10px; padding: 10px; margin: 10px 0 4px; background: rgba(239, 79, 147, .07); }
.zdraft-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zdraft-head .sw { width: 22px; height: 22px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.zdraft-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.zchip { display: inline-flex; align-items: center; gap: 5px; background: var(--panel-2); border-radius: 999px; padding: 3px 4px 3px 6px; font-size: 13px; }
.zchip i { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.zchip em { font-style: normal; color: var(--muted); font-size: 12px; }
.zchip button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 11px; }
.zdraft-hint { font-size: 12px; margin: 6px 0 0; }
.match.with-zone { grid-template-columns: 44px 1fr auto auto auto; }
.de small { display: block; font-size: 13px; }
.zone-mini {
  border: 1px dashed var(--line); background: none; color: var(--muted); border-radius: 8px; height: 32px;
  padding: 0 8px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.zone-mini:hover { color: var(--accent); border-color: var(--accent); }
.zone-mini.on { border-style: solid; border-color: var(--accent); color: var(--accent); }
.zone-mini.big { margin-right: auto; }
@media (max-width: 600px) {
  .match .de small { display: none; }
  .match.with-zone { gap: 6px; }
}

/* Guide photos */
.pthumb.guide { box-shadow: inset 0 0 0 2px #e0b341; }
.pthumb b {
  position: absolute; left: 2px; top: 2px; background: #e0b341; color: #1d1c1a; border-radius: 4px;
  font: 700 9px/14px system-ui, sans-serif; padding: 0 4px; text-transform: uppercase; letter-spacing: .03em;
}
.pthumb.add.guide-add { width: auto; padding: 0 10px; font-size: 13px; color: #e0b341; border-color: #e0b341; }
.pphoto-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.pphoto-meta input { flex: 1 1 160px; min-width: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 13px; }

/* About */
.about { max-width: 760px; margin: 0 auto; line-height: 1.6; }
.about h2 { margin-top: 0; }
.about h3 { margin: 28px 0 8px; font-size: 16px; }
.about h4 { margin: 20px 0 6px; font-size: 14px; }
.about ol, .about ul { padding-left: 22px; }
.about li { margin: 6px 0; }
.about .formula { font: 14px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--panel-2);
  border-radius: 8px; padding: 10px 14px; overflow-x: auto; }
.about-de { border-collapse: collapse; margin: 8px 0; }
.about-de td { padding: 4px 12px 4px 0; vertical-align: middle; }
.mix-demo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.mix-demo figure { margin: 0; background: var(--panel-2); border-radius: 8px; padding: 10px; }
.mix-demo .eq { display: flex; align-items: center; gap: 6px; font-size: 18px; color: var(--muted); }
.mix-demo .eq span { width: 40px; height: 40px; border-radius: 6px; border: 1px solid var(--line); flex: none; }
.mix-demo figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
@media (max-width: 600px) { .mix-demo { grid-template-columns: 1fr; } .tab { padding: 6px 5px; font-size: 14px; } }

/* Export image */
dialog.export { width: min(760px, calc(100vw - 24px)); }
.export-body { overflow-y: auto; overflow-x: hidden; }
.export-body > * { min-width: 0; }
.exp-opts { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.exp-preview { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; justify-content: center; min-height: 120px; align-items: center; }
.exp-preview canvas { display: block; max-width: 100%; max-height: 55vh; height: auto; width: auto; border-radius: 4px; }

/* Accounts */
.sync-status.signedout { color: var(--text); border-color: var(--accent); }
.sync-status.signedout i { background: var(--accent); }
.sync-status .avatar { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; flex: none; display: grid; place-items: center;
  background: var(--panel-2); color: var(--text); font-size: 11px; font-style: normal; }
dialog.account .avatar.big { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 22px; font-weight: 700; }
.acc-head { display: flex; align-items: center; gap: 12px; }
.acc-head h2 { margin: 0; }
.acc-usage { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.acc-usage .bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.acc-usage .bar i { display: block; height: 100%; background: var(--accent); }
.gsi-button { min-height: 44px; display: flex; justify-content: center; align-items: center; }
.dev-login { display: flex; gap: 8px; }
.dev-login input { flex: 1; min-width: 0; }
.ask-body .error { color: var(--far); }
@media (max-width: 600px) { .sync-status.signedout i { width: 10px; height: 10px; } }

/* Legal page and links */
.home-link { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.legal h2 { margin-top: 32px; }
.legal h2:first-child { margin-top: 0; }
.legal a, .legal-links a, .ask-body .fine a { color: var(--accent); }
.legal-links { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.ask-body .fine { font-size: 12px; }

/* Language */
html[lang="en"] .about-ca, html:not([lang="en"]) .about-en { display: none; }
.lang-block { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.lang-block h2 { margin: 0; }
