/* Graphite board, one warm "safelight" accent. */
:root {
  --ink: #101114; --board: #17181b; --raise: #26282d; --line: rgb(255 255 255 / .07);
  --fog: #8a8e97; --paper: #e8e6e1; --safe: #f2a65a; --safe-dim: rgb(242 166 90 / .13);
  --ease: cubic-bezier(.2, .8, .2, 1); --r: 10px; --bar: 38px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0 }
[hidden] { display: none !important }
html { height: 100%; background: transparent }
body {
  height: 100%; overflow: hidden; display: flex; flex-direction: column;
  background: var(--board); border-radius: var(--r);
  color: var(--paper); font: 12px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  user-select: none; -webkit-font-smoothing: antialiased;
}
body::after { content: ''; position: fixed; inset: 0; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line); pointer-events: none; z-index: 60 }
body.clear { background: transparent }
body.clear::after { display: none }
svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round }

/* ---- title bar ---- */
#bar {
  flex: none; height: var(--bar); position: relative; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 6px;
  background: var(--ink); border-bottom: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0;
  -webkit-app-region: drag;
}
body.clear #bar { border-radius: var(--r); border: 1px solid var(--line) }
#bar button, #bar select, #bar a { -webkit-app-region: no-drag }
.side { display: flex; align-items: center; gap: 2px; min-width: 0 }
.side.r { justify-content: flex-end }
.title { padding: 0 8px; color: var(--fog); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.side .ic { flex: none }
body.dirty [data-cmd=save] { color: var(--safe) }

button, .ic {
  font: inherit; color: var(--fog); background: none; border: 0; border-radius: 7px;
  height: 28px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color .15s, color .15s, transform .12s var(--ease);
}
button:hover, .ic:hover { color: var(--paper); background: rgb(255 255 255 / .06) }
button:active { transform: scale(.96) }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--safe); outline-offset: 1px }
.ic { width: 28px; padding: 0 }
.ic[aria-pressed=true] { color: var(--safe) }
.kofi:hover { color: #ff5e5b }

.seg { position: relative; display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgb(0 0 0 / .3); box-shadow: inset 0 0 0 1px var(--line) }
.seg button { position: relative; z-index: 1; height: 26px; padding: 0 11px }
.seg button:hover { background: none }
.seg button[aria-pressed=true] { color: var(--paper) }
.thumb { position: absolute; top: 3px; left: 0; height: 26px; border-radius: 7px; background: var(--raise); box-shadow: 0 1px 3px rgb(0 0 0 / .45), inset 0 0 0 1px rgb(255 255 255 / .06); transition: transform .24s var(--ease), width .24s var(--ease) }

.winctl { display: flex; align-items: center; gap: 2px }
body.mac #wctl, body:not(.mac) #lights { display: none }
#lights { gap: 8px; padding: 0 6px 0 8px }
#lights button { width: 12px; height: 12px; padding: 0; border-radius: 50%; background: #ff5f57; color: transparent }
#lights button[data-cmd=min] { background: #febc2e }
#lights:hover button { color: rgb(0 0 0 / .6) }
#lights svg { width: 8px; height: 8px; stroke-width: 2 }
#wctl [data-cmd=close]:hover { background: #e5484d; color: #fff }

@media (max-width: 560px) { .seg button span, .title, .kofi { display: none } .seg button { padding: 0 9px } }

/* ---- board ---- */
#stage { position: relative; flex: 1; overflow: hidden; background-image: radial-gradient(circle, rgb(255 255 255 / .035) .8px, transparent 1.2px) }
body.clear #stage { background-image: none }
#stage.panning { cursor: grabbing }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0 }
.item { position: absolute; left: 0; top: 0; display: block; box-shadow: 0 calc(2px / var(--z)) calc(12px / var(--z)) rgb(0 0 0 / .35) }
.item:hover { outline: calc(1px / var(--z)) solid rgb(255 255 255 / .22) }
.item.sel { outline: calc(1.5px / var(--z)) solid var(--safe); outline-offset: calc(2px / var(--z)) }
.item.lift { box-shadow: 0 calc(12px / var(--z)) calc(36px / var(--z)) rgb(0 0 0 / .55) }
#world.anim, #world.anim .item { transition: transform .34s var(--ease), width .34s var(--ease), height .34s var(--ease) }
#world.anim .item.lift { transition: none }
#handle { position: absolute; left: 0; top: 0; width: 12px; height: 12px; z-index: 2147483647; transform-origin: 0 0; border-radius: 3px; background: var(--paper); box-shadow: 0 0 0 1.5px var(--safe), 0 2px 8px rgb(0 0 0 / .5); cursor: nwse-resize }
#box { position: absolute; display: none; border: 1px solid var(--safe); border-radius: 2px; background: var(--safe-dim); pointer-events: none }

.chip { position: absolute; padding: 5px 9px; border-radius: 7px; background: rgb(16 17 20 / .82); backdrop-filter: blur(10px); box-shadow: 0 0 0 1px var(--line); color: var(--fog); font: 11px var(--mono); font-variant-numeric: tabular-nums; pointer-events: none; opacity: 0; transition: opacity .35s, transform .35s var(--ease) }
.chip.show { opacity: 1; transition-duration: .12s }
#zoom { left: 12px; bottom: 12px }
#toast { position: fixed; left: 50%; bottom: 18px; z-index: 50; color: var(--paper); font: 12px system-ui, sans-serif; padding: 8px 12px; transform: translate(-50%, 6px) }
#toast.show { transform: translate(-50%, 0) }

/* crop marks, shared by the empty state and the drop overlay */
.cm { position: absolute; width: 18px; height: 18px; border: 0 solid currentColor }
.tl { top: var(--o); left: var(--o); border-width: 1.5px 0 0 1.5px }
.tr { top: var(--o); right: var(--o); border-width: 1.5px 1.5px 0 0 }
.bl { bottom: var(--o); left: var(--o); border-width: 0 0 1.5px 1.5px }
.br { bottom: var(--o); right: var(--o); border-width: 0 1.5px 1.5px 0 }

#empty { position: absolute; inset: 0; display: none; place-items: center; pointer-events: none; transition: opacity .2s }
body.empty #empty { display: grid }
body.dropping #empty { opacity: 0 }
.frame { --o: 0px; position: relative; display: grid; justify-items: center; gap: 8px; padding: 40px 52px; text-align: center; color: rgb(138 142 151 / .5); pointer-events: auto }
.frame > svg { width: 40px; height: 40px; stroke-width: 1.2; color: var(--fog); margin-bottom: 6px }
.frame h1 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--paper) }
.frame p { max-width: 250px; line-height: 1.5; color: var(--fog) }
.acts { display: flex; gap: 6px; margin-top: 10px }
.pri { background: var(--paper); color: var(--ink); font-weight: 500 }
.pri:hover { background: #fff; color: var(--ink) }
.ghost { color: var(--paper); box-shadow: inset 0 0 0 1px var(--line) }
.hint { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: var(--fog); opacity: .55; font-size: 11px }

#drop {
  --o: 14px; position: fixed; inset: var(--bar) 0 0; z-index: 30; display: grid; place-items: center;
  color: var(--safe); pointer-events: none; opacity: 0; transition: opacity .16s;
  background: radial-gradient(ellipse at center, var(--safe-dim), transparent 72%);
}
body.clear #drop { background: radial-gradient(ellipse at center, rgb(242 166 90 / .2), rgb(16 17 20 / .55) 75%) }
body.dropping #drop { opacity: 1 }
#drop .cm { width: 28px; height: 28px; transition: transform .28s var(--ease) }
#drop .tl { transform: translate(-8px, -8px) } #drop .tr { transform: translate(8px, -8px) }
#drop .bl { transform: translate(-8px, 8px) } #drop .br { transform: translate(8px, 8px) }
body.dropping #drop .cm { transform: none }
.msg { display: grid; justify-items: center; gap: 10px; color: var(--paper); font-size: 14px; font-weight: 600; transform: translateY(4px) scale(.98); transition: transform .28s var(--ease) }
.msg b { font-weight: 600 }
.msg svg { width: 30px; height: 30px; color: var(--safe) }
body.dropping .msg { transform: none }

/* ---- slideshow ---- */
#slide { display: none; position: relative; flex: 1; overflow: hidden }
body[data-mode=slides] #stage { display: none }
body[data-mode=slides] #slide { display: block }
body.idle #slide { cursor: none }
#slide > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none }
.zone { position: absolute; top: 0; bottom: 0; width: 50%; display: flex; align-items: center; padding: 0 14px; color: #fff; opacity: 0; transition: opacity .2s }
.zone.l { left: 0 }
.zone.r { right: 0; justify-content: flex-end }
.zone:hover { opacity: .85 }
body.idle .zone { opacity: 0 }
.zone svg { width: 30px; height: 30px; stroke-width: 1.6; filter: drop-shadow(0 1px 4px rgb(0 0 0 / .6)) }

#hud {
  position: absolute; left: 50%; bottom: 18px; z-index: 2; display: flex; align-items: center; gap: 2px; padding: 4px;
  border-radius: 12px; background: rgb(16 17 20 / .8); backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 0 0 1px var(--line), 0 10px 30px rgb(0 0 0 / .45);
  transform: translateX(-50%); transition: opacity .3s, transform .3s var(--ease);
}
body.idle #hud { opacity: 0; transform: translate(-50%, 8px); pointer-events: none }
#hud .ic { color: var(--paper) }
#hud .ic[aria-pressed=true] { color: var(--safe) }
#play .i-pause, body.running #play .i-play { display: none }
body.running #play .i-pause { display: block }
#count { padding: 0 8px; color: var(--fog); font: 11px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap }
.sep { width: 1px; height: 16px; margin: 0 4px; background: var(--line) }
select {
  appearance: none; font: inherit; color: var(--paper); height: 28px; padding: 0 24px 0 10px; border: 0; border-radius: 7px;
  background: rgb(255 255 255 / .06) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m5 6.5 3 3 3-3' fill='none' stroke='%238a8e97' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 6px center / 14px;
}
select:hover { background-color: rgb(255 255 255 / .1) }
#time { top: 12px; right: 12px; font-size: 13px; color: var(--paper) }
body.auto #time { opacity: 1 }
#time.soon { color: var(--safe) }
#timer { display: none; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgb(255 255 255 / .06) }
body.auto #timer { display: block }
#timer i { display: block; height: 100%; background: var(--safe); transform-origin: 0 0 }
body.auto:not(.running) #timer i { background: var(--fog) }

#grip { position: fixed; right: 3px; bottom: 3px; width: 14px; height: 14px; z-index: 40; cursor: nwse-resize; opacity: .3; transition: opacity .2s; background: linear-gradient(135deg, transparent 50%, var(--fog) 50% 57%, transparent 57% 71%, var(--fog) 71% 78%, transparent 78%) }
#grip:hover { opacity: .9 }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important } }
