/* ===========================================================
   Console — token system
   A hardware-mixer feel: warm near-black chassis, brushed-metal
   panels, one amber LED accent used sparingly. Numeric readouts
   run in monospace, like a channel-strip display.
=========================================================== */
:root{
  --bg:            #14161a;
  --panel:         #1c1f25;
  --panel-raised:  #262a31;
  --panel-line:    #34393f;
  --text:          #edeef0;
  --text-dim:      #9aa0a8;
  --text-faint:    #676d76;
  --accent:        #e8a33d;
  --accent-dim:    #a97a35;
  --danger:        #ff6b5e;
  --wave:          #4fd1c5;
  --radius:        10px;
  --radius-lg:     16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}
.mono{ font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .01em; }
.label-sm{ font-size: 11px; color: var(--text-faint); }

button{ font: inherit; }
input[type="text"]{ font: inherit; }

svg.icon{ width: 20px; height: 20px; display:block; }

/* ---------- screens ---------- */
.screen{
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
.screen--active{ display: flex; }

/* ---------- topbar ---------- */
.topbar{
  display:flex; align-items:center; gap:10px;
  padding: calc(14px + var(--safe-t)) 16px 12px;
  border-bottom: 1px solid var(--panel-line);
  background: linear-gradient(180deg, #1a1d22, var(--bg));
  flex-shrink:0;
}
.topbar__brand{ display:flex; align-items:center; gap:9px; flex:1; min-width:0; }
.brand-mark{
  width:10px; height:10px; border-radius:50%;
  background: var(--accent);
  box-shadow: 0 0 8px 1px rgba(232,163,61,.65);
  flex-shrink:0;
}
.topbar h1{ font-size: 17px; font-weight: 700; margin:0; letter-spacing: -.01em; }

.topbar--editor{ justify-content: space-between; }
.editor-name{
  flex:1; min-width:0;
  background: transparent; border: none;
  color: var(--text); font-size: 15px; font-weight: 600;
  text-align:center; padding: 8px 4px;
  border-bottom: 1px solid transparent;
}
.editor-name:focus{ outline:none; border-bottom-color: var(--accent-dim); }

/* ---------- buttons ---------- */
.btn{
  border: 1px solid var(--panel-line);
  background: var(--panel-raised);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-height: 44px;
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  cursor:pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active{ transform: scale(.96); }
.btn--pill{ border-radius: 999px; }
.btn--accent{
  background: var(--accent); border-color: var(--accent); color: #1c1206; font-weight: 700;
}
.btn--outline{ background: transparent; }
.btn--ghost{ background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--sm{ min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn--icon{ width:44px; height:44px; padding:0; border-radius: 50%; }
.btn--play .icon--pause{ display:none; }
.btn--play.is-playing .icon--play{ display:none; }
.btn--play.is-playing .icon--pause{ display:block; }

/* ---------- track list ---------- */
.track-list{
  flex:1; overflow-y:auto;
  padding: 12px 12px calc(24px + var(--safe-b));
  display:flex; flex-direction:column; gap:10px;
  -webkit-overflow-scrolling: touch;
}

.empty-state{
  margin-top: 14vh;
  display:flex; flex-direction:column; align-items:center; text-align:center;
  gap:10px; padding: 0 30px; color: var(--text-dim);
}
.empty-state__icon{ width:56px; height:56px; color: var(--accent-dim); margin-bottom:4px; }
.empty-state__title{ color: var(--text); font-weight:700; font-size:16px; margin:0; }
.empty-state__body{ font-size: 13.5px; line-height:1.5; margin:0 0 6px; }

.track{
  display:flex; gap:10px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  padding: 12px;
}
.track__swatch{
  width:5px; border-radius:3px; flex-shrink:0;
  background: var(--wave);
}
.track__body{ flex:1; min-width:0; display:flex; flex-direction:column; gap:8px; }
.track__head{ display:flex; justify-content:space-between; align-items:baseline; gap:8px; }
.track__name{
  font-weight:600; font-size:14.5px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.track__time{ font-family: ui-monospace, Menlo, Consolas, monospace; font-size:12px; color: var(--text-faint); flex-shrink:0; }
.track__wave{ width:100%; height:46px; display:block; border-radius:6px; background: #14161a; }
.track__controls{ display:flex; align-items:center; gap:8px; }
.track__mute{
  width:38px; height:38px; flex-shrink:0; border-radius:50%;
  border:1px solid var(--panel-line); background: var(--panel-raised); color: var(--text-dim);
  display:flex; align-items:center; justify-content:center;
}
.track__mute.is-muted{ color: var(--danger); border-color: rgba(255,107,94,.5); background: rgba(255,107,94,.08); }
.track__mute.is-muted .wave-lines{ display:none; }
.track__volume{ flex:1; min-width:0; }
.track__edit{ flex-shrink:0; }
.track__remove{
  width:38px; height:38px; flex-shrink:0; border-radius:50%; border:none;
  background:transparent; color: var(--text-faint); display:flex; align-items:center; justify-content:center;
}

/* ---------- range inputs (horizontal) ---------- */
input[type="range"]{
  -webkit-appearance:none; appearance:none;
  width:100%; height: 30px; background: transparent; touch-action: none;
}
input[type="range"]::-webkit-slider-runnable-track{
  height:4px; border-radius:2px; background: var(--panel-line);
}
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none;
  width:20px; height:20px; margin-top:-8px; border-radius:50%;
  background: var(--accent); border: 2px solid #14161a;
  box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
input[type="range"]::-moz-range-track{ height:4px; border-radius:2px; background: var(--panel-line); }
input[type="range"]::-moz-range-thumb{
  width:16px; height:16px; border-radius:50%; background: var(--accent); border: 2px solid #14161a;
}

/* ---------- transport ---------- */
.transport{
  flex-shrink:0;
  border-top: 1px solid var(--panel-line);
  background: linear-gradient(0deg, #191c21, var(--bg));
  padding: 10px 16px calc(12px + var(--safe-b));
}
.transport__scrub{ display:flex; align-items:center; gap:10px; margin-bottom:6px; }
.transport__scrub span{ font-size:11.5px; color: var(--text-faint); width:36px; flex-shrink:0; }
.transport__scrub span:last-child{ text-align:right; }
.transport__row{ display:flex; align-items:center; gap:12px; }
.transport__master{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.transport__master label{ display:block; }

/* ---------- editor ---------- */
.editor-scroll{ flex:1; overflow-y:auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(30px + var(--safe-b)); }

.editor-wave-wrap{
  position:relative;
  margin: 14px 16px 4px;
  background:#0f1114; border-radius: var(--radius-lg); overflow:hidden;
  border: 1px solid var(--panel-line);
}
.editor-wave{ width:100%; height:140px; display:block; }
.trim-handle{
  position:absolute; top:0; bottom:0; width:28px; left:0;
  transform: translateX(-50%);
  display:flex; align-items:center; justify-content:center;
  touch-action:none; cursor: ew-resize;
}
.trim-handle span{
  width:4px; height:56px; border-radius:3px; background: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,163,61,.18);
}

.editor-preview-row{
  display:flex; align-items:center; gap:12px;
  padding: 8px 16px 4px;
}
.editor-preview-row .mono{ flex:1; font-size:13px; color: var(--text-dim); }

.panel{
  margin: 14px 16px 0; padding: 14px 14px 16px;
  background: var(--panel); border:1px solid var(--panel-line); border-radius: var(--radius-lg);
}
.panel__title{ font-size:13px; text-transform: none; color: var(--text-dim); margin:0 0 12px; font-weight:700; }

.field{ margin-bottom: 14px; }
.field:last-child{ margin-bottom:0; }
.field label{ display:flex; justify-content:space-between; font-size:14px; margin-bottom:4px; }
.field__value{ color: var(--accent); }
.field__hint{ font-size:12px; color: var(--text-faint); line-height:1.5; margin: 8px 0 0; }

.eq-row{ display:flex; justify-content:space-around; align-items:flex-end; padding: 6px 0 2px; }
.eq-band{ display:flex; flex-direction:column; align-items:center; gap:6px; }
.eq-band input[type="range"]{
  writing-mode: vertical-lr;
  direction: rtl;
  width: 30px; height: 120px;
  padding: 0;
}
.eq-band__val{ font-size:11.5px; color: var(--text-dim); }
.eq-band__label{ font-size:12px; color: var(--text-faint); }

.tool-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
.tool-grid .btn{ width:100%; }
.tool-grid .btn:last-child{ grid-column: 1 / -1; }

/* ---------- toast ---------- */
.toast{
  position: fixed; left:50%; bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%) translateY(12px);
  background: var(--panel-raised); border:1px solid var(--panel-line);
  color: var(--text); padding: 10px 16px; border-radius: 999px;
  font-size: 13.5px; opacity:0; pointer-events:none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50; max-width: 86vw; text-align:center;
}
.toast.is-visible{ opacity:1; transform: translateX(-50%) translateY(0); }

/* ---------- small screens fine tuning ---------- */
@media (max-width: 360px){
  .track__controls{ flex-wrap:wrap; }
  .track__edit{ order:3; }
}

/* ---------- accessible focus ---------- */
button:focus-visible, input:focus-visible{
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce){
  .btn, .toast{ transition: none; }
}
