:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #13161c;
  --surface-2: #1a1e26;
  --surface-3: #222833;
  --line: #2b313d;
  --text: #f3f5f7;
  --muted: #929cab;
  --accent: #76e4b8;
  --accent-ink: #08271d;
  --blue: #68a7ff;
  --red: #ff5d68;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; overflow-x: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.login { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: 0 24px 90px #000a; }
.login::backdrop { background: #07080bd9; backdrop-filter: blur(12px); }
.login form { display: grid; gap: 18px; padding: 32px; }
.login h1 { margin: -6px 0 8px; font-size: 1.7rem; }
.logo { font-weight: 900; letter-spacing: -.05em; font-size: 1.25rem; }
.logo span { color: var(--accent); }

.topbar { position: sticky; top: 0; z-index: 20; height: 66px; display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #101319ee; backdrop-filter: blur(16px); }
.brand-block { display: flex; align-items: center; gap: 16px; min-width: 270px; }
.brand-block input { max-width: 160px; color: var(--muted); border: 0; border-left: 1px solid var(--line); border-radius: 0; background: transparent; }
.status-line { display: flex; gap: 8px; margin-right: auto; }
.status { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: #555e6b; }
.status.ok { color: var(--text); }
.status.ok i { background: var(--accent); box-shadow: 0 0 10px #76e4b888; }
.status.warn i { background: #ffc857; }

.body-grid { display: grid; grid-template-columns: 142px minmax(0, 1fr); min-height: calc(100vh - 242px); }
.navigation { position: sticky; top: 66px; align-self: start; height: calc(100vh - 66px); display: flex; flex-direction: column; gap: 5px; padding: 16px 10px; border-right: 1px solid var(--line); background: #0e1116; }
.nav-item { min-height: 42px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--accent); }
.nav-item.logout { margin-top: auto; }
.workspace { min-width: 0; padding: 14px; padding-bottom: 190px; }
.view { display: none; }
.view.active { display: block; }
.live-grid { display: grid; grid-template-columns: minmax(250px, .9fr) minmax(300px, 1.2fr); gap: 14px; }
.palette-panel { grid-column: 1 / -1; }
.output-grid { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(420px, 1.6fr); gap: 14px; }

.panel { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.02em; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: 10px; font-weight: 800; }
.help { color: var(--muted); line-height: 1.5; }
.error { min-height: 18px; margin: 0; color: var(--red); }

button { border: 1px solid var(--line); cursor: pointer; user-select: none; touch-action: manipulation; }
button:active { transform: translateY(1px); }
.primary, .quiet, .blackout, .icon-button { min-height: 40px; padding: 0 14px; border-radius: 8px; }
.primary { border-color: transparent; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.quiet, .icon-button { background: var(--surface-2); }
.quiet:hover { background: var(--surface-3); }
.danger-text { color: #ff7b83; }
.blackout { border-color: #7e2930; background: #35151a; color: #ffabb0; font-weight: 900; letter-spacing: .07em; }
.blackout.active { background: var(--red); border-color: var(--red); color: #210306; box-shadow: 0 0 22px #ff5d6855; }
.actions { display: flex; gap: 8px; }
.actions.wrap { flex-wrap: wrap; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
input, select { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #0e1116; color: var(--text); }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #68a7ff20; }
input[type="range"] { min-height: 24px; padding: 0; accent-color: var(--accent); box-shadow: none; }
input[type="color"] { width: 70px; height: 48px; padding: 4px; }
.master { display: grid; grid-template-columns: auto 110px 38px; align-items: center; gap: 8px; }
.master output { color: var(--text); font-variant-numeric: tabular-nums; }
.form-grid { display: grid; gap: 14px; margin-top: 20px; }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 18px; min-height: auto; }

.button-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 7px; }
.button-grid + .button-grid { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.tile { position: relative; min-height: 60px; padding: 9px; border-radius: 8px; background: var(--surface-2); text-align: left; overflow: hidden; }
.tile small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.tile.selected { border-color: var(--accent); background: #173329; box-shadow: inset 0 0 0 1px var(--accent); }
.tile.palette { border-top: 5px solid var(--tile-color, #60708a); }
.groups .tile { min-height: 42px; color: var(--blue); }

.color-composer { display: flex; gap: 8px; margin-bottom: 12px; }
.attributes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.attribute { display: grid; grid-template-columns: minmax(76px, 1fr) 2fr 38px; align-items: center; gap: 8px; padding: 8px 0; }
.attribute output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.list { display: grid; gap: 8px; }
.list-row { display: grid; grid-template-columns: 50px 1fr auto auto; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.list-row strong { font-size: 14px; }
.list-row small { color: var(--muted); }
.empty { padding: 40px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
td input { min-width: 90px; }
td:first-child { width: 60px; color: var(--muted); }

.dmx-grid { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; }
.dmx-cell { min-width: 0; padding: 5px 2px; border-radius: 3px; background: #0e1116; text-align: center; font-variant-numeric: tabular-nums; font-size: 10px; color: #687384; }
.dmx-cell.active { background: color-mix(in srgb, var(--blue) var(--level), #11151c); color: white; }
.data-view { min-height: 260px; max-height: 430px; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #0b0d10; color: #b8c2cf; white-space: pre-wrap; font-size: 12px; }

.playback-dock { position: fixed; z-index: 15; left: 142px; right: 0; bottom: 0; height: 176px; padding: 10px 14px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #0e1116f5; backdrop-filter: blur(16px); }
.playbacks { display: grid; grid-template-columns: repeat(10, minmax(86px, 1fr)); gap: 7px; height: 100%; overflow-x: auto; }
.playback { min-width: 86px; display: grid; grid-template-rows: auto 1fr auto; gap: 5px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.playback.active { border-color: var(--accent); }
.playback select { min-height: 28px; padding: 3px; font-size: 10px; }
.playback input[type="range"] { writing-mode: vertical-lr; direction: rtl; width: 100%; height: 68px; margin: auto; }
.playback-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.playback-actions button { min-height: 25px; padding: 2px; border-radius: 5px; background: var(--surface-2); font-size: 9px; }
.playback-actions .flash.pressed { background: var(--accent); color: var(--accent-ink); }
.toast { position: fixed; z-index: 50; right: 18px; bottom: 190px; max-width: 360px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-3); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: #7e2930; color: #ffabb0; }
.mobile-only { display: none; }

@media (max-width: 980px) {
  .status-line .status { font-size: 0; }
  .status-line .status i { width: 9px; height: 9px; }
  .output-grid { grid-template-columns: 1fr; }
  .attributes { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  body { font-size: 13px; }
  .mobile-only { display: inline-flex; }
  .topbar { gap: 8px; height: 58px; padding: 7px 9px; }
  .brand-block { min-width: 0; flex: 1; }
  .brand-block .logo { display: none; }
  .brand-block input { max-width: none; border: 0; padding: 5px; }
  .status-line { margin: 0; }
  .status-line .status:nth-child(2) { display: none; }
  .master.compact { display: none; }
  .blackout { min-height: 40px; padding: 0 9px; font-size: 10px; }
  .body-grid { display: block; min-height: 0; }
  .navigation { position: fixed; z-index: 30; top: 58px; bottom: 0; left: 0; width: 190px; height: auto; transform: translateX(-100%); transition: transform .2s; box-shadow: 20px 0 50px #0009; }
  .navigation.open { transform: none; }
  .workspace { padding: 8px 8px 160px; }
  .live-grid { grid-template-columns: 1fr; }
  .palette-panel { grid-column: auto; }
  .panel { padding: 12px; }
  .button-grid { grid-template-columns: repeat(4, 1fr); }
  .tile { min-height: 54px; padding: 7px; font-size: 11px; }
  .playback-dock { left: 0; height: 150px; padding: 7px 8px max(7px, env(safe-area-inset-bottom)); }
  .playback { grid-template-rows: auto 1fr auto; }
  .playback input[type="range"] { height: 48px; }
  .dmx-grid { grid-template-columns: repeat(8, 1fr); }
  .toast { right: 8px; left: 8px; bottom: 160px; }
}

@media (max-width: 420px) {
  .button-grid { grid-template-columns: repeat(3, 1fr); }
  .attribute { grid-template-columns: 86px 1fr 32px; }
  .panel-head { align-items: flex-start; }
  .actions { flex-wrap: wrap; }
}
