/* ======================================================
   TTS Studio — styles.css
   ====================================================== */
:root {
  --bg:        #07102a;
  --surface:   #0b1628;
  --card:      #0d1a30;
  --border:    rgba(255,255,255,0.06);
  --accent:    #60a5fa;
  --accent-dim:rgba(96,165,250,0.15);
  --green:     #34d399;
  --yellow:    #fbbf24;
  --red:       #f87171;
  --muted:     #8fa3b8;
  --text:      #deeaf6;
  --radius:    8px;
  --toolbar-h: 56px;
  --player-h:  68px;
  --sidebar-w: 210px;
}

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

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, #06101f 0%, #06162a 100%);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: opacity .15s, transform .1s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: default; }

select, input[type=text], textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
select { padding: 5px 8px; }

/* ===== Generic button styles ===== */
.btn {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,0.06); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-accent {
  background: var(--accent);
  color: #021428;
  border-color: transparent;
  font-weight: 600;
}
.btn-accent:hover:not(:disabled) { opacity: .88; }
.btn-green {
  background: rgba(52,211,153,.12);
  border-color: rgba(52,211,153,.25);
  color: var(--green);
}
.btn-green:hover:not(:disabled) { background: rgba(52,211,153,.22); }
.btn-record {
  background: rgba(248,113,113,.1);
  border-color: rgba(248,113,113,.25);
  color: #fca5a5;
}
.btn-record:hover:not(:disabled) { background: rgba(248,113,113,.18); }
.btn-record.recording {
  background: rgba(248,113,113,.3);
  border-color: rgba(248,113,113,.6);
  color: #fff1f2;
  font-weight: 700;
}
.btn-warn {
  background: rgba(251,191,36,.1);
  border-color: rgba(251,191,36,.25);
  color: var(--yellow);
}
.btn-warn:hover:not(:disabled) { background: rgba(251,191,36,.18); }

/* ===== Layout ===== */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--toolbar-h);
  padding: 0 18px;
  background: rgba(5,12,26,.92);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.brand { font-size: 16px; font-weight: 700; color: var(--accent); letter-spacing: .5px; white-space: nowrap; }
.toolbar-group { display: flex; align-items: center; gap: 6px; }
.toolbar-group label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.sel { max-width: 220px; }
.ml-auto { margin-left: auto; }
.chk-label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; cursor: pointer; }
.voice-preview-label {
  color: var(--muted);
  font-size: 12px;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-toolbar-recording {
  border-color: rgba(248,113,113,.6) !important;
  background: rgba(248,113,113,.3) !important;
  color: #fff1f2 !important;
  font-weight: 700;
}

.model-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.model-unknown  { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.08); color: var(--muted); }
.model-loading  { background: rgba(251,191,36,.1);  border-color: rgba(251,191,36,.2);  color: var(--yellow); }
.model-ready    { background: rgba(52,211,153,.1);  border-color: rgba(52,211,153,.2);  color: var(--green); }
.model-error    { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.2); color: var(--red); }

/* ===== Layout: sidebar + content ===== */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding-bottom: var(--player-h);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(255,255,255,.01);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px;
}
.sidebar-title { font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); padding: 0 6px 8px; }

.chap-item {
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  transition: background .12s, color .12s;
}
.chap-item:hover { background: rgba(255,255,255,.03); color: var(--text); }
.chap-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.chap-item .ci-sub { font-size: 11px; margin-top: 2px; opacity: .65; }

/* ===== Content area ===== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}
.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.chap-heading { font-size: 17px; font-weight: 700; color: var(--accent); flex: 1; }
.content-actions { display: flex; gap: 8px; }

/* ===== Track list ===== */
.tracks { display: flex; flex-direction: column; gap: 10px; }

.track {
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: start;
  transition: border-color .15s, box-shadow .15s;
}
.track.playing {
  border-color: rgba(96,165,250,.35);
  box-shadow: 0 0 0 1px rgba(96,165,250,.12), 0 6px 18px rgba(2,6,23,.5);
}
.track.generating {
  border-color: rgba(251,191,36,.3);
  box-shadow: 0 0 0 1px rgba(251,191,36,.1);
}
.track.gen-done {
  border-color: rgba(52,211,153,.3);
}
.track.gen-error {
  border-color: rgba(248,113,113,.3);
}

/* Line number / meta column */
.track-meta {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  padding-top: 2px;
}
.track-meta .line-no { font-size: 14px; font-weight: 700; color: var(--text); }
.track-meta .edit-badge {
  display: inline-block;
  font-size: 10px;
  background: rgba(251,191,36,.15);
  color: var(--yellow);
  border-radius: 4px;
  padding: 1px 4px;
  margin-top: 3px;
  white-space: nowrap;
}

/* Body column */
.track-body { min-width: 0; }

/* Line text area */
.line-display {
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 8px;
  color: var(--text);
  cursor: default;
}
.line-display.edited { color: var(--yellow); }

.line-editor {
  display: none;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(96,165,250,.25);
  color: var(--text);
  resize: vertical;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.55;
}
.line-editor.visible { display: block; }

/* Note area */
.note-row { display: flex; gap: 8px; align-items: flex-start; }
.note-area {
  flex: 1;
  min-height: 44px;
  padding: 7px 9px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
  color: var(--text);
  resize: vertical;
  font-size: 13px;
}
.note-area:focus { border-color: rgba(96,165,250,.3); outline: none; }
.note-area.has-note { border-color: rgba(96,165,250,.2); }

/* Actions column */
.track-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  min-width: 86px;
}
.track-actions button { width: 100%; text-align: center; }

/* Generation status badge under buttons */
.gen-status {
  font-size: 11px;
  min-height: 14px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 86px;
}
.gen-status.s-queued      { color: var(--muted); }
.gen-status.s-loading     { color: var(--yellow); }
.gen-status.s-generating  { color: var(--yellow); }
.gen-status.s-postprocessing { color: var(--yellow); }
.gen-status.s-done        { color: var(--green); }
.gen-status.s-error       { color: var(--red); }

/* ===== Floating player ===== */
.floating-player {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 1060px;
  height: var(--player-h);
  background: linear-gradient(180deg, #041428 0%, #071832 100%);
  border: 1px solid rgba(96,165,250,.1);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(2,6,23,.75);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 14px;
  z-index: 1200;
  backdrop-filter: blur(6px);
}

.fp-btn {
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.03);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 16px;
  transition: background .12s, color .12s, transform .1s;
}
.fp-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }
.fp-main {
  width: 52px;
  height: 52px;
  font-size: 20px;
  background: var(--accent);
  color: #031428;
  border: none;
  box-shadow: 0 6px 22px rgba(96,165,250,.2);
}
.fp-main:hover { opacity: .88; }
.fp-notes-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(167,139,250,.12);
  border: 1px solid rgba(167,139,250,.22);
}
.fp-note-btn {
  width: 34px;
  height: 34px;
  font-size: 12px;
  border-radius: 9px;
  color: #ddd6fe;
  border-color: rgba(167,139,250,.3);
  background: rgba(167,139,250,.1);
}
.fp-note-btn:hover {
  background: rgba(167,139,250,.2);
  color: #ede9fe;
}
.fp-notes-counter {
  font-size: 12px;
  font-weight: 700;
  color: #ddd6fe;
  min-width: 56px;
  text-align: center;
}
.fp-exit-note { white-space: nowrap; }
.fp-info {
  margin-left: 8px;
  overflow: hidden;
  flex: 1;
}
#nowPlaying {
  font-size: 13px;
  font-weight: 600;
  color: #cfe8ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* ===== Modal / overlay ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.72);
  z-index: 2000;
  backdrop-filter: blur(3px);
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2100;
  background: #0b1628;
  border: 1px solid rgba(96,165,250,.15);
  border-radius: 12px;
  padding: 24px;
  width: min(480px, calc(100vw - 32px));
  box-shadow: 0 24px 60px rgba(2,6,23,.8);
}
.modal h3 { font-size: 15px; margin-bottom: 8px; }
.modal p  { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.drop-zone {
  border: 2px dashed rgba(96,165,250,.25);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: rgba(96,165,250,.06); color: var(--text); }
.drop-zone.has-file { border-color: var(--green); background: rgba(52,211,153,.05); color: var(--green); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.progress-bar { height: 6px; background: rgba(255,255,255,.06); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 99px; width: 0; transition: width .2s; }

/* ===== Notes-review mode ===== */
.btn-notes {
  background: rgba(167,139,250,.12);
  border-color: rgba(167,139,250,.25);
  color: #c4b5fd;
}
.btn-notes:hover:not(:disabled) { background: rgba(167,139,250,.22); }
.btn-notes.active {
  background: rgba(167,139,250,.28);
  border-color: rgba(167,139,250,.5);
  color: #ede9fe;
  font-weight: 600;
}

.notes-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: rgba(167,139,250,.07);
  border: 1px solid rgba(167,139,250,.18);
  border-radius: var(--radius);
}
.notes-counter {
  font-size: 13px;
  font-weight: 600;
  color: #c4b5fd;
  min-width: 52px;
  text-align: center;
}

/* Highlighted track when navigating noted lines */
.track.notes-focus {
  border-color: rgba(167,139,250,.55) !important;
  box-shadow: 0 0 0 2px rgba(167,139,250,.18), 0 6px 20px rgba(2,6,23,.5);
}

/* ===== Loading indicator ===== */
.loading-msg { color: var(--muted); padding: 24px; text-align: center; font-size: 14px; }

/* ===== Utility ===== */
.hidden { display: none !important; }

@media (max-width: 720px) {
  :root { --sidebar-w: 0; }
  .sidebar { display: none; }
  .track { grid-template-columns: 44px 1fr; }
  .track-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .track-actions button { width: auto; flex: 1; }
  .fp-notes-controls { gap: 4px; padding: 3px 5px; }
  .fp-exit-note { display: none; }
}
