:root {
  --bg: #0b0d12;
  --surface: #131722;
  --surface-2: #1a2030;
  --surface-3: #232b40;
  --border: #263046;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #ff4d5a;
  --accent-hover: #ff3342;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --success-hover: #16a34a;
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.muted {
  color: var(--text-muted);
  font-weight: 400;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  border-radius: 7px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.meta-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

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

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.08s;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn-lg {
  padding: 12px 22px;
  font-size: 0.98rem;
  border-radius: 10px;
}

.btn-sm {
  padding: 5px 9px;
  font-size: 0.78rem;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-secondary {
  background: var(--surface-3);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #2d3752;
}

.btn-primary {
  background: var(--primary);
}

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

.btn-accent,
.btn-record {
  background: var(--accent);
  color: #fff;
}

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

.btn-record {
  padding: 9px 16px;
  font-size: 0.92rem;
  box-shadow: 0 4px 16px rgba(255, 77, 90, 0.32);
}

.btn-success {
  background: var(--success);
  color: #052e16;
}

.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
  color: #fff;
}

.btn-danger-text {
  color: #fda4af;
}

.btn-danger-text:hover:not(:disabled) {
  border-color: rgba(255, 77, 90, 0.5);
  background: rgba(255, 77, 90, 0.12);
}

.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.count-pill {
  background: rgba(255, 255, 255, 0.18);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.lang-picker select,
.mini-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}

/* Workspace Layout */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Video Stage Column */
.stage-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #06080c;
  border-right: 1px solid var(--border);
}

.video-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow: hidden;
}

.video-stage.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
  background: rgba(255, 77, 90, 0.06);
}

.video-el {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  background: #000;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

/* Dropzone */
.dropzone {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dropzone-card {
  max-width: 460px;
  text-align: center;
  padding: 36px 28px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px dashed var(--border);
}

.dropzone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border-radius: 16px;
  background: rgba(255, 77, 90, 0.12);
  color: var(--accent);
  margin-bottom: 14px;
}

.dropzone-card h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.dropzone-card p {
  margin: 0 0 22px;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.shortcut-hints {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
}

/* Player Controls */
.player-controls {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px 14px;
  flex-shrink: 0;
}

.player-controls.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.timeline-wrap {
  padding: 6px 0 12px;
}

.timeline-track {
  position: relative;
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  cursor: pointer;
  touch-action: none;
}

.timeline-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 999px;
  pointer-events: none;
}

.timeline-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.timeline-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.timeline-pin {
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  transform: translate(-50%, -50%);
  cursor: pointer;
  pointer-events: auto;
  z-index: 2;
  transition: transform 0.12s;
}

.timeline-pin:hover {
  transform: translate(-50%, -50%) scale(1.35);
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.transport-group,
.right-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-3);
}

.timecode {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  min-height: 0;
  overflow: hidden;
}

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

.sidebar-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title-row h2 {
  margin: 0;
  font-size: 0.96rem;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notes-empty {
  text-align: center;
  padding: 40px 18px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.notes-empty p {
  margin: 0 0 6px;
  color: var(--text);
  font-weight: 600;
}

.note-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.note-card:hover {
  border-color: #3b4b6b;
}

.note-top {
  display: flex;
  gap: 10px;
  padding: 10px;
}

.note-thumb-btn {
  position: relative;
  flex-shrink: 0;
  width: 108px;
  height: 68px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  padding: 0;
  cursor: pointer;
}

.note-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.note-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.note-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.time-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.time-pill:hover {
  background: rgba(59, 130, 246, 0.32);
}

.tag-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
}

.note-text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.note-text.empty-note {
  color: var(--text-muted);
  font-style: italic;
}

.note-card-actions {
  display: flex;
  gap: 4px;
}

.tiny-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 0.76rem;
}

.tiny-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.tiny-btn.delete:hover {
  color: #fda4af;
  background: rgba(255, 77, 90, 0.14);
}

/* Capture & Annotate Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.84);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-panel {
  width: min(1140px, 100%);
  max-height: calc(100dvh - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-group h2 {
  margin: 0;
  font-size: 1rem;
}

.modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr);
  min-height: 0;
  overflow-y: auto;
}

.canvas-column {
  display: flex;
  flex-direction: column;
  background: #06080c;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.canvas-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 240px;
  max-height: 62dvh;
}

.annotate-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.55);
}

.draw-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tool-group,
.color-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
}

.tool-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

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

.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-dot.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--c);
}

/* Voice Column */
.voice-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.tag-chip.active {
  background: rgba(59, 130, 246, 0.22);
  border-color: var(--primary);
  color: #bfdbfe;
}

.mic-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.mic-banner.listening {
  background: rgba(255, 77, 90, 0.16);
  border-color: var(--accent);
  color: #fecdd3;
}

.mic-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.mic-banner.listening .mic-pulse {
  background: var(--accent);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 90, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(255, 77, 90, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 90, 0); }
}

.speech-notice {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.35);
  color: #fde68a;
  line-height: 1.4;
}

.transcript-label {
  font-size: 0.82rem;
  font-weight: 600;
}

.transcript-input {
  width: 100%;
  flex: 1;
  min-height: 120px;
  resize: vertical;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
}

.transcript-input:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 200;
}

/* Responsive: Android & Narrow Screens */
@media (max-width: 920px) {
  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .meta-badge {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .stage-column {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .video-stage {
    height: min(52dvh, 420px);
    padding: 8px;
  }

  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .transport-group {
    justify-content: space-between;
  }

  .right-controls {
    justify-content: space-between;
  }

  .btn-record {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
  }

  .sidebar {
    min-height: 280px;
  }

  .modal-backdrop {
    padding: 0;
  }

  .modal-panel {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal-body {
    grid-template-columns: 1fr;
  }

  .canvas-column {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .canvas-stage {
    max-height: 36dvh;
    min-height: 180px;
  }

  .transcript-input {
    min-height: 92px;
  }
}
