/* Moodroom: soft paper-cut night, one warm light. System fonts only. */
:root {
  --accent: #ffb86b;
  --ink: #f7ecd9;
  --muted: rgba(247, 236, 217, .7);
  --faint: rgba(247, 236, 217, .45);
  --panel: rgba(15, 12, 24, .72);
  --panel-solid: #14111c;
  --line: rgba(255, 238, 214, .16);
  --deep: #0b0d1c;
  --display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --ui: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--deep); color: var(--ink); font-family: var(--ui); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { overflow: hidden; position: fixed; inset: 0; width: 100%; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
.defs { position: absolute; width: 0; height: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
kbd { font-family: var(--mono); font-size: .78em; padding: .1em .45em; border: 1px solid var(--line); border-radius: 6px; background: rgba(255, 255, 255, .06); }

/* Visible focus everywhere */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 12px; }

/* The picture and the layers over it */
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: #05060f; }
#grain { position: fixed; inset: -20%; pointer-events: none; opacity: .09; mix-blend-mode: overlay; background-size: 180px 180px; animation: grain 1.1s steps(6) infinite; }
@keyframes grain { 0% { transform: translate(0, 0); } 17% { transform: translate(-3%, 2%); } 33% { transform: translate(2%, -3%); } 50% { transform: translate(-2%, -1%); } 67% { transform: translate(3%, 3%); } 83% { transform: translate(-1%, 2%); } 100% { transform: translate(0, 0); } }
#fade { position: fixed; inset: 0; background: #04050c; opacity: 0; pointer-events: none; transition: opacity .28s ease; }
#fade.on { opacity: 1; }
#pulse { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at 50% 100%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 62%), radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 55%); }
#pulse.on { animation: pulse 7s ease-in-out 1; }
@keyframes pulse { 0% { opacity: 0; } 18% { opacity: .85; } 36% { opacity: .2; } 54% { opacity: .75; } 100% { opacity: 0; } }

/* ---------- Gallery ---------- */
#gallery { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr auto; padding: calc(22px + var(--safe-t)) clamp(18px, 4vw, 56px) calc(20px + var(--safe-b)); gap: 12px; z-index: 5; background: linear-gradient(to top, rgba(5, 5, 14, .86) 0%, rgba(5, 5, 14, .5) 34%, rgba(5, 5, 14, 0) 62%), linear-gradient(to bottom, rgba(5, 5, 14, .5) 0%, rgba(5, 5, 14, 0) 24%); transition: opacity .7s ease, visibility .7s; overflow-y: auto; overscroll-behavior: contain; }
body:not(.is-gallery) #gallery { opacity: 0; visibility: hidden; pointer-events: none; }
.g-head { display: flex; flex-direction: column; gap: 4px; }
.g-head h1 { margin: 0; line-height: 0; color: var(--ink); filter: drop-shadow(0 2px 12px rgba(0, 0, 0, .55)); }
.wordmark { width: clamp(190px, 26vw, 280px); height: auto; overflow: visible; }
.wordmark .lit { fill: var(--accent); stroke: var(--accent); }
.g-tag { margin: 6px 0 0 2px; font-family: var(--display); font-style: italic; font-size: 17px; color: var(--muted); text-shadow: 0 1px 10px rgba(0, 0, 0, .7); }
.g-pick { align-self: end; max-width: 560px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.g-count { margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; text-shadow: 0 1px 8px rgba(0, 0, 0, .8); }
.g-name { margin: 0; font-family: var(--display); font-weight: 500; font-size: clamp(32px, 5.4vw, 54px); line-height: 1.04; letter-spacing: -.01em; text-shadow: 0 2px 22px rgba(0, 0, 0, .75); }
.g-line { margin: 2px 0 10px; font-size: clamp(15px, 1.6vw, 18px); line-height: 1.45; color: var(--muted); max-width: 44ch; text-shadow: 0 1px 12px rgba(0, 0, 0, .85); }
.enter { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 60px; padding: 10px 30px 10px 26px; border-radius: 999px; background: var(--accent); color: #1b1108; box-shadow: 0 10px 34px color-mix(in srgb, var(--accent) 45%, transparent), 0 1px 0 rgba(255, 255, 255, .5) inset; transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.enter-main { font-weight: 700; font-size: 20px; letter-spacing: .005em; }
.enter-sub { font-size: 12px; opacity: .72; }
@media (hover: hover) { .enter:hover { transform: translateY(-2px); box-shadow: 0 14px 40px color-mix(in srgb, var(--accent) 55%, transparent), 0 1px 0 rgba(255, 255, 255, .5) inset; } }
.enter:active { transform: scale(.98); }
.enter:focus-visible { outline-color: var(--ink); }
.g-note { margin: 10px 0 0; font-size: 12.5px; color: var(--faint); max-width: 44ch; text-shadow: 0 1px 8px rgba(0, 0, 0, .9); }
.g-rooms { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cards { list-style: none; margin: 0; padding: 4px 2px 6px; display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.cards::-webkit-scrollbar { display: none; }
.cards li { flex: 0 0 auto; scroll-snap-align: start; }
.card { position: relative; display: block; width: clamp(128px, 11.2vw, 168px); text-align: left; border-radius: 16px; overflow: hidden; background: #0c0e1c; border: 1px solid var(--line); box-shadow: 0 8px 22px rgba(0, 0, 0, .45); transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.card canvas { display: block; width: 100%; aspect-ratio: 16 / 10; background: #0c0e1c; }
.card .c-n { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; display: grid; place-items: center; font-size: 12px; font-weight: 700; border-radius: 50%; background: rgba(8, 8, 18, .7); color: var(--ink); backdrop-filter: blur(6px); }
.card .c-t { display: block; padding: 8px 11px 10px; font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 12px 30px rgba(0, 0, 0, .55); transform: translateY(-4px); }
.card[aria-pressed="true"] .c-n { background: var(--accent); color: #1b1108; }
@media (hover: hover) { .card:hover { transform: translateY(-3px); } }
.keys { margin: 0; font-size: 12.5px; color: var(--faint); text-shadow: 0 1px 8px rgba(0, 0, 0, .9); }
@media (min-width: 1000px) {
  #gallery { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 1fr; column-gap: 40px; }
  .g-head { grid-column: 1 / 3; }
  .g-pick { grid-row: 2; grid-column: 1; }
  .g-rooms { grid-row: 2; grid-column: 2; align-self: end; max-width: min(62vw, 860px); }
}
@media (max-height: 560px) and (orientation: landscape) {
  #gallery { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 6px 22px; padding-top: 12px; padding-bottom: 12px; }
  .g-head { grid-column: 1 / 3; flex-direction: row; align-items: baseline; gap: 14px; }
  .g-tag { margin: 0; font-size: 14px; }
  .wordmark { width: 150px; }
  .g-pick { grid-row: 2; grid-column: 1; }
  .g-rooms { grid-row: 2; grid-column: 2; align-self: end; }
  .g-name { font-size: 28px; } .g-line { font-size: 14px; margin-bottom: 6px; } .g-note, .keys { display: none; }
  .enter { min-height: 48px; padding: 6px 22px; } .enter-main { font-size: 17px; } .enter-sub { display: none; }
  .card { width: 108px; } .card .c-t { font-size: 12px; padding: 5px 8px 7px; }
}
@media (max-width: 560px) {
  .g-tag { font-size: 15px; }
  .card { width: 138px; }
  .keys { display: none; }
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-fade { transition: opacity .8s ease, transform .8s var(--ease); }
body.idle .hud-fade, body.idle .dock-chip { opacity: 0; }
body.idle .hud-fade { pointer-events: none; }
body.idle { cursor: none; }
.dock:focus-within .hud-fade, .top:focus-within { opacity: 1 !important; pointer-events: auto !important; }
.top { position: absolute; top: calc(14px + var(--safe-t)); left: clamp(12px, 3vw, 28px); right: clamp(12px, 3vw, 28px); display: flex; align-items: center; gap: 12px; pointer-events: none !important; }
.top > * { pointer-events: auto; }
.icon-btn { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: transform .25s var(--ease), background .25s; flex: none; }
.icon-btn .ico { width: 26px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .icon-btn:hover { transform: scale(1.06); background: rgba(30, 24, 44, .8); } }
.who { min-width: 0; text-shadow: 0 1px 14px rgba(0, 0, 0, .8); }
.who-name { margin: 0; font-family: var(--display); font-size: 19px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-line { margin: 1px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .who-line { display: none; } }

.dock { position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: clamp(2px, 1.2vw, 10px); padding: 8px clamp(6px, 1.6vw, 14px) 8px; max-width: calc(100vw - 16px); pointer-events: none !important; }
.dock > * { pointer-events: auto; }
.dock::before { content: ""; position: absolute; inset: 0; border-radius: 28px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 14px 40px rgba(0, 0, 0, .45); transition: opacity .8s ease; pointer-events: none; }
body.idle .dock::before { opacity: 0; }
.dk { position: relative; min-width: 58px; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 4px; border-radius: 18px; transition: background .2s, transform .25s var(--ease); }
.dk .ico { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: stroke .2s; }
.dk .ico .knob { fill: var(--panel-solid); }
.dk-l { font-size: 11.5px; color: var(--muted); letter-spacing: .01em; white-space: nowrap; }
@media (hover: hover) { .dk:hover { background: rgba(255, 255, 255, .08); } }
.dk[aria-expanded="true"] { background: rgba(255, 255, 255, .12); }
.dk[aria-pressed="true"] .ico, .dk[aria-expanded="true"] .ico { stroke: var(--accent); }
body.sleeping-on #b-sleep .ico { stroke: var(--accent); }
.ring { margin: 0 2px; }
.ring-svg { position: absolute; top: 4px; left: 50%; width: 42px; height: 42px; transform: translateX(-50%); overflow: visible; }
.ring-bg { fill: rgba(20, 16, 30, .5); stroke: rgba(255, 238, 214, .18); stroke-width: 3; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 3.6; stroke-linecap: round; stroke-dasharray: 144.5; stroke-dashoffset: 144.5; transition: stroke-dashoffset .9s linear, stroke .6s; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 70%, transparent)); }
body.break .ring-fg { stroke: #9fe0c4; filter: drop-shadow(0 0 4px rgba(159, 224, 196, .7)); }
.ring-ico { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; margin-top: 4px; }
.ring-ico .solid { fill: var(--ink); stroke: var(--ink); stroke-linejoin: round; }
.ring-ico .thick { stroke-width: 3; }
.ring-l { font-variant-numeric: tabular-nums; }
body.idle.timer-on #b-timer { opacity: .6; }
body:not(.timer-on) .ring-fg { stroke-dashoffset: 144.5; }
body.idle:not(.timer-on) #b-timer { opacity: 0; pointer-events: none; }
body.idle #b-timer .ring-l { opacity: 0; }
#b-timer { transition: opacity .8s ease, background .2s; }
@media (max-width: 400px) { .dk { min-width: 48px; } .dock { gap: 0; } }

/* ---------- Panels ---------- */
.panel { position: absolute; left: 50%; bottom: calc(104px + var(--safe-b)); transform: translateX(-50%); width: min(94vw, 390px); max-height: calc(100dvh - 180px - var(--safe-b)); overflow-y: auto; padding: 18px 18px 16px; border-radius: 24px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2); box-shadow: 0 24px 60px rgba(0, 0, 0, .55); animation: rise .28s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.panel h3 { margin: 0 0 10px; font-family: var(--display); font-weight: 500; font-size: 19px; }
.panel hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.hint { margin: 12px 0 0; font-size: 12.5px; color: var(--faint); line-height: 1.45; }
.t-state { margin: -4px 0 12px; font-size: 14px; color: var(--muted); min-height: 1.4em; font-variant-numeric: tabular-nums; }
.chips { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.chips.rooms { grid-template-columns: 1fr 1fr; }
.rooms .rb { width: 100%; min-height: 52px; display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); font-size: 14px; line-height: 1.2; transition: background .2s, border-color .2s; }
.rooms .rb .n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: rgba(255, 255, 255, .1); }
.rooms .rb[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.rooms .rb[aria-pressed="true"] .n { background: var(--accent); color: #1b1108; }
@media (hover: hover) { .rooms .rb:hover { background: rgba(255, 255, 255, .09); } }
.rooms li:last-child:nth-child(odd) { grid-column: 1 / 3; }

.slider { display: block; margin-bottom: 4px; }
.sl-top { display: flex; justify-content: space-between; font-size: 14px; }
.sl-top output { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; cursor: pointer; --v: 50%; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--accent) var(--v), rgba(255, 255, 255, .16) var(--v)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .16); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); margin-top: -9px; box-shadow: 0 2px 10px rgba(0, 0, 0, .5), 0 0 0 4px color-mix(in srgb, var(--accent) 28%, transparent); border: 0; }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--ink); border: 0; box-shadow: 0 2px 10px rgba(0, 0, 0, .5), 0 0 0 4px color-mix(in srgb, var(--accent) 28%, transparent); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--panel-solid), 0 0 0 6px var(--accent); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--panel-solid), 0 0 0 6px var(--accent); }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 14px; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 44px; height: 44px; margin: 0; cursor: pointer; }
.check .box { flex: none; width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--faint); position: relative; transition: background .2s, border-color .2s; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .box::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid #1b1108; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.check input:focus-visible + .box { outline: 3px solid var(--accent); outline-offset: 3px; }
.check em { display: block; font-style: normal; font-size: 12px; color: var(--faint); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 16px; background: rgba(255, 255, 255, .06); }
.seg-b { min-height: 44px; border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s; }
.seg-b[aria-pressed="true"] { background: var(--accent); color: #1b1108; }
.custom { display: grid; gap: 4px; margin-top: 10px; }
.step { display: grid; grid-template-columns: 1fr 44px 84px 44px; align-items: center; gap: 4px; font-size: 14px; }
.step-b { width: 44px; height: 44px; border-radius: 50%; font-size: 22px; line-height: 1; background: rgba(255, 255, 255, .08); }
@media (hover: hover) { .step-b:hover { background: rgba(255, 255, 255, .16); } }
.step output { text-align: center; font-variant-numeric: tabular-nums; }
.t-actions { display: flex; gap: 10px; margin-top: 14px; }
.primary, .ghost { min-height: 48px; border-radius: 999px; font-weight: 700; font-size: 15px; padding: 0 22px; transition: transform .2s var(--ease), background .2s; }
.primary { flex: 1; background: var(--accent); color: #1b1108; }
.ghost { background: rgba(255, 255, 255, .09); }
@media (hover: hover) { .primary:hover { transform: translateY(-1px); } .ghost:hover { background: rgba(255, 255, 255, .16); } }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); font-size: 14px; font-weight: 600; transition: background .2s, border-color .2s; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #1b1108; }
@media (hover: hover) { .chip:hover:not([aria-pressed="true"]) { background: rgba(255, 255, 255, .12); } }

/* ---------- The dark ---------- */
#dark { position: fixed; inset: 0; z-index: 20; background: #000; display: grid; place-content: center; text-align: center; gap: 8px; opacity: 0; visibility: hidden; transition: opacity 3s ease, visibility 3s; cursor: pointer; }
#dark.on { opacity: 1; visibility: visible; }
.dark-a { margin: 0; font-family: var(--display); font-style: italic; font-size: 22px; color: rgba(247, 236, 217, .28); }
.dark-b { margin: 0; font-size: 13px; color: rgba(247, 236, 217, .16); }
.noscript { position: fixed; inset: auto 16px 16px; padding: 14px; background: var(--panel-solid); border-radius: 12px; z-index: 50; }

/* ---------- Calm / reduced motion ---------- */
body.calm #grain, .calm-os #grain { animation: none; }
body.calm .panel { animation: none; }
body.calm #pulse.on { animation: pulse-calm 7s ease-in-out 1; }
@keyframes pulse-calm { 0%, 100% { opacity: 0; } 40%, 60% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
  .panel { animation: none; }
  .hud-fade, .card, .enter, .dk, .icon-btn, .primary, .ring-fg, #gallery { transition-duration: .01s; }
  #pulse.on { animation: pulse-calm 7s ease-in-out 1; }
}
