* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f8f6ef 0%, #ece7d7 100%);
  color: #1f1c16;
}

button,
input {
  font: inherit;
}

select,
input[type="number"] {
  font: inherit;
}

button {
  border: 1px solid #1f1c16;
  background: #f7f1e1;
  color: #1f1c16;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #1f1c16;
  background: #f7f1e1;
  color: #1f1c16;
  padding: 0.65rem 0.9rem;
  text-decoration: none;
}

input[type="text"],
input[type="password"],
input[type="file"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid #7f7662;
  background: #fffdfa;
  padding: 0.7rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-card,
.card {
  background: rgba(255, 252, 245, 0.86);
  border: 1px solid #c9baa2;
  box-shadow: 0 16px 40px rgba(66, 51, 22, 0.08);
}

.login-card {
  width: min(420px, 100%);
  padding: 2rem;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
}

.topbar,
.statusbar,
.steps,
.panel {
  padding-left: min(3vw, 1.5rem);
  padding-right: min(3vw, 1.5rem);
}

.topbar,
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 1rem;
}

.step {
  min-width: 8rem;
}

.step.active {
  background: #1f1c16;
  color: #f7f1e1;
}

.step.disabled {
  border-style: dashed;
}

.panel {
  padding-bottom: 1.5rem;
}

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  padding: 1rem;
}

.stack {
  display: grid;
  gap: 0.85rem;
}

.subtle {
  color: #6e6656;
}

.error-text {
  color: #8f1c1c;
  margin: 0;
}

.project-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  border-top: 1px solid #ddd3c0;
  padding-top: 0.75rem;
}

.project-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.project-row-current {
  padding: 0.85rem;
  border: 1px solid #c9baa2;
  background: rgba(247, 241, 225, 0.7);
}

.project-meta {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.project-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.project-library-controls {
  margin-bottom: 0.4rem;
}

.project-library-filter-row {
  align-items: end;
}

.project-search-field {
  min-width: 220px;
}

.project-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.project-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #c9baa2;
  background: #fffdfa;
  color: #6e6656;
  font-size: 0.84rem;
}

.project-badge-archived {
  border-color: #8f1c1c;
  color: #8f1c1c;
}

.project-badge-ready {
  border-color: #2d6a4f;
  color: #2d6a4f;
}

.project-badge-warning {
  border-color: #a66d1d;
  color: #8c5a13;
}

.project-badge-danger {
  border-color: #8f1c1c;
  color: #8f1c1c;
}

.project-row-summary {
  display: grid;
  gap: 0.2rem;
}

.danger {
  border-color: #8f1c1c;
  color: #8f1c1c;
}

.lock-banner {
  margin: 0 1.5rem 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid #a88534;
  background: #f6ebc7;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.divider {
  height: 1px;
  background: #d9cfbe;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.summary-grid div {
  display: grid;
  gap: 0.25rem;
  border: 1px solid #ddd3c0;
  padding: 0.75rem;
  background: #fffdfa;
}

.sync-grid {
  align-items: start;
}

.sync-reference-grid {
  align-items: start;
}

.sync-reference-card {
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid rgba(124, 58, 237, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 247, 255, 0.96) 100%);
  box-shadow: 0 10px 30px rgba(79, 70, 229, 0.08);
}

.sync-reference-label {
  display: block;
  color: #1e1b4b;
  font-weight: 700;
  font-size: 15px;
}

.sync-waveform-host,
.sync-segment-waveform {
  overflow: hidden;
  position: relative;
  background: white;
  border-radius: 12px;
  padding: 6px 0;
  border: 1px solid rgba(124, 58, 237, 0.16);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.04);
}

.sync-selected-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7), 0 0 10px rgba(239, 68, 68, 0.28);
  pointer-events: none;
  z-index: 7;
}

.sync-waveform-host {
  min-height: 96px;
  margin-top: 0.2rem;
}

.sync-waveform-host[data-editable='false'],
.sync-segment-waveform[data-editable='false'] {
  cursor: default;
}

.sync-segment-waveform {
  display: none;
  min-height: 180px;
  margin-top: 8px;
}

.sync-waveform-host canvas,
.sync-waveform-host .wavesurfer-canvas,
.sync-segment-waveform canvas,
.sync-segment-waveform .wavesurfer-canvas {
  display: block;
}

.video-wave-audio {
  display: none;
}

.video-zoom-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.video-zoom-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1.5px solid #a78bfa;
  background: white;
  color: #7c3aed;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.video-zoom-btn:hover {
  background: rgba(124, 58, 237, 0.06);
}

.video-zoom-label {
  color: #6b7280;
  font-size: 12px;
  margin-left: 4px;
  font-weight: 500;
}

.wave-play-btn,
.seg-play-btn {
  padding: 6px 16px;
  border-radius: 8px;
  background: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
  flex-shrink: 0;
}

.wave-play-btn {
  border: 1.5px solid #a78bfa;
  color: #7c3aed;
}

.wave-play-btn:hover {
  background: rgba(124, 58, 237, 0.06);
}

.wave-play-btn.playing {
  background: #7c3aed;
  color: white;
}

.seg-play-btn {
  display: none;
  border: 1.5px solid #0d9488;
  color: #0d9488;
}

.seg-play-btn:hover {
  background: rgba(13, 148, 136, 0.06);
}

.seg-play-btn.playing {
  background: #0d9488;
  color: white;
}

.video-wave-time-row,
.sync-segment-time-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #4b5563;
  margin-top: 10px;
  font-weight: 500;
  flex-wrap: wrap;
}

.sync-segment-time-row {
  display: none;
  margin-top: 8px;
  gap: 10px;
}

.video-wave-range {
  width: 100%;
  margin-top: 8px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #e5e7eb;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.video-wave-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #7c3aed;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

.beat-ms-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.beat-ms-row label {
  font-weight: 700;
  color: #1e1b4b;
  font-size: 14px;
}

.beat-ms-row input[type="number"] {
  flex: 1;
  min-width: 120px;
  padding: 10px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 15px;
  background: white;
}

.beat-ms-row input[type="number"]:focus,
.seg-picker-controls input[type="number"]:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.wave-hint {
  color: #6b7280;
  font-size: 11px;
  line-height: 1.5;
}

.seg-picker-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.seg-picker-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.seg-picker-controls label {
  font-size: 13px;
  color: #4b5563;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.seg-picker-controls input[type="number"] {
  width: 72px;
  padding: 7px 10px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.btn-show-seg {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-show-seg:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.seg-status {
  font-size: 12px;
  color: #7c3aed;
  font-weight: 500;
}

.seg-status.err {
  color: #8f1c1c;
}

.waveform-canvas {
  display: block;
  width: 100%;
  height: 160px;
  border: 1px solid #ddd3c0;
  background: #fffdfa;
  cursor: crosshair;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.scene-card {
  border: 1px solid #ddd3c0;
  background: #fffdfa;
  padding: 0.85rem;
  display: grid;
  gap: 0.75rem;
}

.scene-card-active {
  border-color: #1f1c16;
  box-shadow: inset 0 0 0 1px rgba(31, 28, 22, 0.12);
}

.scene-card-meta {
  display: grid;
  gap: 0.25rem;
}

.scene-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.scene-video {
  width: 100%;
  max-height: 56vh;
  background: #15120d;
  border: 1px solid #ddd3c0;
}

.preview-video {
  cursor: pointer;
}

.trim-fields-grid {
  align-items: start;
}

.handle-toggle-active {
  background: #1f1c16;
  color: #f7f1e1;
}

audio {
  width: 100%;
}

#preview-current-time-label,
#preview-duration-label {
  min-width: 6rem;
}

@media (max-width: 720px) {
  .project-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar,
  .statusbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .video-wave-time-row,
  .sync-segment-time-row,
  .beat-ms-row,
  .seg-picker-controls {
    flex-direction: column;
    align-items: flex-start;
  }
}
