:root {
  --bg0: #0c0907;
  --bg1: #2a1f18;
  --ink: #f3e9dc;
  --ink2: #c7b6a3;
  --ink3: #8f7f6e;
  --card: rgba(24, 18, 14, 0.86);
  --line: rgba(243, 233, 220, 0.12);
  --accent: #d9a35f;
  --accent-ink: #1a120c;
  --panel-w: 304px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 90% at 42% 38%, var(--bg1) 0%, #17110d 48%, var(--bg0) 100%);
  background-color: var(--bg0);
  color: var(--ink);
  font: 14px/1.4 ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#stage { position: fixed; inset: 0; }
#c { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#c.pointer { cursor: pointer; }

#brand { position: fixed; left: 24px; top: 20px; pointer-events: none; }
#brand h1 {
  margin: 0; font: 500 26px/1.1 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  letter-spacing: 0.01em; color: var(--ink);
}
#brand p { margin: 4px 0 0; color: var(--ink3); font-size: 13px; letter-spacing: 0.04em; }

#panel {
  position: fixed; right: 20px; top: 20px; width: var(--panel-w);
  max-height: calc(100% - 40px); overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
  padding: 6px 18px 16px;
}
#sheetHandle { display: none; }
section { padding: 12px 0 6px; border-top: 1px solid var(--line); }
section:first-child, section[hidden]:first-child + section { border-top: 0; }
section[hidden] { display: none; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink2); }
.current { font-size: 13px; color: var(--ink); }

.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sw {
  appearance: none; border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink2);
  display: flex; flex-direction: column; align-items: center; gap: 5px; font: inherit; font-size: 11px;
}
.sw .chip {
  width: 40px; height: 40px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 2px 6px rgba(0,0,0,0.4);
  outline: 2px solid transparent; outline-offset: 3px; transition: outline-color .15s, transform .15s;
  background-size: cover;
}
.swatches.small { grid-template-columns: repeat(6, 1fr); }
.swatches.small .sw .chip { width: 28px; height: 28px; }
.sw:hover .chip { transform: scale(1.06); }
.sw[aria-checked="true"] { color: var(--ink); }
.sw[aria-checked="true"] .chip { outline-color: var(--accent); }
.sw:focus-visible { outline: none; }
.sw:focus-visible .chip { outline-color: #fff; }

.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.buttons button {
  appearance: none; font: inherit; font-size: 13px; color: var(--ink);
  background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 8px; cursor: pointer; transition: background .15s, border-color .15s;
  min-height: 38px;
}
.buttons button:hover { background: rgba(255,255,255,0.1); }
.buttons button[aria-pressed="true"] { border-color: var(--accent); background: rgba(217,163,95,0.16); }
.buttons button.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.buttons button.accent:hover { background: #e6b474; }
.buttons button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.hint { color: var(--ink3); font-size: 12px; margin: 12px 0 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: rgba(255,255,255,0.03); }
.seg button {
  appearance: none; font: inherit; font-size: 13px; color: var(--ink2); background: none; border: 0; border-radius: 7px;
  padding: 7px 8px; min-height: 34px; cursor: pointer; transition: background .15s, color .15s;
}
.seg button[aria-checked="true"] { background: rgba(217,163,95,0.2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.seg button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.seg button:disabled { opacity: 0.55; cursor: progress; }
#studyProg { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--ink3); }
#studyProg .bar { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,0.1); overflow: hidden; }
#studyProg .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
#studyProg.done { display: none; }
#studyProg.error span { color: #f0b8a0; }
#stage { transition: opacity .45s; }
#stage.fading { opacity: 0; }

#loader {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg0); color: var(--ink2); z-index: 10; transition: opacity .5s;
}
#loader.done { opacity: 0; pointer-events: none; }
#loader.error p { color: #f0b8a0; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.12); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
#loader.error .spin { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; }

.mseg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: rgba(255,255,255,0.03); }
.mseg button {
  appearance: none; font: inherit; font-size: 13px; color: var(--ink2); background: none; border: 0; border-radius: 7px;
  padding: 7px 8px; min-height: 34px; cursor: pointer; transition: background .15s, color .15s;
}
.mseg button[aria-checked="true"] { background: rgba(217,163,95,0.2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.mseg button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
#modelSwitch { position: fixed; left: 24px; top: 84px; width: 210px; background: var(--card); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 2; }
.buttons button[hidden] { display: none; }

/* Phone: bottom sheet */
@media (max-width: 819px) {
  #brand { left: 16px; top: 12px; }
  #brand h1 { font-size: 20px; }
  #brand p { font-size: 11px; }
  #panel {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 62%;
    border-radius: 16px 16px 0 0; border-left: 0; border-right: 0; border-bottom: 0;
    padding: 0 16px calc(12px + env(safe-area-inset-bottom));
  }
  #sheetHandle {
    display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%;
    appearance: none; background: none; border: 0; color: var(--ink2); font: inherit; font-size: 11px;
    letter-spacing: 0.12em; text-transform: uppercase; padding: 8px 0 4px; cursor: pointer;
  }
  .grip { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.25); }
  #panel.collapsed #panelBody { display: none; }
  section { padding: 8px 0 4px; }
  .row-head { margin-bottom: 6px; }
  .sw .chip { width: 34px; height: 34px; }
  .swatches.small .sw .chip { width: 24px; height: 24px; }
  .buttons { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .buttons button { font-size: 12px; padding: 7px 4px; min-height: 36px; }
  .buttons button[data-act="reset"] { display: none; }
  .hint { display: none; }
  .seg button { min-height: 32px; padding: 5px 6px; font-size: 12px; }
  #studyProg { margin-top: 6px; }
  /* phone: one compact scrolling row of model chips under the title, clear of the cabinet */
  #modelSwitch {
    left: 0; right: 0; top: 58px; width: auto; padding: 0 12px; border: 0; border-radius: 0; background: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%);
  }
  #modelSwitch::-webkit-scrollbar { display: none; }
  #sideSwatches { grid-template-columns: repeat(8, 1fr); gap: 2px; }
  #sideSwatches .sw { font-size: 9.5px; gap: 4px; }
  #sideSwatches .sw .chip { width: 30px; height: 30px; }
  #modelSwitch button {
    flex: 0 0 auto; white-space: nowrap; font-size: 12px; min-height: 30px; padding: 5px 11px; border-radius: 15px;
    border: 1px solid var(--line); background: var(--card); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  #modelSwitch button:last-child { margin-right: 12px; }
  .mseg button { min-height: 32px; padding: 5px 6px; font-size: 12px; }
}

/* ---------------------------------------------------------------- own artwork (model 2) */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.buttons.own-actions { grid-template-columns: 1fr 1fr; }
.own-actions #ownArtPick, .own-actions #ownArtShow[hidden] + #ownArtRemove { grid-column: 1 / -1; }
#ownArtFit { display: grid; gap: 6px; margin-top: 12px; }
#ownArtFit[hidden] { display: none; }
.rng { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--ink2); }
.rng input { width: 100%; accent-color: var(--accent); margin: 0; }
.own-note { color: var(--ink3); font-size: 11.5px; line-height: 1.45; margin: 10px 0 2px; }

/* ---------------------------------------------------------------- Hartnett Humidors mode (?brand=hartnett) */
@font-face { font-family: 'HH Serif'; src: url(fonts/cormorant.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'HH Sans'; src: url(fonts/jost.woff2) format('woff2'); font-weight: 300 600; font-display: swap; }
body.hh {
  --accent: #bfa06a; --accent-ink: #0a0908; --ink: #ece6da; --ink2: #c9c0b1; --ink3: #8d8577;
  --bg0: #0a0908; --bg1: #1d1915; --card: rgba(14, 12, 10, 0.88);
  font-family: 'HH Sans', ui-sans-serif, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
body.hh #modelSwitch { display: none; }
body.hh #brand .hh-mark { display: block; font: 500 10.5px/1 'HH Sans', sans-serif; letter-spacing: 0.32em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
body.hh #brand h1 { font: 400 44px/1 'HH Serif', Georgia, serif; letter-spacing: 0.01em; }
body.hh #brand p { font: 400 11px/1.3 'HH Sans', sans-serif; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink2); margin-top: 10px; }
body.hh h2 { font-family: 'HH Sans', sans-serif; font-weight: 500; letter-spacing: 0.18em; }
body.hh .buttons button.accent:hover { background: #cdb07c; }
#hhNav { position: fixed; left: 24px; top: 136px; z-index: 3; }
#hhNav[hidden], #hhEnq[hidden] { display: none; }
#hhNav a { color: var(--ink2); text-decoration: none; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; border-bottom: 1px solid rgba(191,160,106,0.55); padding-bottom: 5px; }
#hhNav a:hover, #hhNav a:focus-visible { color: var(--ink); border-bottom-color: var(--accent); outline: none; }
#hhEnq { padding-top: 14px; }
.hh-enq { display: block; text-align: center; background: var(--accent); color: var(--accent-ink); text-decoration: none; padding: 12px 10px; border-radius: 9px; font-weight: 500; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
.hh-enq:hover { background: #cdb07c; }
.hh-enq:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 819px) {
  body.hh #brand .hh-mark { font-size: 9.5px; margin-bottom: 7px; letter-spacing: 0.28em; }
  body.hh #brand h1 { font-size: 30px; }
  body.hh #brand p { font-size: 10px; margin-top: 6px; }
  #hhNav { left: auto; right: 16px; top: 14px; }
  #hhNav a { font-size: 10px; letter-spacing: 0.14em; }
  .buttons.own-actions { grid-template-columns: 1fr 1fr; }
  .own-note { font-size: 11px; margin-top: 8px; }
  #hhEnq { padding-top: 10px; }
}
