:root {
  color-scheme: dark;
  --bg: #151617;
  --surface: #1c1e20;
  --surface-2: #242629;
  --surface-3: #303338;
  --line: #3b3e43;
  --text: #f5f8ff;
  --muted: #9eacc2;
  --blue: #4f9cff;
  --blue-strong: #2877e8;
  --violet: #9d8cff;
  --danger: #ff7f8d;
  --shadow: 0 16px 40px rgba(0, 0, 0, .22);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Apple SD Gothic Neo", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.app-shell { width: min(1120px, 100%); margin: 0 auto; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #5a82d6; border-radius: 10px; background: #1b3b75; color: #fff; font-weight: 800; font-size: 22px; box-shadow: 0 7px 18px rgba(48, 110, 223, .25); }
.brand-lockup h1 { margin: 0; font-size: 18px; line-height: 1.15; letter-spacing: 0; }
.brand-lockup p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.icon-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 23px; cursor: pointer; }
.icon-button:hover { border-color: var(--blue); }

.tabs { display: flex; gap: 4px; padding: 12px 18px 0; border-bottom: 1px solid var(--line); }
.tab { position: relative; padding: 10px 15px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.tab.is-active { color: var(--text); border-bottom-color: var(--blue); }
.tab-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 3px; padding: 0 5px; border-radius: 10px; background: var(--surface-3); color: var(--muted); font-size: 12px; }

main { padding: 24px 18px 0; }
.page { display: block; }
.page[hidden], .workspace-grid[hidden], .storage-grid[hidden], .storage-detail[hidden], .progress-wrap[hidden], .toast[hidden], .crop-overlay[hidden] { display: none; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-heading h2 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: 0; }
.page-heading .muted { max-width: 560px; margin: 8px 0 0; color: var(--muted); }
.eyebrow { display: none; }
.muted { color: var(--muted); }
.small-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

.primary-button, .secondary-button, .danger-button, .convert-button, .text-button, .tool-button, .round-button { cursor: pointer; -webkit-user-select: none; user-select: none; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--blue); color: #061020; font-weight: 800; text-decoration: none; }
.primary-button:hover { background: #72b0ff; }
.secondary-button { min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); font-weight: 700; }
.secondary-button:hover { border-color: var(--blue); }
.danger-button { min-height: 40px; padding: 0 13px; border: 1px solid rgba(255,127,141,.45); border-radius: 8px; background: transparent; color: var(--danger); font-weight: 700; }
.text-button { padding: 6px 0; border: 0; background: transparent; color: var(--muted); font-weight: 700; }
.text-button:hover { color: var(--text); }
.text-button.danger { color: var(--danger); }
.text-button:disabled, .danger-button:disabled, .secondary-button:disabled, .tool-button:disabled, .convert-button:disabled { cursor: not-allowed; opacity: .45; }

.drop-zone { display: grid; place-items: center; gap: 7px; min-height: 148px; margin-bottom: 20px; padding: 24px; border: 1px dashed #4b6590; border-radius: 8px; background: #101a2a; color: var(--text); text-align: center; cursor: pointer; transition: border-color .2s, background .2s; }
.drop-zone:hover, .drop-zone.is-dragging, .drop-zone:focus-visible { border-color: var(--blue); background: #142642; }
.drop-zone span { color: var(--muted); font-size: 13px; }
.drop-icon { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #4268a0; border-radius: 50%; color: var(--blue); font-size: 22px; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.42fr) minmax(300px, .8fr); align-items: start; gap: 16px; margin-bottom: 18px; }
.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.preview-panel, .settings-panel, .queue-panel, .storage-detail { padding: 18px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-heading.compact { margin-bottom: 16px; }
.panel-heading h3 { margin: 0; font-size: 18px; line-height: 1.15; }
.status-pill { padding: 5px 9px; border-radius: 999px; background: #203149; color: #b9c9e3; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-pill.is-done { background: #173f3f; color: #7be0c0; }
.status-pill.is-failed { background: #472536; color: #ff9aaa; }

.preview-stage { position: relative; display: grid; place-items: center; min-height: 230px; overflow: hidden; border-radius: 8px; background: #06090e; }
#video-preview { display: block; width: 100%; height: auto; max-height: 410px; background: #06090e; object-fit: contain; }
.preview-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; color: #71819a; text-align: center; pointer-events: none; }
.preview-stage.has-video .preview-empty { display: none; }
.crop-overlay { position: absolute; left: 4%; top: 4%; width: 92%; height: 92%; border: 1px solid #fff; box-shadow: 0 0 0 999px rgba(4,8,14,.56); touch-action: none; cursor: move; }
.crop-overlay.is-disabled { pointer-events: none; opacity: .6; }
.crop-handle { position: absolute; width: 22px; height: 22px; padding: 0; border: 2px solid #fff; border-radius: 5px; background: var(--blue); box-shadow: 0 2px 8px rgba(0,0,0,.45); touch-action: none; }
.handle-nw { left: -11px; top: -11px; cursor: nwse-resize; }.handle-ne { right: -11px; top: -11px; cursor: nesw-resize; }.handle-sw { left: -11px; bottom: -11px; cursor: nesw-resize; }.handle-se { right: -11px; bottom: -11px; cursor: nwse-resize; }

.transport-row { display: flex; align-items: center; gap: 10px; padding-top: 14px; }
.round-button { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: var(--blue); color: #081426; font-size: 15px; }
.time-readout { display: flex; gap: 4px; color: var(--text); font-variant-numeric: tabular-nums; font-size: 14px; }
.time-readout span:nth-child(2) { color: var(--muted); }.transport-row .text-button { margin-left: auto; font-size: 13px; }

.timeline-wrap { position: relative; height: 34px; margin: 12px 8px 0; }
.timeline-track { position: absolute; top: 15px; left: 0; right: 0; height: 5px; overflow: hidden; border-radius: 5px; background: #2a3750; pointer-events: none; }
.timeline-track span { position: absolute; top: 0; height: 100%; border-radius: 5px; background: var(--blue); }
.range-input { position: absolute; inset: 0; width: 100%; height: 34px; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; pointer-events: none; }
.range-input::-webkit-slider-thumb { width: 18px; height: 18px; appearance: none; -webkit-appearance: none; border: 2px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 2px 5px rgba(0,0,0,.4); pointer-events: auto; }
.range-input::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; background: var(--blue); pointer-events: auto; }
.playhead { z-index: 3; }.range-start, .range-end { z-index: 2; }.playhead::-webkit-slider-thumb { width: 13px; height: 13px; border-color: var(--violet); background: var(--violet); }
.timeline-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }.metadata-strip { display: flex; gap: 6px; align-items: center; margin-top: 15px; color: var(--muted); font-size: 12px; }.metadata-dot { color: #536580; }

.settings-panel { position: sticky; top: 12px; }
.field-label { display: block; margin: 13px 0 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
input[type="text"], input[type="number"], select { width: 100%; min-height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: #0d1624; color: var(--text); }
input[type="text"]:focus, input[type="number"]:focus, select:focus { border-color: var(--blue); }
.input-with-suffix, .inline-input, .rename-row { display: flex; align-items: center; gap: 8px; }.input-with-suffix input { min-width: 0; }.input-with-suffix span, .inline-input span, .rename-row span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; }.switch-line { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); font-size: 14px; font-weight: 700; cursor: pointer; }.switch-line input { position: absolute; opacity: 0; }.switch { position: relative; display: inline-block; flex: 0 0 auto; width: 38px; height: 22px; border-radius: 12px; background: #3a4a63; transition: background .15s; }.switch::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; content: ""; transition: transform .15s; }.switch-line input:checked + .switch { background: var(--blue); }.switch-line input:checked + .switch::after { transform: translateX(16px); }.inline-input { flex: 0 0 93px; }.inline-input input { min-width: 0; padding: 0 7px; text-align: right; }
.two-column-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.edit-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 17px; }.tool-button { min-height: 40px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 700; }.tool-button:hover, .tool-button.is-active { border-color: var(--blue); background: #1a3354; }.tool-button span { color: var(--blue); font-size: 16px; }
.trim-summary { margin-top: 13px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }.convert-button { width: 100%; min-height: 48px; margin-top: 17px; border: 0; border-radius: 8px; background: var(--blue); color: #071222; font-weight: 850; }.convert-button:hover { background: #72b0ff; }
.progress-wrap { margin-top: 14px; }.progress-bar { height: 7px; overflow: hidden; border-radius: 5px; background: #2a3750; }.progress-bar span { display: block; width: 0; height: 100%; border-radius: 5px; background: var(--blue); transition: width .16s; }.progress-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; color: var(--muted); font-size: 12px; }

.queue-panel { margin-top: 18px; }.job-list { display: grid; gap: 8px; }.empty-list { padding: 22px 0 10px; color: var(--muted); text-align: center; }.job-row { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 11px; min-height: 62px; padding: 9px 10px; border: 1px solid transparent; border-radius: 7px; background: var(--surface-2); cursor: pointer; }.job-row.is-active { border-color: var(--blue); background: #1a2c48; }.job-index { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; background: #263b5c; color: #bdd9ff; font-weight: 800; }.job-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }.job-meta { margin-top: 3px; color: var(--muted); font-size: 12px; }.job-status { color: var(--muted); font-size: 12px; white-space: nowrap; }.job-status.done { color: #7be0c0; }.job-status.failed { color: var(--danger); }.job-remove { width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }.job-remove:hover { color: var(--danger); }

.toast { position: fixed; z-index: 20; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); left: 18px; max-width: 520px; margin: auto; padding: 13px 15px; border: 1px solid #486893; border-radius: 8px; background: #1c3150; color: var(--text); box-shadow: var(--shadow); font-size: 14px; }

.storage-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }.segmented-control { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }.segment { min-height: 33px; padding: 0 11px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; }.segment.is-active { background: var(--surface-3); color: var(--text); }.storage-toolbar .text-button:first-of-type { margin-left: auto; }
.storage-empty { display: grid; place-items: center; min-height: 250px; padding: 24px; text-align: center; }.empty-glyph { display: grid; place-items: center; width: 56px; height: 56px; border: 1px solid #43618b; border-radius: 50%; color: var(--blue); font-size: 34px; }.storage-empty h3 { margin: 15px 0 2px; font-size: 18px; }.storage-empty p { margin: 0; color: var(--muted); }
.storage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }.storage-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }.storage-card.is-selected { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }.storage-thumb { display: grid; place-items: center; aspect-ratio: 16 / 10; overflow: hidden; background: #080c13; }.storage-thumb canvas, .storage-thumb video { display: block; width: 100%; height: 100%; object-fit: contain; }.storage-type { position: absolute; top: 8px; left: 8px; padding: 3px 6px; border-radius: 4px; background: rgba(8, 13, 22, .82); color: #d7e5ff; font-size: 10px; font-weight: 800; }.storage-check { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; accent-color: var(--blue); }.storage-card-body { padding: 10px; }.storage-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 700; }.storage-card-meta { margin-top: 3px; color: var(--muted); font-size: 11px; }
.storage-detail { margin-top: 16px; }.storage-preview { display: grid; place-items: center; min-height: 210px; overflow: hidden; border-radius: 7px; background: #070a10; }.storage-preview video, .storage-preview canvas { display: block; max-width: 100%; max-height: 420px; }.rename-row { margin-top: 13px; }.rename-row input { min-width: 0; }.detail-actions { display: flex; gap: 8px; margin-top: 12px; }.detail-actions > * { flex: 1; }

@media (max-width: 760px) {
  main { padding: 20px 14px 0; }
  .topbar { padding-right: 14px; padding-left: 14px; }
  .tabs { padding-left: 14px; padding-right: 14px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .page-heading .primary-button, .page-heading .danger-button { width: 100%; }
  .workspace-grid { grid-template-columns: 1fr; }
  .settings-panel { position: static; }
  .preview-stage { min-height: 220px; }
  .storage-toolbar { flex-wrap: wrap; }.storage-toolbar .text-button:first-of-type { margin-left: 0; }.storage-toolbar .text-button { margin-left: auto; }
  .storage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .storage-card-body { padding: 8px; }
  .job-row { grid-template-columns: 36px minmax(0,1fr) auto; gap: 8px; }
  .job-index { width: 29px; height: 29px; }
}

@media (max-width: 380px) {
  .brand-lockup h1 { font-size: 16px; }.brand-lockup p { font-size: 11px; }.page-heading h2 { font-size: 24px; }
  .setting-row { align-items: flex-start; flex-direction: column; }.inline-input { flex-basis: auto; width: 120px; }
  .storage-toolbar { align-items: stretch; }.segmented-control { width: 100%; }.segment { flex: 1; }.storage-toolbar .text-button { margin-left: 0; }
}

[hidden] { display: none !important; }
button, input, select { letter-spacing: 0; }
button { touch-action: manipulation; }
button svg { flex-shrink: 0; vertical-align: middle; }
.brand-mark { object-fit: cover; border: 0; background: transparent; box-shadow: none; }
.panel { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.preview-panel, .settings-panel, .queue-panel, .storage-detail { padding: 16px 0; border-top: 1px solid var(--line); }
.settings-panel { padding-left: 20px; }
.link-section { padding: 0 0 20px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.link-section h3 { font-size: 16px; margin: 0 0 12px; }
.link-form { display: flex; flex-wrap: wrap; gap: 8px; }
input[type="url"] { flex: 1 1 280px; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: #101112; color: var(--text); }
.link-status-row { display: flex; gap: 12px; align-items: center; margin-top: 8px; font-size: 14px; color: var(--muted); }
.twitter-results { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap: 12px; margin-top: 12px; }
.twitter-results:empty { display: none; }
.twitter-item { min-width: 0; display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; overflow-wrap: anywhere; }
.twitter-item img { display: block; width: 100%; height: 140px; object-fit: contain; background: #090a0b; }
.drop-zone { min-height: 96px; background: #1b1d1f; padding: 16px; }
.drop-zone:hover, .drop-zone.is-dragging { background: #24282d; }
.drop-icon { display: none; }
.preview-stage { min-height: 0; margin: 0 auto; width: 100%; overflow: hidden; border-radius: 2px; }
#preview-canvas { display: block; width: 100%; height: 100%; }
.preview-empty { font-size: 14px; }
.trim-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.trim-inputs label { display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; }
.trim-inputs input { min-width: 0; }
.segment-actions { display: flex; gap: 8px; margin-top: 14px; }
.segment-actions .danger-button { display: flex; align-items: center; gap: 8px; }
.timeline-wrap { height: 52px; }
.timeline-track { top: 16px; }
.playhead { top: 23px; height: 24px; pointer-events: auto; }
.playhead::-webkit-slider-thumb { border-radius: 2px; height: 18px; width: 6px; background: #f2c66a; border-color: #f2c66a; }
.playhead::-moz-range-thumb { border-radius: 2px; height: 18px; width: 6px; background: #f2c66a; border-color: #f2c66a; }
.range-start, .range-end { height: 34px; }
.wide { width: 100%; margin-top: 8px; }
.tool-button { display: flex; align-items: center; justify-content: center; gap: 8px; }
.field-label, .tool-button, .segment, .storage-card-name, .job-status, .metadata-strip, .progress-meta { font-size: 14px; }
.small-note, .storage-card-meta, .timeline-labels, .job-meta { font-size: 12px; }
.job-row { grid-template-columns: 32px minmax(0,1fr) auto 32px; background: var(--surface-2); }
.job-info { min-width: 0; }
.job-row.is-active { background: #28303a; }
.job-error { color: var(--danger); font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; margin-top: 4px; }
.job-remove { display: grid; place-items: center; }
.folder-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 16px; }
#folder-path { flex: 1 1 200px; display: flex; flex-wrap: wrap; gap: 8px; }
#folder-path button { background: none; border: 0; color: var(--text); cursor: pointer; padding: 6px 0; overflow-wrap: anywhere; }
.storage-thumb img { width: 100%; height: 100%; object-fit: contain; }
.storage-thumb > svg { width: 40px; height: 40px; color: #d4b56a; }
.storage-preview img { max-width: 100%; max-height: 400px; object-fit: contain; }
.storage-detail h3 { overflow-wrap: anywhere; }
.detail-actions { flex-wrap: wrap; }
.detail-actions button { min-width: 100px; }
.rename-row { flex-wrap: wrap; }
.rename-row input { flex: 1; min-width: 140px; }
.progress-meta { overflow-wrap: anywhere; }
.progress-meta .text-button { flex-shrink: 0; }
dialog { width: min(440px,calc(100% - 32px)); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
dialog::backdrop { background: #000a; }
dialog h3 { margin-top: 0; }
input[type="text"], input[type="number"], select { background: #17191c; }
.storage-type { font-size: 12px; }
.primary-button:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 760px) {
  .settings-panel { padding-left: 0; }
  .job-row { grid-template-columns: 26px minmax(0,1fr) auto 28px; gap: 6px; }
  .job-status { font-size: 12px; }
  .link-form input { flex-basis: 100%; }
  .link-form button { flex: 1; }
  .folder-toolbar > button { flex: 1; font-size: 14px; padding: 8px; }
  #folder-path { flex-basis: 100%; }
  .page-heading { flex-direction: row; align-items: center; }
  .page-heading .primary-button, .page-heading .danger-button { width: auto; flex-shrink: 0; }
  .page-heading h2 { font-size: 22px; }
  .storage-toolbar { gap: 12px; }
  .preview-panel { padding-top: 8px; }
}
