:root {
    color-scheme: dark;
    --page: #0b0d10;
    --surface: #14181f;
    --raised: #1b212a;
    --border: #2a3340;
    --text: #f3f6fa;
    --muted: #98a4b3;
    --focus: #73b7ff;
    --danger: #ff6b6b;
    --success: #62d6a5;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; background: var(--page); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.app-shell { width: min(100%, 1360px); min-height: 100dvh; margin: auto; padding: 0 28px 32px; }
.app-header { display: flex; height: 68px; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; letter-spacing: .13em; }
.brand-dots { display: flex; align-items: end; gap: 3px; width: 25px; height: 22px; }
.brand-dots i { width: 6px; border-radius: 3px; background: #38ec8c; box-shadow: 0 0 13px rgb(56 236 140 / .38); }
.brand-dots i:nth-child(1) { height: 11px; }.brand-dots i:nth-child(2) { height: 21px; }.brand-dots i:nth-child(3) { height: 15px; }
.product-label { flex: 1; color: #586373; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.studio-link { color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700; }
.studio-link:hover { color: var(--text); }

main { display: grid; gap: 18px; }
.led-stage { position: relative; display: grid; min-height: clamp(220px, 39vw, 480px); place-items: center; overflow: hidden; border: 1px solid #232931; border-radius: 24px; background: radial-gradient(circle at 50% 35%, #15191e 0, #070809 58%, #030303 100%); box-shadow: inset 0 0 70px rgb(0 0 0 / .72), 0 24px 80px rgb(0 0 0 / .2); }
.led-frame { position: relative; width: min(100%, 1120px); padding: clamp(14px, 2vw, 26px); border: 1px solid #22272d; border-radius: 18px; background: #020202; box-shadow: inset 0 0 0 4px #090a0b, 0 15px 50px rgb(0 0 0 / .65); }
#canvas { display: block; width: 100%; height: auto; background: #000; image-rendering: auto; }
.canvas-tap { position: absolute; z-index: 2; top: 0; bottom: 0; width: 25%; cursor: pointer; }
.canvas-tap.left { left: 0; }.canvas-tap.right { right: 0; }
.view-hint { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); margin: 0; padding: 8px 12px; border-radius: 10px; background: rgb(0 0 0 / .78); color: var(--muted); font-size: 11px; }

.welcome-card, .finished-card, .inline-error { width: min(100%, 720px); margin: 8px auto 0; padding: 26px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); text-align: center; }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .17em; text-transform: uppercase; }
.welcome-card h1 { margin: 9px 0 6px; font-size: clamp(25px, 4vw, 36px); }
.welcome-card > p { margin: 0 0 20px; color: var(--muted); }
.welcome-actions { display: flex; justify-content: center; gap: 8px; }
.welcome-route { margin: 14px 0 0 !important; font-size: 12px; }
.button, .icon-button {
    display: inline-flex; min-height: 46px; align-items: center; justify-content: center; gap: 8px;
    padding: 0 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--raised);
    color: var(--text); text-decoration: none; font-weight: 750; cursor: pointer;
}
.button.primary { border-color: transparent; background: #73b7ff; color: #07111c; }
.button.secondary:hover, .icon-button:hover { border-color: #465469; background: #222a34; }
.button:focus-visible, .icon-button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.button:disabled { opacity: .42; cursor: default; }
.icon-button { width: 44px; padding: 0; font-size: 18px; }

.now-playing { position: relative; display: grid; grid-template-columns: 7px minmax(0, 1fr) auto; gap: 15px; align-items: center; padding: 16px 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.route-accent { align-self: stretch; border-radius: 4px; background: var(--route-color, #62d6a5); box-shadow: 0 0 16px color-mix(in srgb, var(--route-color), transparent 60%); }
.now-playing h1 { margin: 3px 0; font-size: 23px; }
.now-playing p { margin: 0; color: var(--muted); font-size: 13px; }
.control-dock { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); }
.station-controls { display: grid; grid-template-columns: auto auto minmax(120px, 1fr) auto auto; gap: 7px; }
.control { min-height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--raised); cursor: pointer; font-weight: 750; }
.control.main { min-width: 78px; }
.control.pause { border-color: #345f4c; background: rgb(98 214 165 / .11); color: #9deac8; }
.control:disabled { opacity: .35; cursor: default; }
.view-controls { display: flex; gap: 5px; }
.view-controls button { min-height: 42px; padding: 0 11px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.finished-card h2 { margin: 8px 0 18px; }
.finished-card div { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.inline-error { display: flex; align-items: center; justify-content: space-between; gap: 18px; text-align: left; }
.inline-error h2 { margin: 0 0 4px; font-size: 18px; }
.inline-error p { margin: 0; color: var(--muted); }

.setup-dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto 18px auto auto; padding: 0; overflow: hidden; border: 1px solid #394557; border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: 0 30px 100px rgb(0 0 0 / .58); }
.setup-dialog::backdrop { background: rgb(0 0 0 / .52); backdrop-filter: blur(5px); }
.setup-dialog > form { display: flex; max-height: calc(100dvh - 32px); flex-direction: column; padding: 22px; overflow: auto; }
.setup-dialog header { display: flex; align-items: flex-start; justify-content: space-between; }
.setup-dialog h2 { margin: 5px 0 0; font-size: 25px; }
.setup-steps { display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; gap: 8px; margin: 20px 0; }
.setup-steps button { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 800; }
.setup-steps button[aria-current="step"] { color: var(--focus); }
.setup-steps button:disabled { opacity: .4; cursor: default; }
.setup-steps button i { display: grid; width: 23px; height: 23px; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-style: normal; }
.setup-steps > span { height: 1px; background: var(--border); }
.setup-panel { min-height: 330px; }
.setup-panel h3 { margin: 15px 0 9px; font-size: 13px; }
.route-search { display: flex; min-height: 46px; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid #394557; border-radius: 11px; background: #0f1319; color: var(--muted); }
.route-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); }
.route-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.route-option { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; min-height: 72px; align-items: center; padding: 11px; border: 1px solid var(--border); border-radius: 12px; background: #11161c; color: inherit; text-align: left; cursor: pointer; }
.route-option:hover, .route-option[aria-selected="true"] { border-color: var(--focus); }
.route-option i { align-self: stretch; border-radius: 4px; background: var(--route-color); }
.route-option strong, .route-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-option small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.route-option b { color: var(--focus); }
.loading-copy, .empty-routes { padding: 25px; color: var(--muted); text-align: center; }
.journey-summary { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-bottom: 18px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #11161c; }
.journey-summary i { align-self: stretch; border-radius: 4px; background: var(--route-color); }
.journey-summary strong, .journey-summary small { display: block; }
.journey-summary small { margin-top: 3px; color: var(--muted); }
.journey-summary button { border: 0; background: transparent; color: var(--focus); cursor: pointer; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.path-field { margin: 0 0 14px; padding: 0; border: 0; }
.path-field legend { margin-bottom: 8px; font-size: 12px; font-weight: 800; }
.path-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.path-option { display: grid; grid-template-columns: 7px minmax(0, 1fr) auto; gap: 10px; min-height: 68px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: #11161c; color: var(--text); text-align: left; cursor: pointer; }
.path-option[aria-pressed="true"] { border-color: var(--focus); background: rgb(115 183 255 / .08); }
.path-option i { align-self: stretch; border-radius: 4px; background: var(--route-color, var(--focus)); }
.path-option strong, .path-option small { display: block; }
.path-option small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.path-option b { color: var(--focus); font-size: 11px; }
.setup-panel label { display: grid; gap: 7px; font-size: 12px; font-weight: 750; }
.setup-panel label small { color: var(--muted); font-weight: 400; }
select { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid #394557; border-radius: 10px; background: #0f1319; color: var(--text); }
.loop-options { display: flex; gap: 14px; margin-top: 16px; padding: 13px; border: 1px solid var(--border); border-radius: 11px; }
.loop-options legend { color: var(--muted); font-size: 11px; }
.loop-options label { display: flex; align-items: center; gap: 5px; }
.option-list { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--border); }
.switch-row { display: flex !important; min-height: 62px; flex-direction: row !important; align-items: center; justify-content: space-between; padding: 10px 13px; background: #11161c; }
.switch-row b, .switch-row small { display: block; }
.switch-row small { margin-top: 3px; }
.switch-row input { width: 42px; height: 23px; accent-color: var(--focus); }
.advanced-options { margin-top: 14px; padding: 13px; border: 1px solid var(--border); border-radius: 11px; }
.advanced-options summary { cursor: pointer; font-size: 12px; font-weight: 800; }
.advanced-options .field-grid { grid-template-columns: repeat(3, 1fr); margin: 14px 0 0; }
.setup-error { margin: 10px 0 0; padding: 10px 12px; border: 1px solid rgb(255 107 107 / .42); border-radius: 10px; background: rgb(255 107 107 / .08); color: #ffb1b1; font-size: 12px; }
.setup-dialog footer { position: sticky; bottom: -22px; display: flex; align-items: center; gap: 8px; margin: 20px -22px -22px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface); }
.setup-dialog footer span { flex: 1; }

body[data-view="led-only"] .app-header, body[data-view="led-only"] .welcome-card, body[data-view="led-only"] .now-playing, body[data-view="led-only"] .control-dock, body[data-view="led-only"] .finished-card, body[data-view="fullscreen"] .app-header, body[data-view="fullscreen"] .welcome-card, body[data-view="fullscreen"] .now-playing, body[data-view="fullscreen"] .control-dock, body[data-view="fullscreen"] .finished-card { display: none !important; }
body[data-view="led-only"] .app-shell, body[data-view="fullscreen"] .app-shell { width: 100%; height: 100dvh; padding: 0; }
body[data-view="led-only"] main, body[data-view="fullscreen"] main { height: 100%; }
body[data-view="led-only"] .led-stage, body[data-view="fullscreen"] .led-stage { min-height: 100%; border: 0; border-radius: 0; }
body[data-view="led-only"] .led-frame, body[data-view="fullscreen"] .led-frame { width: min(96vw, calc(96vh * 6)); }
body[data-view="led-only"].controls-visible .control-dock, body[data-view="fullscreen"].controls-visible .control-dock { position: fixed; z-index: 10; right: 14px; bottom: 14px; left: 14px; display: grid !important; background: rgb(20 24 31 / .94); }
body.cursor-hidden, body.cursor-hidden * { cursor: none !important; }

@media (max-width: 699px) {
    .app-shell { padding: 0 12px calc(18px + env(safe-area-inset-bottom)); }
    .app-header { height: 58px; }
    .product-label { display: none; }
    .studio-link { margin-left: auto; font-size: 11px; }
    .led-stage { min-height: 235px; border-radius: 18px; }
    .led-frame { width: calc(100% - 14px); padding: 9px; border-radius: 12px; }
    .welcome-card { padding: 22px 16px; }
    .welcome-actions { flex-direction: column; }
    .now-playing { padding: 12px; }
    .now-playing h1 { font-size: 19px; }
    .control-dock { display: block; padding: 8px; overflow: hidden; }
    .station-controls { grid-template-columns: 1fr 1fr 1.15fr 1fr 1fr; gap: 4px; }
    .control { min-width: 0 !important; min-height: 52px; padding: 0 4px; font-size: 11px; }
    .control.small { display: grid; place-items: center; }
    .control.pause b { display: none; }
    .view-controls { justify-content: center; margin-top: 5px; }
    .setup-dialog { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0; }
    .setup-dialog > form { max-height: 100dvh; padding: 17px 15px calc(17px + env(safe-area-inset-bottom)); }
    .setup-dialog footer { bottom: calc(-17px - env(safe-area-inset-bottom)); margin: 18px -15px calc(-17px - env(safe-area-inset-bottom)); padding: 12px 15px calc(12px + env(safe-area-inset-bottom)); }
    .route-grid, .field-grid, .path-options, .advanced-options .field-grid { grid-template-columns: 1fr; }
    .setup-panel { min-height: auto; }
    .loop-options { display: grid; }
    .inline-error { display: grid; }
}

@media (orientation: landscape) and (max-height: 560px) {
    .app-header { height: 42px; }
    .led-stage { min-height: calc(100dvh - 58px); }
    body[data-state="running"] .now-playing, body[data-state="running"] .control-dock { position: fixed; z-index: 5; right: 8px; left: 8px; opacity: .15; transition: opacity .15s; }
    body[data-state="running"] .now-playing { top: 48px; }
    body[data-state="running"] .control-dock { bottom: 8px; }
    body[data-state="running"] .now-playing:hover, body[data-state="running"] .control-dock:hover { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
