:root {
  --bg: #eeece2;
  --fg: #3d3929;
  --muted: #6a6558;
  --accent: #141413;
  --border: #e8e6dc;
  --panel: #fff;
  --lane: #f5f4ef;
}
* { box-sizing: border-box; }
body.ab-body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 "Lora", Georgia, serif;
}
.ab-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.ab-header h1 {
  margin: 0;
  font: 600 1.1rem "Poppins", sans-serif;
  color: var(--accent);
}
.ab-creds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
}
.ab-creds input {
  width: 140px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ab-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: calc(100vh - 120px);
}
.ab-sidebar, .ab-inspector {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow: auto;
}
.ab-inspector {
  border-right: none;
  border-left: 1px solid var(--border);
}
body.ab-body .ab-layout .ab-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  gap: 0;
}
.ab-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.ab-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.ab-toolbar input, .ab-toolbar textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
}
.ab-toolbar textarea {
  flex: 1 1 360px;
  width: auto !important;
  min-width: 260px;
  height: 42px !important;
  min-height: 42px !important;
  max-height: 90px;
}
#timeline-wrap {
  flex: 1;
  overflow: auto;
  background: #e8e6dc;
  padding: 8px;
}
#timeline-tracks { position: relative; min-height: 200px; }
.tl-track-tools {
  position: sticky;
  left: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.tl-ruler {
  position: relative;
  height: 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.tl-tick {
  position: absolute;
  top: 4px;
  font-size: 0.7rem;
  color: var(--muted);
  transform: translateX(-50%);
}
.tl-track-row {
  display: flex;
  margin-bottom: 6px;
  min-height: 52px;
}
.tl-track-label {
  width: 130px;
  flex-shrink: 0;
  padding: 8px 6px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px 0 0 8px;
  cursor: pointer;
}
.tl-track-label.active {
  border-color: var(--accent);
  background: #f5f5f2;
}
.tl-track-name,
.tl-track-meta {
  display: block;
}
.tl-track-name {
  font-weight: 700;
}
.tl-track-meta {
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--muted);
}
.tl-lane {
  position: relative;
  flex: 1;
  min-height: 52px;
  background: var(--lane);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
}
.tl-clip {
  position: absolute;
  top: 6px;
  height: 40px;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: grab;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.12);
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.tl-clip-dialogue { background: #d4e4f7; }
.tl-clip-bgm { background: #e8d4f0; }
.tl-clip-sfx { background: #f5e6c8; }
.tl-clip-silence { background: #ddd; border-style: dashed; }
.tl-clip.selected { outline: 2px solid var(--accent); }
.tl-clip-status { font-size: 0.65rem; opacity: 0.7; }
.tl-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  background: rgba(0,0,0,0.08);
}
.char-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
}
.char-item.active { border-color: var(--accent); background: #f5f5f2; }
.char-name { font-weight: 600; }
.char-meta { font-size: 0.8rem; color: var(--muted); }
.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font: 600 0.85rem "Poppins", sans-serif;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: #fff; color: var(--fg); border: 1px solid var(--border); }
.btn.danger { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.hint { color: var(--muted); font-size: 0.85rem; }
.hint.error { color: #9f1239; }
label { display: block; margin: 8px 0 4px; font-size: 0.82rem; font-weight: 600; }
label input, label textarea, label select {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
.voice-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.voice-chip {
  border: 1px solid var(--border);
  background: #fafaf8;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.8rem;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-overlay.hidden { display: none; }
.modal-panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  width: min(560px, 100%);
  max-height: 80vh;
  overflow: auto;
}
.modal-panel textarea,
.modal-panel input,
.modal-panel select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fafaf8;
  color: var(--fg);
}
.modal-panel textarea {
  min-height: 120px;
  resize: vertical;
}
.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.sfx-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px;
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafaf8;
  cursor: pointer;
}
.seg-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 0.85rem;
}
.hidden { display: none !important; }
#api-status { font-size: 0.8rem; color: var(--muted); }
@media (max-width: 960px) {
  .ab-layout { grid-template-columns: 1fr; }
  .ab-sidebar, .ab-inspector { border: none; border-bottom: 1px solid var(--border); }
}
