* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0a0f;
  color: #c8c8d0;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: 1fr auto;
  height: 100vh;
}

/* ── Left panel ─────────────────────────────── */

#left-panel {
  grid-row: 1 / 2;
  border-right: 1px solid #1a1a2e;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#left-panel .panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid #1a1a2e;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#left-panel .panel-header h2 {
  font-size: 0.85rem;
  font-weight: 500;
  color: #d4a054;
}

#mode-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.tab-btn {
  background: transparent;
  border: 1px solid #2a2a3e;
  color: #666680;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  color: #d4a054;
  border-color: #d4a054;
}

/* ── Explore panel ──────────────────────────── */

#explore-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#explore-panel .load-buttons {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid #1a1a2e;
}

.load-btn {
  background: #12121e;
  border: 1px solid #2a2a3e;
  color: #888;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.load-btn:hover { border-color: #d4a054; color: #d4a054; }
.load-btn.active-block { border-color: #d4a054; color: #d4a054; }

#json-editor {
  flex: 1;
  background: #0a0a0f;
  border: none;
  color: #c8c8d0;
  font-family: inherit;
  font-size: 0.75rem;
  padding: 12px;
  resize: none;
  outline: none;
  line-height: 1.5;
}

/* Left spindle (shown in column view, replaces JSON editor) */

#left-spindle {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.view-columns #json-editor { display: none; }
.view-columns #left-spindle { display: flex; }

/* Sticky address header */
#spindle-address {
  padding: 8px 12px;
  border-bottom: 1px solid #1a1a2e;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #5a9bf5;
  letter-spacing: 0.05em;
}

#spindle-address .addr-digit { color: #d4a054; }

#spindle-entries {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
}

.left-spindle-empty {
  color: #444;
  font-size: 0.75rem;
  font-style: italic;
  padding: 20px 12px;
  text-align: center;
}

#left-spindle .spindle-entry {
  padding: 10px 0;
  border-bottom: 1px solid #1a1a2e;
}

#left-spindle .spindle-entry:last-child {
  border-bottom: none;
}

#left-spindle .spindle-pscale {
  color: #5a9bf5;
  font-size: 0.65rem;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

#left-spindle .spindle-text {
  color: #c8c8d0;
  font-size: 0.75rem;
  line-height: 1.6;
}

#left-spindle .spindle-entry.current .spindle-pscale {
  color: #d4a054;
}

#left-spindle .spindle-entry.current .spindle-text {
  color: #d4a054;
}

/* ── Live panel ─────────────────────────────── */

#live-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

#live-panel.active { display: flex; }
#explore-panel.active { display: flex; }

.live-controls {
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid #1a1a2e;
}

#mic-btn {
  background: #12121e;
  border: 1px solid #2a2a3e;
  color: #888;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
}

#mic-btn.active {
  color: #e04060;
  border-color: #e04060;
}

#compile-status {
  font-size: 0.65rem;
  color: #666680;
  margin-left: auto;
}

#transcript {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-size: 0.75rem;
  line-height: 1.5;
}

#transcript .final { color: #d0d0e0; margin-bottom: 6px; }
#transcript .interim { color: #8888a0; font-style: italic; }

/* ── Tree panel ─────────────────────────────── */

#tree-panel {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  overflow: hidden;
  display: none;
}

#tree-panel.active {
  display: block;
}

#tree-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Spindle panel (tree view only) ─────────── */

#spindle-panel {
  grid-column: 1 / -1;
  border-top: 1px solid #1a1a2e;
  max-height: 200px;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  display: none;
}

#spindle-panel.active {
  display: block;
}

.view-columns #spindle-panel { display: none !important; }

#spindle-panel h3 {
  font-size: 0.75rem;
  font-weight: 400;
  color: #d4a054;
  margin-bottom: 8px;
}

.spindle-entry {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 0.75rem;
  line-height: 1.5;
}

.spindle-pscale {
  color: #5a9bf5;
  font-weight: 500;
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.spindle-text {
  color: #c8c8d0;
}

/* ── Controls bar ───────────────────────────── */

#controls {
  grid-column: 1 / -1;
  grid-row: 2;
  border-top: 1px solid #1a1a2e;
  padding: 8px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.7rem;
  color: #666680;
}

#controls button {
  background: #12121e;
  border: 1px solid #2a2a3e;
  color: #888;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
}

#controls button:hover { border-color: #5a9bf5; color: #5a9bf5; }
#controls button.active { border-color: #d4a054; color: #d4a054; }

/* Hide tree-only controls in column view */
.view-columns #zoom-fit,
.view-columns #zoom-in,
.view-columns #zoom-out { display: none; }

#api-key-input {
  background: #12121e;
  border: 1px solid #2a2a3e;
  color: #c8c8d0;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 4px;
  width: 200px;
  outline: none;
}

#api-key-input:focus { border-color: #d4a054; }

.file-upload-label {
  background: #12121e;
  border: 1px solid #2a2a3e;
  color: #888;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-block;
}

.file-upload-label:hover { border-color: #d4a054; color: #d4a054; }

#file-upload, #transcript-upload { display: none; }

/* ── Column view (Gingko-style) ─────────────── */

#column-panel {
  grid-column: 2;
  grid-row: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

#column-panel.active { display: flex; }

.col-columns {
  display: flex;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
}

.col-column {
  min-width: 280px;
  max-width: 340px;
  border-right: 1px solid #1a1a2e;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.col-card {
  background: #12121e;
  border: 1px solid #1a1a2e;
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.col-card:hover {
  border-color: #3a3a5e;
}

.col-card.selected {
  border-color: #d4a054;
  background: #1a1820;
}

.col-card.selected .col-digit {
  color: #d4a054;
}

.col-card.selected .col-text {
  color: #d4a054;
}

.col-card.has-children .col-text::after {
  content: ' \2192';
  color: #444;
}

.col-card.selected.has-children .col-text::after {
  color: #8a6a2a;
}

.col-digit {
  color: #5a9bf5;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 14px;
  flex-shrink: 0;
  padding-top: 1px;
}

.col-text {
  font-size: 0.75rem;
  line-height: 1.5;
  color: #c8c8d0;
}

.col-edit {
  flex: 1;
  background: #0a0a0f;
  border: 1px solid #d4a054;
  color: #c8c8d0;
  font-family: inherit;
  font-size: 0.75rem;
  padding: 6px;
  border-radius: 3px;
  resize: vertical;
  outline: none;
  line-height: 1.5;
  min-height: 60px;
}

/* ── Converter modal ────────────────────────── */

#converter-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

#converter-modal.active { display: flex; }

.converter-content {
  background: #0a0a0f;
  border: 1px solid #1a1a2e;
  border-radius: 8px;
  width: 90vw;
  max-width: 900px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.converter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #1a1a2e;
}

.converter-header h2 {
  font-size: 0.85rem;
  font-weight: 500;
  color: #d4a054;
}

.converter-header button {
  background: none;
  border: none;
  color: #666;
  font-size: 1.2rem;
  cursor: pointer;
}

.converter-body {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  flex: 1;
  min-height: 0;
}

.converter-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.converter-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.converter-col-header label {
  font-size: 0.7rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.converter-col-header button {
  background: none;
  border: 1px solid #2a2a3e;
  color: #888;
  font-size: 0.85rem;
  padding: 1px 7px;
  border-radius: 3px;
  cursor: pointer;
  line-height: 1;
}

.converter-col-header button:hover { border-color: #d4a054; color: #d4a054; }

.converter-col textarea {
  flex: 1;
  background: #12121e;
  border: 1px solid #1a1a2e;
  color: #c8c8d0;
  font-family: inherit;
  font-size: 0.72rem;
  padding: 10px;
  border-radius: 4px;
  resize: none;
  outline: none;
  min-height: 200px;
}

.converter-col textarea:focus { border-color: #d4a054; }

.converter-col button,
.converter-actions button {
  background: #12121e;
  border: 1px solid #2a2a3e;
  color: #888;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.converter-col button:hover,
.converter-actions button:hover { border-color: #d4a054; color: #d4a054; }

.converter-actions {
  padding: 10px 16px;
  border-top: 1px solid #1a1a2e;
  display: flex;
  justify-content: center;
}

/* ── Scrollbar ──────────────────────────────── */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a3e; border-radius: 2px; }
