:root { color-scheme: dark; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #d6deee; background: #05080f; }
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
main { position: fixed; inset: 0; width: 100%; height: 100dvh; margin: 0; padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 4px; }
.online-bar { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 20px; font-size: 11px; color: #aab5cb; }
.online-dot { width: 6px; height: 6px; border-radius: 50%; background: #64748b; }
.online-bar:has([data-connected="true"]) .online-dot { background: #58dda2; box-shadow: 0 0 8px #58dda255; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
h1 { margin: 0; font-size: 15px; font-weight: 500; letter-spacing: -.3px; white-space: nowrap; }
.home-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: #929db3; font-size: 11px; text-decoration: none; white-space: nowrap; }
.home-link:hover { color: #ffc45a; }
.home-link:focus-visible { outline: 2px solid #ffc45a; outline-offset: 2px; border-radius: 3px; }
.scene { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
canvas { display: block; width: auto; height: 100%; max-width: 100%; object-fit: contain; background: #05080f; }
.controls { width: min(100%, 880px); min-width: 0; justify-self: center; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 16px; }
.timeline { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 11px; color: #929db3; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
input[type="range"] { flex: 1; min-width: 0; height: 32px; margin: 0; accent-color: #ffc45a; cursor: pointer; }
output { min-width: 98px; text-align: right; font-variant-numeric: tabular-nums; }
.buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
button { min-height: 44px; font: inherit; font-size: 11px; color: #d6deee; background: #0f121d; border: 1px solid #252d40; border-radius: 7px; padding: 8px 12px; cursor: pointer; }
button:hover { background: #1a2030; border-color: #626d83; }
button:focus-visible, input:focus-visible, .action-link:focus-visible { outline: 2px solid #ffc45a; outline-offset: 2px; }
#play { color: #ffc45a; border-color: #554323; }
.loop { display: flex; align-items: center; gap: 5px; min-height: 32px; font-size: 11px; white-space: nowrap; cursor: pointer; }
.loop input { margin: 0; accent-color: #ffc45a; }
.controls > .hint:not(#sound-hint) { display: none; }
#sound-hint, #status { grid-column: 1 / -1; margin: 0; font-size: 10px; line-height: 1.5; color: #828da4; text-align: center; }
#status { overflow-wrap: anywhere; }
#status:empty, #sound-hint:empty { display: none; }
.page-actions { display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.action-link { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 12px; border: 1px solid #252d40; border-radius: 7px; background: #0f121d; color: #d6deee; font-size: 11px; text-decoration: none; white-space: nowrap; }
.action-link:hover { background: #1a2030; border-color: #626d83; }
.label-short { display: none; }
.coffee-link { color: #ffc45a; border-color: #554323; }
.coffee-link:hover { background: #292114; border-color: #ffc45a; }
.coffee-dialog { width: min(400px, calc(100% - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 24px; overflow: auto; border: 1px solid #554323; border-radius: 20px; background: #0f121d; color: #d6deee; box-shadow: 0 24px 80px #0009; text-align: center; }
.coffee-dialog::backdrop { background: #02040bc9; backdrop-filter: blur(6px); }
.coffee-dialog h2 { margin: 0; padding: 0 28px; color: #ffc45a; font-size: 19px; line-height: 1.4; }
.coffee-dialog p { margin: 12px 0; font-size: 12px; line-height: 1.7; }
.coffee-close { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; font-size: 26px; }
.coffee-qr { display: block; width: min(100%, 280px); height: auto; max-height: 42dvh; margin: 16px auto; border-radius: 14px; overflow: hidden; }
.coffee-dialog .coffee-thanks { margin-bottom: 0; color: #aab5cb; font-size: 11px; }
@media (max-width: 700px) {
  header { gap: 8px; }
  .brand h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .label-full { display: none; }
  .label-short { display: inline; }
  .page-actions { gap: 6px; }
  .action-link { min-height: 44px; padding: 8px; }
  .controls { width: min(100%, 480px); grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .timeline { gap: 8px; font-size: 10px; }
  output { min-width: 88px; }
  button { padding: 8px 4px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .controls { width: min(100%, 880px); grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .controls button { padding: 8px; }
}

.tree-stage { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-width: 0; min-height: 0; }
.scene { position: relative; isolation: isolate; }
.tree-stage canvas { width: 100%; height: 100%; object-fit: contain; }
.music-panel { position: absolute; right: 0; bottom: 0; width: 280px; height: 280px; z-index: 1; isolation: isolate; }
.music-panel[hidden] { display: none; }
.youtube-audio { position: absolute; top: 0; left: 0; width: 200px; height: 200px; overflow: hidden; clip-path: inset(50%); opacity: 0; pointer-events: none; }
#youtube-player { width: 200px; height: 200px; border: 0; }
#music-status { grid-column: 1 / -1; margin: 0; color: #aab5cb; font-size: 10px; line-height: 1.5; text-align: center; }
#music-status:empty { display: none; }
.settings-dialog { width: min(420px, calc(100% - 24px)); max-height: calc(100dvh - 24px); margin: auto; padding: 24px; overflow: auto; border: 1px solid #554323; border-radius: 18px; background: #0f121d; color: #d6deee; box-shadow: 0 24px 80px #0009; }
.settings-dialog::backdrop { background: #02040bc9; backdrop-filter: blur(6px); }
.settings-dialog h2 { margin: 0 28px 20px 0; color: #ffc45a; font-size: 18px; }
.settings-dialog label { display: block; margin: 14px 0 6px; color: #aab5cb; font-size: 12px; }
.settings-dialog input { width: 100%; min-height: 44px; padding: 10px; border: 1px solid #34405a; border-radius: 7px; background: #05080f; color: #d6deee; font: inherit; font-size: 16px; }
.settings-hint, .form-message { margin: 10px 0; color: #aab5cb; font-size: 12px; line-height: 1.6; }
.form-message { color: #ffc45a; }
.form-message:empty { display: none; }
.settings-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.settings-buttons button:first-child { color: #ffc45a; border-color: #554323; }
@media (max-width: 700px) {
  .page-actions .action-link { width: 44px; padding: 8px 0; font-size: 16px; }
  .youtube-active .scene { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 4px; }
  .music-panel { position: relative; width: 160px; height: 160px; justify-self: center; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .youtube-active .scene { display: flex; }
  .music-panel { position: absolute; width: 220px; height: 220px; }
}

.music-panel::before { content: ""; position: absolute; inset: 8%; z-index: -1; border-radius: 50%; background: conic-gradient(from 200deg, #ff006c44, #4720ff44, #00e5ff33, #ff006c44); filter: blur(28px); opacity: calc(.5 + var(--music-beat, 0) * .5); }
#music-visualizer { width: 100%; height: 100%; max-width: none; background: transparent; }
#music-orb { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46%; height: 46%; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0; border: 1px solid #6de8f77a; border-radius: 50%; background: radial-gradient(ellipse at top left, #171369, transparent 70%), radial-gradient(ellipse at bottom left, #650d36, transparent 70%), linear-gradient(125deg, #080c23, #032d32); color: #fff; box-shadow: inset 0 0 24px #0006, 0 0 18px #11c9ff15; cursor: pointer; }
#music-orb:hover { border-color: #f8cfff; box-shadow: 0 0 24px #9b55ff44; }
.is-loading #music-orb::after { content: ""; position: absolute; inset: -6px; border: 2px solid #48d9ff22; border-top-color: #67e8f9; border-right-color: #ed72e9; border-radius: 50%; pointer-events: none; animation: music-loading-spin 1s linear infinite; }
.is-loading .music-orb-caption { color: #a5f3fc; }
@keyframes music-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .is-loading #music-orb::after { animation: none; } }
.music-orb-title { font-family: "Arial Narrow", "Helvetica Neue", sans-serif; font-size: 48px; font-weight: 200; line-height: 1; letter-spacing: -2px; transform: scaleX(.72); }
.music-orb-caption { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
@media (max-width: 700px) { .music-orb-title { font-size: 28px; letter-spacing: -1px; } .music-orb-caption { font-size: 7px; letter-spacing: .7px; } }
@media (prefers-reduced-motion: reduce) { .music-panel::before { opacity: .5; } }

/* Keep music editing directly in the header, with Enter to play. */
.music-inline { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 480px; }
.music-inline[hidden] { display: none; }
.music-input-icon { color: #ffc45a; font-size: 18px; }
.music-inline input { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid #252d40; border-radius: 7px; background: #0f121d; color: #d6deee; font: inherit; font-size: 12px; }
.music-inline button { flex-shrink: 0; min-width: 44px; }
.music-inline button[type="submit"] { color: #ffc45a; border-color: #554323; }
#music-error { grid-column: 1 / -1; margin: 0; text-align: center; font-size: 11px; }
@media (max-width: 1000px) {
  header { flex-wrap: wrap; gap: 4px 12px; }
  .music-inline { order: 3; flex-basis: 100%; max-width: none; }
  .music-inline input { font-size: 16px; }
}

#cursor-trail { position: fixed; inset: 0; z-index: 50; overflow: hidden; pointer-events: none; }
#cursor-trail span { position: absolute; font-size: 18px; line-height: 1; text-shadow: 0 0 10px currentColor; pointer-events: none; animation: cursor-spark 1200ms linear forwards; }
@keyframes cursor-spark {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  15% { opacity: .9; }
  50% { opacity: .8; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--drift-x)), calc(-50% + var(--drift-y))) scale(.2); }
}
@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) { #cursor-trail { display: none; } }
