:root {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: #273449;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --accent: #10b981;
  --accent-hover: #059669;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --warn-border: rgba(245, 158, 11, 0.45);
  --warn-text: #fde68a;
  --err-bg: rgba(239, 68, 68, 0.14);
  --err-border: rgba(239, 68, 68, 0.45);
  --err-text: #fecaca;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px 14px 28px;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #38bdf8, #10b981);
  color: #06131f;
  font-size: 22px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.lang-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.lang-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.field-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.url-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

#url-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  outline: none;
}

#url-input:focus {
  border-color: var(--primary);
}

.action-row {
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

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

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #06131f;
}

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

.btn-accent {
  background: var(--accent);
  color: #041d15;
}

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
}

.alert p {
  margin: 4px 0 0;
}

.alert-warning {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}

.alert-error {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err-text);
}

.video-meta {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.video-thumb {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--surface-2);
  flex-shrink: 0;
}

.video-info {
  min-width: 0;
  flex: 1;
}

.video-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
  word-break: break-word;
}

.video-uploader {
  margin: 4px 0 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

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

.badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}

.badge-neutral {
  background: var(--surface-2);
  color: var(--text);
}

.badge-info {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}

.badge-ok {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.options-grid {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toggle-row,
.bitrate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
}

.toggle-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

#split-toggle {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.select-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.segments-preview {
  margin: 14px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.section-heading {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

#convert-btn {
  margin-top: 14px;
}

.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.track-list.compact {
  max-height: 220px;
  overflow-y: auto;
}

.track-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.track-main {
  min-width: 0;
  flex: 1;
}

.track-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.progress-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.25s ease;
}

.progress-note {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.result-summary,
.expiry-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.expiry-note {
  margin-top: 12px;
}

.footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 8px;
}

.hidden {
  display: none !important;
}

@media (max-width: 480px) {
  .video-meta {
    flex-direction: column;
  }
  .video-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
}
