:root {
  /* Warna Permukaan & Teks */
  --bg-app: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-hover: #E2E8F0;
  --bg-player: #0F172A;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-on-accent: #FFFFFF;

  /* Warna Aksen & Semantik */
  --accent-primary: #1D4ED8;
  --accent-hover: #1E40AF;
  --accent-soft: #EFF6FF;
  --accent-border: #BFDBFE;

  --status-success: #15803D;
  --status-success-bg: #DCFCE7;
  --status-warning: #B45309;
  --status-warning-bg: #FEF3C7;
  --status-error: #B91C1C;
  --status-error-bg: #FEE2E2;
  --status-neutral: #475569;
  --status-neutral-bg: #F1F5F9;

  /* Garis Batas */
  --border-default: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-focus: #1D4ED8;

  /* Tipografi */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;

  /* Radius & Bayangan Minimalis */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-modal: 0 12px 32px -8px rgba(15, 23, 42, 0.18);

  /* Spasi & Dimensi Layout */
  --topbar-height: 56px;
  --panel-gap: 12px;
  --sidebar-width: 390px;
  --timeline-height: 280px;
  --z-dropdown: 40;
  --z-modal: 60;
  --z-toast: 80;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.badge-nowrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.2;
}

.badge-neutral {
  background: var(--status-neutral-bg);
  color: var(--status-neutral);
}

.badge-success {
  background: var(--status-success-bg);
  color: var(--status-success);
}

.badge-warning {
  background: var(--status-warning-bg);
  color: var(--status-warning);
}

.badge-error {
  background: var(--status-error-bg);
  color: var(--status-error);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-primary);
}

/* Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: var(--text-xs);
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-on-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--status-error);
  color: var(--text-on-accent);
}

.btn-danger:hover:not(:disabled) {
  background: #991B1B;
}

.btn-danger-outline {
  background: var(--bg-card);
  color: var(--status-error);
  border-color: var(--border-default);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--status-error-bg);
  border-color: #FECACA;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
}

.input-control,
.select-control,
.textarea-control {
  width: 100%;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-sm);
  padding: 7px 10px;
  outline: none;
}

.input-control,
.select-control {
  height: 36px;
}

.textarea-control {
  resize: vertical;
  min-height: 62px;
  line-height: 1.45;
}

.input-control:focus,
.select-control:focus,
.textarea-control:focus {
  border-color: var(--border-focus);
}

.range-control {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

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

.text-muted-sm {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-app);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: var(--text-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
}

.login-subtitle {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap .input-control {
  padding-right: 38px;
}

.icon-btn-inline {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn-inline:hover {
  color: var(--text-primary);
}

.inline-error {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--status-error);
  background: var(--status-error-bg);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

/* Studio Layout */
.studio-shell {
  display: grid;
  grid-template-rows: var(--topbar-height) 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text-primary);
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-default);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-mark-sm {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  color: var(--text-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.select-project {
  min-width: 200px;
  max-width: 280px;
  font-weight: 600;
}

/* Dropdown */
.dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 6px;
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--bg-subtle);
}

.dropdown-danger {
  color: var(--status-error);
}

.dropdown-danger:hover {
  background: var(--status-error-bg);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-default);
  margin: 4px 0;
}

/* Body Grid */
.studio-body {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: var(--panel-gap);
  padding: var(--panel-gap);
  min-height: 0;
}

.studio-main {
  display: grid;
  grid-template-rows: 1fr var(--timeline-height);
  gap: var(--panel-gap);
  min-width: 0;
  min-height: 0;
}

.preview-ai-split {
  display: grid;
  grid-template-columns: minmax(340px, 1.15fr) minmax(300px, 0.85fr);
  gap: var(--panel-gap);
  min-height: 0;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}

.section-title {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

/* Sidebar */
.sidebar-panel {
  overflow-y: auto;
  padding: 14px;
  gap: 18px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-default);
}

.sidebar-section:last-child {
  border-bottom: none;
  padding-bottom: 4px;
}

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

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.dropzone-sm {
  padding: 10px 12px;
}

.dropzone-text {
  margin: 0;
  font-size: var(--text-xs);
  line-height: 1.4;
}

.clip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clip-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.clip-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-player);
}

.clip-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.clip-name {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clip-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.clip-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}

.clip-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.style-ref-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.style-ref-img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-subtle);
  flex-shrink: 0;
}

.style-ref-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Player */
.tab-pills {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.tab-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-pill.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.player-stage {
  flex: 1;
  min-height: 0;
  background: var(--bg-player);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.video-element {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-card);
  flex-shrink: 0;
}

.timecode {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.seek-bar {
  flex: 1;
}

.render-progress {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border-default);
  background: var(--accent-soft);
  flex-shrink: 0;
}

.progress-text-row {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 5px;
}

.progress-track {
  height: 6px;
  background: var(--accent-border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-primary);
  transition: width 0.2s ease;
}

/* AI Panel */
.ai-explanation-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
}

.ai-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-note-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 10px 12px;
}

.ai-note-card h3 {
  margin: 0 0 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-secondary);
}

.ai-note-card p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.45;
}

.ai-revise-box {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* Timeline */
.timeline-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 14px;
}

.segments-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  height: 100%;
  align-items: stretch;
}

.segment-card {
  width: 268px;
  flex-shrink: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.segment-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.segment-clip-name {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.segment-order-btns {
  display: flex;
  align-items: center;
  gap: 3px;
}

.icon-square-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-square-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-square-btn.danger:hover:not(:disabled) {
  background: var(--status-error-bg);
  color: var(--status-error);
}

.seg-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.seg-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.seg-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.seg-field label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.seg-field input,
.seg-field select {
  height: 28px;
  padding: 2px 6px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-xs);
}

.opening-title-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.subtitles-table-wrap {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.subtitles-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

.subtitles-table th {
  text-align: left;
  padding: 7px 10px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-default);
  font-weight: 600;
}

.subtitles-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-default);
}

.subtitles-table tr:last-child td {
  border-bottom: none;
}

.subtitles-table input {
  width: 100%;
  height: 28px;
  padding: 2px 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-family: inherit;
  font-size: var(--text-xs);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px 16px;
  color: var(--text-muted);
  gap: 6px;
  height: 100%;
}

.empty-state-dark {
  color: #94A3B8;
}

.empty-title {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: inherit;
}

.empty-desc {
  margin: 0;
  font-size: var(--text-xs);
  max-width: 320px;
  line-height: 1.45;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: var(--z-modal);
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-default);
}

.modal-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
}

.modal-body {
  padding: 16px 18px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-subtle);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-toast);
  max-width: 360px;
}

.toast-item {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.toast-success { border-left-color: var(--status-success); }
.toast-warning { border-left-color: var(--status-warning); }
.toast-error { border-left-color: var(--status-error); }
.toast-info { border-left-color: var(--accent-primary); }

.toast-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

/* Responsive < 1280px */
@media (max-width: 1279px) {
  :root {
    --sidebar-width: 340px;
    --timeline-height: 250px;
  }
  .select-project {
    min-width: 160px;
    max-width: 210px;
  }
}

/* Responsive < 1024px */
@media (max-width: 1023px) {
  .studio-shell {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }
  .studio-body {
    grid-template-columns: 1fr;
  }
  .sidebar-panel {
    order: 3;
    overflow-y: visible;
  }
  .studio-main {
    order: 1;
    grid-template-rows: auto auto;
  }
  .preview-ai-split {
    grid-template-columns: 1fr;
  }
  .player-stage {
    min-height: 300px;
  }
  .timeline-panel {
    min-height: 280px;
  }
}
