/* OneButton Audio & Synth Studio — Studio UI Stylesheet */
:root {
  --bg-root: #070b11;
  --bg-panel: #0d141f;
  --bg-panel-alt: #111b2a;
  --bg-control: #162235;
  --bg-control-hover: #1d2d46;
  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(52, 211, 153, 0.38);
  --text-primary: #e6edf7;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --indigo-400: #818cf8;
  --indigo-500: #6366f1;
  --amber-400: #fbbf24;
  --rose-400: #fb7185;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-glow: 0 0 28px rgba(16, 185, 129, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-root);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(16, 185, 129, 0.09) 0%, transparent 42%),
    radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
    linear-gradient(180deg, #070b11 0%, #090f18 100%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
  color: inherit;
}

.studio-shell {
  max-width: 1520px;
  margin: 0 auto;
  padding: 16px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header & Master Transport */
.studio-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(13, 20, 31, 0.96), rgba(17, 27, 42, 0.92));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.22);
}

.brand-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hub-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  color: var(--emerald-400);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.transport-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.engine-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber-400);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.65);
  transition: background 0.2s, box-shadow 0.2s;
}

.led.active {
  background: var(--emerald-400);
  box-shadow: 0 0 10px var(--emerald-400);
}

.transport-metric {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-control);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.transport-metric label {
  color: var(--text-secondary);
}

.transport-metric input[type="range"] {
  width: 78px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-control);
  color: var(--text-primary);
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.btn:hover {
  background: var(--bg-control-hover);
  border-color: rgba(148, 163, 184, 0.35);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--emerald-600), var(--emerald-500));
  border-color: rgba(52, 211, 153, 0.55);
  color: #03150e;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-400));
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
}

.btn-indigo {
  background: linear-gradient(135deg, #4f46e5, var(--indigo-500));
  border-color: rgba(129, 140, 248, 0.5);
  color: #eef2ff;
}

.btn-indigo:hover {
  background: linear-gradient(135deg, var(--indigo-500), var(--indigo-400));
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.35);
}

.btn-danger {
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.35);
  color: var(--rose-400);
}

.btn-danger:hover {
  background: rgba(251, 113, 133, 0.22);
}

.btn-sm {
  padding: 5px 9px;
  font-size: 0.76rem;
}

/* Main Workspace Layout */
.workspace-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1080px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.panel-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-meta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Preset Library */
.search-input {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-root);
  color: var(--text-primary);
  font-size: 0.84rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.16);
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-alt);
  color: var(--text-secondary);
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  color: var(--text-primary);
  border-color: rgba(148, 163, 184, 0.35);
}

.pill.active {
  background: rgba(16, 185, 129, 0.16);
  border-color: var(--emerald-500);
  color: var(--emerald-400);
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 580px;
  overflow-y: auto;
  padding-right: 4px;
}

.preset-list::-webkit-scrollbar {
  width: 6px;
}

.preset-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
}

.preset-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  text-align: left;
  transition: all 0.14s ease;
}

.preset-item:hover {
  border-color: rgba(99, 102, 241, 0.45);
  background: #142134;
}

.preset-item.selected {
  border-color: var(--emerald-500);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(99, 102, 241, 0.08));
  box-shadow: var(--shadow-glow);
}

.preset-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.preset-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.preset-cat {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.14);
  color: var(--indigo-400);
}

.preset-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.preset-specs {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  color: var(--text-muted);
}

/* Right Studio Column */
.studio-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Oscilloscope + OneButton Trigger Stage */
.stage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 1fr);
  gap: 16px;
}

@media (max-width: 820px) {
  .stage-grid {
    grid-template-columns: 1fr;
  }
}

.scope-wrap {
  position: relative;
  background: #05090f;
  border: 1px solid rgba(52, 211, 153, 0.24);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 220px;
}

#scopeCanvas {
  width: 100%;
  height: 220px;
  display: block;
}

.scope-overlay {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: rgba(148, 163, 184, 0.9);
}

.scope-mode-toggle {
  pointer-events: auto;
  display: flex;
  gap: 4px;
}

.onebutton-stage {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.big-trigger-btn {
  position: relative;
  width: 100%;
  min-height: 112px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(52, 211, 153, 0.45);
  background:
    radial-gradient(circle at 50% 30%, rgba(52, 211, 153, 0.24), transparent 70%),
    linear-gradient(145deg, #0c2924, #0d1b2e);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.big-trigger-btn:hover {
  border-color: var(--emerald-400);
  box-shadow: 0 0 28px rgba(16, 185, 129, 0.28);
}

.big-trigger-btn.firing,
.big-trigger-btn:active {
  transform: scale(0.985);
  box-shadow: 0 0 36px rgba(52, 211, 153, 0.5);
  border-color: #6ee7b7;
}

.big-trigger-label {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--emerald-400);
}

.big-trigger-sub {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.quick-sfx-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.sfx-pad {
  padding: 7px 4px;
  font-family: var(--font-mono);
  font-size: 0.71rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-control);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.sfx-pad:hover {
  color: var(--text-primary);
  border-color: var(--indigo-400);
  background: rgba(99, 102, 241, 0.15);
}

.sfx-pad.flash {
  border-color: var(--emerald-400);
  color: var(--emerald-400);
  background: rgba(16, 185, 129, 0.18);
}

/* Synth Parameter Rack */
.rack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.rack-module {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.module-title {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--emerald-400);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
}

.control-label {
  color: var(--text-secondary);
}

.control-val {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-primary);
}

select.studio-select {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-root);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-primary);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: #1f2e45;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--emerald-400);
  border: 2px solid #04221a;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.45);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--emerald-400);
  border: 2px solid #04221a;
  cursor: pointer;
}

.patch-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.patch-save-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.patch-name-input {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-root);
  font-size: 0.82rem;
  min-width: 185px;
}

/* 16-Step Sequencer */
.seq-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.seq-pattern-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seq-grid-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}

.seq-table {
  width: 100%;
  min-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.seq-row {
  display: grid;
  grid-template-columns: 118px repeat(16, minmax(28px, 1fr));
  gap: 5px;
  align-items: center;
}

.seq-track-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.track-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 6px;
}

.seq-step {
  height: 30px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  background: #101927;
  cursor: pointer;
  transition: all 0.08s ease;
  position: relative;
}

.seq-step:nth-child(4n + 2) {
  border-left-color: rgba(148, 163, 184, 0.3);
}

.seq-step:hover {
  border-color: rgba(148, 163, 184, 0.45);
}

.seq-step.on {
  background: rgba(16, 185, 129, 0.3);
  border-color: var(--emerald-400);
  box-shadow: inset 0 0 8px rgba(52, 211, 153, 0.32);
}

.seq-step.on.melodic {
  background: rgba(99, 102, 241, 0.34);
  border-color: var(--indigo-400);
  box-shadow: inset 0 0 8px rgba(129, 140, 248, 0.34);
}

.seq-step.playhead {
  outline: 2px solid #fbbf24;
  outline-offset: -1px;
}

.seq-step.on.playhead {
  background: rgba(52, 211, 153, 0.65);
}

/* Footer */
.studio-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-control);
  color: var(--text-secondary);
  font-size: 0.71rem;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0d1d2b;
  border: 1px solid var(--emerald-500);
  color: var(--text-primary);
  padding: 10px 15px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}
