@import url(/fonts/fonts.css);

:root {
  --wall: #171614;
  --wall-2: #1e1c19;
  --wall-3: #26231f;
  --ink: #efe8d8;
  --muted: #a39a88;
  --line: rgba(239, 232, 216, 0.14);
  --line-strong: rgba(239, 232, 216, 0.28);
  --paper: #efe8d8;
  --paper-ink: #22201c;
  --paper-muted: #6b6152;
  --brass: #c99a2e;
  --brass-deep: #8a6a24;
  --frame: #b8913a;
  --danger: #d4664d;
  --ok: #7fae6a;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--wall);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brass); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
.mono { font-family: var(--mono); font-size: 0.92em; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--brass);
  border-radius: 3px;
  background: var(--brass);
  color: #1b1610;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms, border-color 140ms;
}
.btn:hover { background: #d8aa3e; border-color: #d8aa3e; }
.btn:disabled { background: transparent; border-color: var(--line-strong); color: var(--muted); cursor: not-allowed; }
.btn.quiet { background: transparent; border-color: var(--line-strong); color: var(--ink); font-weight: 500; }
.btn.quiet:hover { border-color: var(--ink); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn .chip { width: 16px; height: 16px; border-radius: 2px; outline: 1px solid rgba(0, 0, 0, 0.35); outline-offset: -1px; }
.linklike {
  background: none; border: 0; padding: 0; color: var(--brass); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--wall);
  position: relative;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand svg { width: 28px; height: 28px; flex: none; }
.brand i { font-style: italic; color: var(--brass); }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-bottom: 2px solid transparent;
  transition: color 140ms;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brass); }
.live { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.live b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }

/* account menu */
.account { position: relative; }
.account .btn { min-height: 34px; padding: 4px 12px; }
.account details { position: relative; }
.account summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  white-space: nowrap;
}
.account summary::-webkit-details-marker { display: none; }
.account summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: 0.7; }
.account .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  background: var(--wall-3);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 20;
}
.account .menu p { margin: 6px 8px 10px; font-size: 13px; color: var(--muted); }
.account .menu p b { color: var(--ink); font-weight: 500; }
.account .menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 8px; border-radius: 3px; cursor: pointer;
}
.account .menu button:hover { background: rgba(255, 255, 255, 0.06); }
.account .menu button.warn { color: var(--danger); }

@media (max-width: 720px) {
  .top { gap: 10px; padding: 0 12px; height: 52px; }
  .brand span { display: none; }
  .nav a { padding: 6px 6px; font-size: 14px; }
  .live { display: none; }
}

/* ---------- dialogs ---------- */
dialog {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--wall-2);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
dialog::backdrop { background: rgba(10, 9, 8, 0.7); }
.dlg { padding: 22px 22px 20px; }
.dlg h2 { font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1.1; margin: 0 0 6px; }
.dlg .hint { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.dlg .switch { display: flex; gap: 18px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.dlg .switch button {
  background: none; border: 0; padding: 0 0 8px; margin-bottom: -1px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.dlg .switch button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brass); }
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; }
.field input, .field select {
  width: 100%;
  background: var(--wall);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 9px 10px;
}
.field input:focus { border-color: var(--brass); outline: none; }
.field small { color: var(--muted); font-size: 12px; }
.dlg .err { color: var(--danger); min-height: 1.4em; margin: 0 0 10px; font-size: 14px; }
.dlg .actions { display: flex; gap: 10px; justify-content: flex-end; }
.dlg .close {
  position: absolute; right: 10px; top: 10px; width: 32px; height: 32px;
  background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer;
}

/* ---------- exhibition hall (canvas page) ---------- */
body.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.hall { position: relative; flex: 1; min-height: 0; background: var(--wall-2); overflow: hidden; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: crosshair; }
#view.grabbing { cursor: grabbing; }
#view.picking { cursor: copy; }

.plaque {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 260px;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 12px 14px 12px;
  border-radius: 1px;
  border: 1px solid #cfc6b2;
  font-size: 13px;
  line-height: 1.45;
}
.plaque h1 { font-family: var(--serif); font-weight: 500; font-size: 24px; line-height: 1.05; margin: 0 0 4px; }
.plaque p { margin: 0; }
.plaque .meta { font-family: var(--serif); font-style: italic; color: var(--paper-muted); font-size: 14px; }
.plaque .facts-line { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(34, 32, 28, 0.18); font-variant-numeric: tabular-nums; }
.plaque .legal { margin-top: 10px; font-size: 11px; color: var(--paper-muted); }
.plaque .legal a { color: var(--paper-muted); }
.hall-tabs { display: flex; margin: 0 0 10px; border: 1px solid rgba(34, 32, 28, 0.25); border-radius: 2px; }
.hall-tabs a {
  flex: 1; text-align: center; padding: 3px 0; font-size: 12px; color: var(--paper-muted); text-decoration: none;
}
.hall-tabs a + a { border-left: 1px solid rgba(34, 32, 28, 0.25); }
.hall-tabs a:hover { color: var(--paper-ink); }
.hall-tabs a[aria-current="page"] { background: var(--paper-ink); color: var(--paper); }
@media (max-width: 720px) {
  .plaque { left: 10px; top: 10px; width: auto; max-width: 200px; padding: 8px 10px; }
  .plaque h1 { font-size: 18px; }
  .plaque .meta, .plaque .facts-line.ends, .plaque .legal { display: none; }
}

.zoom { position: absolute; right: 16px; top: 16px; display: flex; flex-direction: column; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--wall); }
.zoom button { width: 40px; height: 40px; background: none; border: 0; cursor: pointer; font-size: 20px; line-height: 1; display: grid; place-items: center; }
.zoom button + button { border-top: 1px solid var(--line); }
.zoom button:hover { background: rgba(255, 255, 255, 0.06); }
.zoom svg { width: 18px; height: 18px; }
@media (max-width: 720px) { .zoom { right: 10px; top: 10px; } }

#minimap {
  position: absolute; right: 16px; bottom: 16px;
  width: 132px; height: 132px;
  border: 1px solid var(--line-strong); background: var(--wall);
  cursor: pointer; image-rendering: pixelated;
}
@media (max-width: 720px) { #minimap { display: none; } }

.tip {
  position: absolute;
  pointer-events: none;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 5px 8px;
  border-radius: 2px;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  border: 1px solid #cfc6b2;
  z-index: 4;
}
.tip b { font-weight: 600; }
.tip .mono { color: var(--paper-muted); }

.panel {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 520px);
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 12px;
  background: var(--wall);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 3;
}
.panel .px { width: 34px; height: 34px; border-radius: 2px; border: 1px solid var(--line-strong); cursor: pointer; padding: 0; }
.panel .px:hover { border-color: var(--brass); }
.panel-info { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.panel-info strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.panel-info span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-info span b { color: var(--ink); font-weight: 500; }
.panel .x { width: 34px; height: 34px; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }
@media (max-width: 720px) {
  .panel { bottom: 10px; width: calc(100% - 20px); gap: 10px; }
  .panel .btn { padding: 8px 12px; }
}

.toast {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translate(-50%, -8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 8px 8px 8px 14px;
  border-radius: 3px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  font-weight: 500;
  z-index: 6;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast .btn { min-height: 32px; padding: 4px 10px; }
.toast .sw { width: 14px; height: 14px; border-radius: 2px; display: inline-block; vertical-align: -2px; margin-right: 4px; outline: 1px solid rgba(0, 0, 0, 0.3); outline-offset: -1px; }
@media (max-width: 720px) { .toast { top: 62px; } }

.intro {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(calc(100% - 32px), 440px);
  background: var(--paper);
  color: var(--paper-ink);
  padding: 22px 22px 18px;
  border-radius: 2px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  z-index: 7;
}
.intro h2 { font-family: var(--serif); font-weight: 500; font-size: 26px; margin: 0 0 12px; }
.intro ol { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: s; }
.intro li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 4px; padding: 8px 0; border-top: 1px solid rgba(34, 32, 28, 0.15); }
.intro li::before { content: counter(s, decimal-leading-zero); font-family: var(--mono); font-size: 12px; color: var(--paper-muted); padding-top: 3px; }
.intro li b { display: block; font-weight: 600; }
.intro li span { color: var(--paper-muted); font-size: 14px; }
.intro .btn { width: 100%; }

/* ---------- dock (tools + colours) ---------- */
.dock {
  border-top: 1px solid var(--line);
  background: var(--wall);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-areas: "tools color palette" "status status status";
  gap: 10px 20px;
  align-items: center;
  position: relative;
  z-index: 5;
}
.tools { grid-area: tools; display: flex; border: 1px solid var(--line-strong); border-radius: 3px; }
.tool {
  display: flex; align-items: center; gap: 7px;
  background: none; border: 0; padding: 7px 12px; cursor: pointer; color: var(--muted);
}
.tool + .tool { border-left: 1px solid var(--line-strong); }
.tool svg { width: 18px; height: 18px; }
.tool:hover { color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--ink); color: var(--wall); }
.tool kbd { font-family: var(--mono); font-size: 11px; opacity: 0.6; }

.color { grid-area: color; display: flex; align-items: center; gap: 8px; }
.current {
  position: relative; width: 40px; height: 40px; border-radius: 3px; cursor: pointer;
  border: 1px solid var(--line-strong);
}
.current input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.current::after {
  content: ""; position: absolute; right: -4px; bottom: -4px; width: 14px; height: 14px; border-radius: 2px;
  background: var(--wall) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3 10.5 9.5 4M8 2.5 11.5 6' stroke='%23efe8d8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / 12px no-repeat;
  border: 1px solid var(--line-strong);
  pointer-events: none;
}
#hex {
  width: 92px; background: var(--wall-2); border: 1px solid var(--line-strong); border-radius: 3px;
  padding: 8px; font-family: var(--mono); font-size: 13px; text-transform: lowercase;
}
#hex:focus { border-color: var(--brass); outline: none; }
#hex.bad { border-color: var(--danger); }

.swatches { grid-area: palette; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.palette, .recent { display: flex; gap: 4px; flex-wrap: wrap; }
.recent-row { display: flex; align-items: center; gap: 8px; }
.recent-row small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.swatch {
  width: 24px; height: 24px; border-radius: 2px; border: 0; padding: 0; cursor: pointer;
  outline: 1px solid rgba(255, 255, 255, 0.12);
  outline-offset: -1px;
}
.swatch:hover { outline: 2px solid var(--ink); outline-offset: -2px; }
.swatch[aria-pressed="true"], .swatch[aria-pressed="true"]:hover { outline: 2px solid var(--brass); outline-offset: 1px; }

.status { grid-area: status; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.status.ready b { color: var(--brass); }
.status .spacer { flex: 1; }
.status .btn { min-height: 32px; padding: 4px 12px; font-size: 13px; }

@media (min-width: 1100px) {
  .dock { grid-template-columns: auto auto 1fr 320px; grid-template-areas: "tools color palette status"; }
  .status { justify-content: flex-end; text-align: right; }
}
@media (max-width: 720px) {
  .dock { grid-template-columns: auto 1fr; grid-template-areas: "tools color" "palette palette" "status status"; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); gap: 8px 10px; }
  .tool span { display: none; }
  .tool kbd { display: none; }
  .color { justify-content: flex-end; }
  .palette { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .swatch { width: 30px; height: 30px; flex: none; }
  .recent-row { overflow-x: auto; }
  .recent { flex-wrap: nowrap; }
}

/* ---------- content pages ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 48px 20px 72px; }
.page.narrow > * { max-width: 680px; }
.page h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(40px, 7vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  max-width: 14ch;
}
.page h2 { font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1.15; margin: 44px 0 10px; }
.page .lead { font-size: 19px; color: var(--muted); max-width: 58ch; margin: 0 0 40px; }
.page p, .page li { max-width: 68ch; }
.page li { margin-bottom: 6px; }
.page ul, .page ol { padding-left: 20px; }
.page address { font-style: normal; }
.page .todo { background: rgba(201, 154, 46, 0.2); padding: 0 4px; }
.rules {
  background: var(--paper);
  color: var(--paper-ink);
  padding: 20px 24px;
  margin: 40px 0;
  max-width: 680px;
  border-radius: 1px;
}
.rules h2 { margin-top: 0; }
.rules ol { margin: 0; }
.foot {
  border-top: 1px solid var(--line);
  padding: 20px 16px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}
.foot nav { display: flex; gap: 16px; flex-wrap: wrap; }
.foot a { color: var(--muted); }

/* ---------- frames (lobby + gallery) ---------- */
.frame {
  display: block;
  padding: 0;
  border: 12px solid var(--frame);
  outline: 1px solid #6b521d;
  box-shadow: inset 0 0 0 2px #7d6125, 0 14px 28px rgba(0, 0, 0, 0.45);
  background: #f3eee3;
}
.frame img { display: block; width: 100%; height: auto; aspect-ratio: 1; image-rendering: pixelated; border: 3px solid #1a1712; }

/* entrance hall: boards grow with the lifetime of the painting */
.halls { display: grid; grid-template-columns: 2fr 3fr 4fr; gap: 40px; align-items: end; }
.hall-card { display: flex; flex-direction: column; gap: 18px; color: var(--ink); text-decoration: none; }
.hall-card .frame { transition: outline-color 140ms; }
.hall-card:hover .frame { outline-color: var(--brass); }
.hall-card:hover h2 { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.hall-info h2 { font-family: var(--serif); font-weight: 500; font-size: 30px; line-height: 1.05; margin: 0; }
.hall-info p { margin: 6px 0 0; color: var(--muted); }
.hall-info .hall-sub { color: var(--brass); font-family: var(--serif); font-style: italic; font-size: 17px; margin: 2px 0 0; }
.facts { list-style: none; padding: 0; margin: 14px 0 16px; font-size: 14px; }
.facts li { padding: 6px 0; border-top: 1px solid var(--line); max-width: none; margin: 0; font-variant-numeric: tabular-nums; }
.facts .countdown { color: var(--ink); }
.halls .empty { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .halls { grid-template-columns: 1fr; gap: 56px; }
  .hall-tag .frame { width: 55%; }
  .hall-monat .frame { width: 75%; }
}

/* gallery */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 40px 28px; }
.work { margin: 0; }
.work figcaption {
  margin: 16px 0 0;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 8px 12px;
  font-size: 13px;
  width: fit-content;
  max-width: 100%;
}
.work figcaption strong { display: block; font-family: var(--serif); font-weight: 500; font-size: 17px; }
.tabs { display: flex; flex-wrap: wrap; gap: 20px; margin: 0 0 32px; border-bottom: 1px solid var(--line); }
.tabs a { color: var(--muted); text-decoration: none; padding: 0 0 10px; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brass); }
.gallery-hall { margin-bottom: 56px; }
.gallery-hall > h2 { margin-top: 0; }
.empty { border: 1px dashed var(--line-strong); padding: 32px 20px; color: var(--muted); }
.empty p { margin: 0 0 12px; }

/* admin */
.form { display: grid; gap: 4px; max-width: 460px; margin-bottom: 40px; }
.form .row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.msg { min-height: 1.5em; color: var(--muted); }
