:root {
  --bg: #f5f3ee;
  --surface: #fffdf8;
  --fg: #1d1b18;
  --muted: #6d675e;
  --faint: #a39c91;
  --line: #e2ddd3;
  --accent: #8a6a2f;
  --tile: #e8e3d9;
  --overlay: rgba(20, 18, 16, 0.92);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1b1a18;
    --fg: #ece8e1;
    --muted: #a19a8f;
    --faint: #6e685f;
    --line: #2c2a27;
    --accent: #d6b268;
    --tile: #23211e;
    --overlay: rgba(8, 7, 6, 0.96);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--sans);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

/* Bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.mark { font: 600 20px/1 var(--serif); text-decoration: none; letter-spacing: -0.01em; }
.search { flex: 1; max-width: 640px; display: flex; gap: 8px; }
.search select {
  appearance: none; -webkit-appearance: none; flex: none;
  padding: 0 30px 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  cursor: pointer;
}
.search input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.logout { margin-left: auto; color: var(--muted); text-decoration: none; font-size: 14px; }
.logout:hover { color: var(--fg); }

/* Filters */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 0 24px 14px;
}
.filters select, .years input {
  appearance: none; -webkit-appearance: none;
  height: 34px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  cursor: pointer;
}
.filters select.on { border-color: var(--accent); color: var(--accent); }
.years { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); }
.years input { width: 78px; padding: 0 12px; background-image: none; cursor: text; -moz-appearance: textfield; }
.years input::-webkit-inner-spin-button { display: none; }
.years input:not(:placeholder-shown) { border-color: var(--accent); color: var(--accent); }
.swatches { display: inline-flex; gap: 4px; padding: 0 4px; }
.swatch {
  width: 22px; height: 22px; padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  cursor: pointer;
}
.swatch[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip {
  height: 34px; padding: 0 14px;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--surface); color: var(--accent); cursor: pointer;
}
.link {
  border: 0; background: none; padding: 0 6px;
  color: var(--accent); cursor: pointer;
}

/* Grid (justified rows; sizes set in app.js) */
main { padding: 0 24px 64px; }
.grid { display: flex; flex-wrap: wrap; gap: 6px; }
.tile {
  position: relative; display: block; flex: none;
  overflow: hidden; border-radius: 3px;
  background: var(--tile);
  text-decoration: none;
}
.tile img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.25s ease;
}
.tile img.loaded { opacity: 1; }
.tile figcaption {
  position: absolute; inset: auto 0 0 0;
  padding: 28px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  color: #fff; font-size: 13px; line-height: 1.3;
  opacity: 0; transition: opacity 0.15s ease;
}
.tile figcaption b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile figcaption span { opacity: 0.8; }
.tile:hover figcaption, .tile:focus-visible figcaption { opacity: 1; }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: none) { .tile figcaption { display: none; } }

.state { color: var(--muted); text-align: center; padding: 64px 0; }
#more { height: 1px; }

/* Detail */
.detail {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--fg);
}
.detail::backdrop { background: var(--overlay); }
.detail[open] { display: grid; grid-template-columns: minmax(0, 1fr) 420px; }
.stage {
  position: relative; display: grid; place-items: center;
  height: 100dvh; padding: 32px;
  background: #0d0c0b;
}
.stage img { max-width: 100%; max-height: calc(100dvh - 64px); object-fit: contain; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5); }
.info { height: 100dvh; overflow-y: auto; padding: 24px 28px 48px; border-left: 1px solid var(--line); }
.info-top { display: flex; justify-content: flex-end; gap: 4px; margin-bottom: 16px; }
.icon {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--muted);
  text-decoration: none; font-size: 18px; line-height: 1;
}
.icon:hover { background: var(--tile); color: var(--fg); }
.info h1 { font: 600 26px/1.2 var(--serif); margin: 0 0 6px; letter-spacing: -0.01em; }
.artist { color: var(--muted); margin: 0 0 20px; }
.artist a { text-decoration: none; }
.artist a:hover { color: var(--accent); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 22px; font-size: 14px; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; }
.facts a { text-decoration: none; }
.facts a:hover { color: var(--accent); }
.about { margin: 0 0 16px; }
.fact { margin: 0 0 22px; padding-left: 12px; border-left: 2px solid var(--accent); color: var(--muted); font-size: 14px; }
.palette { display: flex; gap: 6px; margin: 0 0 22px; }
.palette button { height: 28px; flex: 1; border: 0; border-radius: 4px; cursor: pointer; }
.palette button:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.actions { display: flex; gap: 16px; margin: 0 0 32px; font-size: 14px; }
.actions a { color: var(--accent); text-decoration: none; }
.actions a:hover { text-decoration: underline; }
.feel, .lessons { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.feel li { color: var(--muted); }
.feel a { color: var(--fg); text-decoration: none; font-family: var(--serif); font-size: 16px; }
.feel a:hover { color: var(--accent); }
.lessons li { padding-left: 12px; border-left: 2px solid var(--line); }
.form { margin-top: 24px; font-size: 14px; }
.form summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.form .facts { margin: 10px 0 0; }
.info h2 { font: 600 13px/1 var(--sans); color: var(--muted); margin: 28px 0 10px; }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mini a { aspect-ratio: 1; border-radius: 3px; overflow: hidden; background: var(--tile); }
.mini img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; }
.login-form { width: min(320px, calc(100vw - 32px)); display: grid; gap: 12px; }
.login-form h1 { font: 600 28px/1 var(--serif); margin: 0 0 8px; text-align: center; }
.login-form input, .login-form button {
  height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.login-form button { background: var(--fg); color: var(--bg); border: 0; font-weight: 600; cursor: pointer; }
.login-error { margin: 0; color: #c0392b; font-size: 14px; }

@media (max-width: 860px) {
  .detail[open] { display: block; overflow-y: auto; }
  .stage { height: auto; min-height: 50dvh; padding: 16px; }
  .stage img { max-height: 70dvh; }
  .info { height: auto; overflow: visible; border-left: 0; padding: 20px 16px 48px; }
}
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: 10px 14px; padding: 12px 16px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .filters { padding: 0 16px 12px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters > * { flex: none; }
  main { padding: 0 16px 48px; }
}
