/* ============================================================
   RESET & BASE  —  matches Sprite Tool / Tracker design language
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  color: #1a1a1a;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================================
   TOP BAR
   ============================================================ */
#topbar {
  background: #cccccc;
  border-bottom: 1.5px solid #999999;
  padding: 7px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  user-select: none;
}

#topbar h1 {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-right: 0;
}

#topbar .subtitle {
  font-size: 11px;
  color: #789;
  font-style: italic;
}

.sep { width: 1px; height: 22px; background: #999999; margin: 0 2px; }

.btn {
  padding: 5px 12px;
  border: 1.5px solid #5a5a5a;
  border-radius: 5px;
  background: #eeeeee;
  color: #1a1a1a;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.btn:hover                { background: #d5d5d5; border-color: #4a4a4a; }
.btn.active               { background: #5a5a5a; color: #fff; border-color: #3a3a3a; }
.btn.green                { border-color: #2e7d32; color: #2e7d32; }
.btn.green:hover          { background: #d4edda; }
.btn.green.active         { background: #3a7a3a; border-color: #2a5a2a; color: #fff; }

label.top { font-size: 11px; color: #556; font-weight: 600; }

/* Mode selector — Standard / OS-7 BIOS */
.mode-sel { display: flex; gap: 2px; }
.mode-btn {
  padding: 3px 8px;
  border: 1.5px solid #5a5a5a;
  border-radius: 4px;
  background: #e4e4e4;
  color: #444;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  transition: background 0.12s;
}
.mode-btn:hover:not(.active) { background: #d5d5d5; }
#mode-std.active             { background: #2980b9; color: #fff; border-color: #1a5c8a; }
#mode-bios.active            { background: #6a1f8a; color: #fff; border-color: #4a1560; }

/* Channel tabs group — only visible in OS-7 BIOS mode */
#ch-tabs-group               { display: contents; }
body.mode-std #ch-tabs-group { display: none; }

/* Channel tabs */
.ch-tab {
  padding: 4px 10px;
  border: 1.5px solid #5a5a5a;
  border-radius: 5px;
  background: #e4e4e4;
  color: #444;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Segoe UI', system-ui, sans-serif;
  transition: background 0.1s, color 0.1s;
  position: relative;
}
.ch-tab:hover:not(.active) { background: #d5d5d5; color: #222; }
.ch-tab.active     { background: #2980b9; color: #fff; border-color: #1a5c8a; }
.ch-tab.noise      { border-color: #7d3c98; color: #7d3c98; }
.ch-tab.noise.active { background: #7d3c98; color: #fff; border-color: #5b2c6f; }
/* Dot indicator — click to arm/disarm non-current channels */
.ch-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid currentColor;
  margin-left: 5px;
  vertical-align: middle;
  opacity: 0.35;
  cursor: pointer;
  transition: background 0.1s, opacity 0.1s, transform 0.12s;
}
.ch-tab.has-audio .ch-dot    { background: #4caf50; border-color: #388e3c; opacity: 1; }
.ch-tab:not(.active) .ch-dot:hover { transform: scale(1.6); opacity: 0.9; }
.ch-tab.active .ch-dot       { cursor: default; }

select.top {
  background: #f8f8f8;
  border: 1.5px solid #5a5a5a;
  color: #1a1a1a;
  padding: 4px 6px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
#main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.panel {
  background: #cccccc;
  border-right: 1.5px solid #999999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel:last-child { border-right: none; }

.panel-title {
  background: #bbbbbb;
  border-bottom: 1.5px solid #999999;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #3a3a3a;
  flex-shrink: 0;
}

.panel-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
}

/* ============================================================
   LEFT PANEL — Parameters
   ============================================================ */
#left-panel { width: 218px; flex-shrink: 0; }

.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  margin-bottom: 5px;
}

/* Channel selector */
.ch-row { display: flex; gap: 3px; }
.ch-btn {
  flex: 1;
  padding: 5px 0;
  border: 1.5px solid #5a5a5a;
  border-radius: 5px;
  background: #eeeeee;
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  transition: background 0.12s;
}
.ch-btn:hover:not(.active)  { background: #d5d5d5; }
.ch-btn.active            { background: #5a5a5a; color: #fff; border-color: #3a3a3a; }
#type-tone.active         { background: #2980b9; border-color: #1a5276; }
#type-noise.active        { background: #7d3c98; border-color: #5b2c6f; }

/* Segmented buttons */
.seg-row { display: flex; gap: 3px; }
.seg-btn {
  flex: 1;
  padding: 4px 0;
  border: 1.5px solid #5a5a5a;
  border-radius: 4px;
  background: #eeeeee;
  color: #1a1a1a;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  transition: background 0.12s;
}
.seg-btn:hover:not(.active) { background: #d5d5d5; }
.seg-btn.active { background: #5a5a5a; color: #fff; border-color: #3a3a3a; }
.seg-btn.nrate-t3.active { background: #7d3c98; border-color: #5b2c6f; }

/* Divider inputs */
.div-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.div-label {
  font-size: 11px;
  color: #444;
  width: 36px;
  flex-shrink: 0;
}
.div-note {
  font-size: 10px;
  color: #777;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.snap-btn {
  flex-shrink: 0;
  padding: 2px 5px;
  border: 1.5px solid #5a5a5a;
  border-radius: 4px;
  background: #eeeeee;
  color: #444;
  font-size: 11px;
  cursor: pointer;
  line-height: 1;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.snap-btn:hover { background: #d5d5d5; border-color: #4a4a4a; }

input[type=number] {
  background: #f0f0f0;
  border: 1.5px solid #5a5a5a;
  color: #1a1a1a;
  padding: 3px 5px;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  width: 58px;
}
input[type=number]:focus { outline: none; border-color: #3a3a3a; background: #fff; }

/* Sliders */
.slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.slider-label {
  font-size: 11px;
  color: #444;
  width: 56px;
  flex-shrink: 0;
}
.slider-val {
  font-size: 11px;
  font-weight: 700;
  color: #222;
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}
.slider-unit { font-size: 10px; color: #888; }
.slider-db   { font-size: 10px; color: #888; width: 34px; flex-shrink: 0; }
input[type=range] {
  flex: 1;
  height: 4px;
  accent-color: #5a5a5a;
  cursor: pointer;
}

#duration-info {
  font-size: 12px;
  font-weight: 700;
  color: #222;
  background: #b8b8b8;
  border-radius: 4px;
  padding: 5px 8px;
  text-align: center;
}

/* ============================================================
   CENTER PANEL — Visualizer
   ============================================================ */
#center-panel { flex: 1; width: calc(100% - 378px); min-width: 0; }

#viz-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 6px;
  overflow: hidden;
  position: relative;
}

#viz-playline {
  position: absolute;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: rgba(255, 255, 255, 0.75);
  pointer-events: none;
  display: none;
  z-index: 2;
  border-radius: 1px;
}

#viz-canvas {
  display: block;
  background: #1e1e1e;
  border-radius: 4px;
  border: 1px solid #999;
  width: 100%;
  flex: 1;
  min-height: 0;
}

/* ============================================================
   RIGHT PANEL — Frame Data
   ============================================================ */
#right-panel { width: 160px; flex-shrink: 0; }

#frame-panel-title {
  display: flex;
  align-items: center;
  gap: 4px;
}
#frame-panel-title > span { flex: 1; }
.frame-title-btn {
  padding: 1px 6px;
  font-size: 9px;
  border-radius: 4px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
}
#right-panel.manual-mode #frame-table-wrap { background: #f5f5e8; }
#right-panel.manual-mode #frame-panel-title { background: #c8c890; }

#frame-table-wrap {
  flex: 1;
  overflow-y: auto;
}

#frame-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 11px;
}
#frame-table th {
  background: #b8b8b8;
  border-bottom: 1.5px solid #999;
  padding: 4px 6px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #333;
  position: sticky;
  top: 0;
  z-index: 1;
}
#frame-table td {
  padding: 2px 6px;
  text-align: center;
  border-bottom: 1px solid #b8b8b8;
  color: #222;
}
#frame-table tr:nth-child(even) td { background: #c4c4c4; }
#frame-table tr.playing td { background: #c8e6c8 !important; color: #1a6a1a; font-weight: 700; }

/* ============================================================
   STATUS BAR
   ============================================================ */
#statusbar {
  background: #cccccc;
  border-top: 1.5px solid #999999;
  padding: 4px 14px;
  font-size: 11px;
  color: #555;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============================================================
   EXPORT MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
  background: #cccccc;
  border: 1.5px solid #5a5a5a;
  border-radius: 8px;
  width: 540px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.modal-title {
  background: #bbbbbb;
  border-bottom: 1.5px solid #999;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.modal-close {
  background: none; border: none;
  font-size: 14px; cursor: pointer; color: #555; padding: 0 4px;
}
.modal-close:hover { color: #000; }

pre.modal-code {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  background: #f0f0f0;
  color: #1a1a1a;
  white-space: pre;
  margin: 8px;
  border-radius: 4px;
  border: 1px solid #cccccc;
}
.modal-footer {
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  border-top: 1px solid #999;
  flex-shrink: 0;
}

/* Import modal extras */
#import-hint {
  margin: 8px 8px 0;
  padding: 8px 10px;
  background: #f0f0f0;
  border-radius: 4px;
  border: 1px solid #cccccc;
  font-size: 11px;
  line-height: 1.6;
  color: #333;
}
#import-hint code {
  background: #e0e0e0;
  border-radius: 3px;
  padding: 1px 4px;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 10px;
}
#import-textarea {
  display: block;
  margin: 8px;
  width: calc(100% - 16px);
  height: 160px;
  resize: vertical;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 11px;
  background: #f8f8f8;
  border: 1.5px solid #5a5a5a;
  border-radius: 4px;
  padding: 8px;
  color: #1a1a1a;
}
#import-textarea:focus { outline: none; border-color: #3a3a3a; }
#import-error {
  margin: 0 8px 6px;
  font-size: 11px;
  color: #b03030;
  font-weight: 600;
  min-height: 16px;
}
