* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Nanum Myeongjo", serif;
  background-color: #0f1015;
  color: #e2e8f0;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Left Preview Section */
.left-panel {
  flex: 1.25;
  display: flex;
  flex-direction: column;
  background-color: #141721;
  border-right: 1px solid #232838;
  padding: 16px 20px;
  gap: 12px;
  min-width: 600px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #f8fafc;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guide-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}

.guide-toggle input {
  accent-color: #38bdf8;
  cursor: pointer;
}

.badge {
  background-color: #2b3245;
  color: #93c5fd;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000000;
  border: 1px solid #2a3044;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  position: relative;
  user-select: none;
  min-height: 280px;
}

/* Translucent Drag Hint Overlay inside Preview Window */
.canvas-inner-hint {
  position: absolute;
  top: 14px;
  left: 14px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(18, 22, 33, 0.75);
  backdrop-filter: blur(4px);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 10;
  letter-spacing: -0.2px;
  user-select: none;
}

#previewCanvas {
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000;
  display: block;
  cursor: default;
}

#previewCanvas.dragging {
  cursor: grabbing !important;
}

#previewCanvas.hover-item {
  cursor: grab;
}

/* Waveform Visualizer */
.waveform-container {
  background: #171b26;
  border: 1px solid #262c3f;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.waveform-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.waveform-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.track-label {
  color: #93c5fd;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}

.badge-mini {
  background: #1e293b;
  border: 1px solid #38bdf8;
  color: #38bdf8;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
}

.fade-label {
  color: #fbbf24;
  font-family: monospace;
}

.waveform-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 48px;
  background: #0d1017;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
}

#waveformCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.waveform-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0%;
  width: 2px;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  pointer-events: none;
  transition: left 0.05s linear;
}

/* Playback & Export Controls */
.playback-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1b1f2e;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #2a3044;
}

#timeScrubber {
  flex: 1;
  cursor: pointer;
  accent-color: #3b82f6;
}

#timeDisplay {
  font-family: monospace;
  font-size: 0.88rem;
  color: #94a3b8;
  min-width: 125px;
}

.export-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Seed Control in Export Bar */
.seed-control-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #171b26;
  border: 1px solid #2b3245;
  border-radius: 6px;
  padding: 5px 10px;
}

.seed-control-group .seed-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

.seed-control-group input {
  width: 75px;
  background: transparent;
  border: none;
  outline: none;
  color: #38bdf8;
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0;
}

.seed-control-group input::-webkit-inner-spin-button,
.seed-control-group input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.seed-control-group input[type=number] {
  -moz-appearance: textfield;
}

/* Right Panel */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #12141c;
  padding: 16px 20px;
  overflow-y: auto;
  gap: 16px;
}

.settings-group {
  background: #171b26;
  border: 1px solid #252b3d;
  border-radius: 8px;
  padding: 12px 16px;
}

.settings-group h3, .editor-header h3 {
  font-size: 0.92rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.audio-grid {
  grid-template-columns: repeat(4, 1fr);
}

.col-span-2 {
  grid-column: span 2;
}

.label-with-val {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.val-badge {
  color: #38bdf8;
  font-weight: 700;
  font-family: monospace;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.76rem;
  color: #94a3b8;
}

.settings-grid input, .select-input {
  background: #0d1017;
  border: 1px solid #2b3245;
  border-radius: 4px;
  padding: 6px 8px;
  color: #fff;
  font-size: 0.86rem;
  font-family: inherit;
}

.range-slider {
  accent-color: #38bdf8;
  cursor: pointer;
  padding: 4px 0 !important;
  background: transparent !important;
  border: none !important;
}

.select-input option {
  background: #141721;
  color: #fff;
}

.editor-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #171b26;
  border: 1px solid #252b3d;
  border-radius: 8px;
  padding: 12px 16px;
  gap: 10px;
  min-height: 380px;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-tip {
  font-size: 0.76rem;
  color: #64748b;
  line-height: 1.45;
  background: #0e121a;
  padding: 8px 12px;
  border-radius: 6px;
}

.editor-tip code {
  color: #93c5fd;
  background: #1a2233;
  padding: 2px 4px;
  border-radius: 3px;
}

.sentence-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.sentence-card {
  background: #0e111a;
  border: 1px solid #212739;
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sentence-card-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 600;
  color: #64748b;
}

.sentence-card textarea {
  width: 100%;
  background: #151924;
  border: 1px solid #262e43;
  border-radius: 4px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 6px 8px;
  resize: vertical;
  min-height: 44px;
}

/* Buttons */
.btn {
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn.primary {
  background: #3b82f6;
  color: #fff;
}
.btn.primary:hover {
  background: #2563eb;
}

.btn.secondary {
  background: #242b3b;
  color: #cbd5e1;
}
.btn.secondary:hover {
  background: #333d52;
}

.btn.accent {
  background: #10b981;
  color: #fff;
  margin-left: auto;
}
.btn.accent:hover {
  background: #059669;
}

.btn.small {
  padding: 4px 8px;
  font-size: 0.75rem;
  background: #262c3e;
  color: #94a3b8;
}

/* Progress bar */
.progress-bar {
  flex: 1;
  position: relative;
  background: #202636;
  height: 34px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #10b981);
  transition: width 0.1s linear;
}

#exportProgressText {
  position: relative;
  z-index: 1;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
}

.hidden {
  display: none !important;
}

/* Dual Tabs Header */
.panel-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #232838;
  padding-bottom: 12px;
  margin-bottom: 4px;
}

.tab-btn {
  background: #171b26;
  border: 1px solid #283044;
  color: #94a3b8;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab-btn:hover {
  color: #f1f5f9;
  background: #1e2433;
  border-color: #3b455e;
}

.tab-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.tab-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-pane.hidden {
  display: none !important;
}

.group-header-with-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.group-header-with-badge h3 {
  margin-bottom: 0 !important;
}

.val-badge.blue {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #e2e8f0;
  font-size: 0.9rem;
  font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #3b82f6;
}

.string-feature-list {
  padding-left: 20px;
  margin: 0;
  color: #94a3b8;
  font-size: 0.82rem;
  line-height: 1.6;
}

.string-feature-list li {
  margin-bottom: 8px;
}

.string-feature-list strong {
  color: #cbd5e1;
}

/* Color Ramp Gradation Editor */
.color-ramp-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #171b26;
  border: 1px solid #283044;
  border-radius: 8px;
  padding: 14px 14px 10px 14px;
}

.color-ramp-track-container {
  position: relative;
  width: 100%;
  height: 52px;
  user-select: none;
}

.color-ramp-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  cursor: crosshair;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.3);
}

.color-ramp-markers {
  position: absolute;
  top: 22px;
  left: 0;
  right: 0;
  height: 30px;
  pointer-events: none;
}

.color-ramp-marker {
  position: absolute;
  top: 3px;
  transform: translateX(-50%);
  width: 20px;
  height: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  transition: transform 0.08s ease, opacity 0.15s ease, filter 0.15s ease;
}

.color-ramp-marker:active {
  cursor: grabbing;
}

.color-ramp-marker.dragging-out {
  opacity: 0.35;
  transform: translateX(-50%) scale(0.78);
  filter: drop-shadow(0 0 8px #ef4444) saturate(2);
}

.color-ramp-marker.dragging-out .marker-arrow {
  border-bottom-color: #ef4444;
}

.color-ramp-marker.dragging-out .marker-thumb {
  border-color: #ef4444;
}

.marker-arrow {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid #ffffff;
  margin-bottom: -1px;
}

.marker-thumb {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.marker-color-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.color-ramp-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.74rem;
  color: #8a94a6;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 8px;
  line-height: 1.4;
}

.color-ramp-hint span {
  display: inline-block;
}

/* Export Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal-dialog {
  background: #141721;
  border: 1px solid #283044;
  border-radius: 12px;
  width: 520px;
  max-width: 92vw;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #232838;
}

.modal-header h3 {
  font-size: 1.05rem;
  color: #f8fafc;
  margin: 0;
  font-weight: 600;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.15s ease;
}

.modal-close-btn:hover {
  color: #ffffff;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-section h4 {
  font-size: 0.9rem;
  color: #cbd5e1;
  margin-bottom: 10px;
  font-weight: 600;
}

.export-layer-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layer-radio-card, .audio-checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #1b202e;
  border: 1px solid #2c354a;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.layer-radio-card:hover, .audio-checkbox-card:hover {
  background: #232a3d;
  border-color: #3b82f6;
}

.layer-radio-card input, .audio-checkbox-card input {
  margin-top: 3px;
  accent-color: #3b82f6;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.layer-info strong, .audio-info strong {
  display: block;
  font-size: 0.88rem;
  color: #f1f5f9;
  margin-bottom: 3px;
}

.layer-info p, .audio-info p {
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.4;
  margin: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid #232838;
  background: #10131c;
}


/* Share Button & Modal Styles */
.btn-share {
  background: #1e293b;
  border: 1px solid #3b82f6;
  color: #60a5fa;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-share:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

.share-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.share-url-input {
  flex: 1;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #38bdf8;
  font-family: monospace;
  outline: none;
  user-select: all;
}

.share-url-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

.share-copy-alert {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  border-radius: 6px;
  color: #34d399;
  font-size: 0.8rem;
  font-weight: 500;
  animation: modalFadeIn 0.2s ease-out;
}

.share-copy-alert.hidden {
  display: none;
}

/* Direction Switch Control */
.direction-setting-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #232838;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-row-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.segmented-control {
  display: flex;
  background: #0f131d;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #283044;
  gap: 4px;
}

.segment-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.segment-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.05);
}

.segment-btn.active {
  background: #3b82f6;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.segment-btn svg {
  flex-shrink: 0;
}
