:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-soft: #fbfbfd;
  --text: #161617;
  --muted: #6e6e73;
  --hairline: rgba(29, 29, 31, 0.11);
  --blue: #0071e3;
  --green: #1d9f61;
  --amber: #b76e00;
  --red: #c42127;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--hairline);
  background: rgba(251, 251, 253, 0.86);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: white;
  background: #111;
  border-radius: 8px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.08;
  font-weight: 680;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.2;
}

.primary-action,
.dark-button,
.ghost-button,
.mini-button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.ghost-button {
  text-decoration: none;
}

.primary-action,
.dark-button {
  color: white;
  background: #111;
}

.primary-action:hover,
.dark-button:hover {
  background: #2b2b2d;
}

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--hairline);
}

.ghost-button:hover {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.22);
}

.mini-button {
  min-height: 32px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--hairline);
  font-size: 12px;
}

.full {
  width: 100%;
}

.montage-button {
  min-height: 48px;
  font-weight: 650;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  color: var(--muted);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: var(--radius);
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  background: #fff;
}

.project-card {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  display: flex;
  gap: 10px;
  background: #fff;
}

.project-card span:last-child,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--green);
}

.main {
  padding: 26px;
  display: grid;
  gap: 18px;
}

.topbar,
.section-heading,
.export-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar-actions,
.timeline-actions,
.export-actions,
.control-row {
  display: flex;
  gap: 10px;
}

.workspace-grid,
.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 18px;
}

.preview-panel,
.inspector,
.variants-panel,
.timeline-panel,
.info-panel,
.export-panel {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.preview-panel,
.inspector,
.variants-panel,
.timeline-panel,
.info-panel {
  padding: 14px;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef0f3;
  color: #3a3a3c;
  font-size: 12px;
}

.pill.good {
  color: #0d6b3b;
  background: #e8f7ef;
}

.segmented {
  padding: 3px;
  display: flex;
  background: #f0f1f3;
  border-radius: var(--radius);
}

.segment {
  min-width: 54px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 7px 10px;
  color: var(--muted);
}

.segment.active {
  color: var(--text);
  background: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.viewer {
  position: relative;
  min-height: 520px;
  background: #0f0f10;
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.ratio-vertical {
  aspect-ratio: 9 / 12;
}

.ratio-square {
  aspect-ratio: 1 / 1;
}

.ratio-wide {
  aspect-ratio: 16 / 9;
}

.viewer video,
.viewer img,
.viewer audio {
  max-width: 100%;
  max-height: 100%;
}

.viewer video,
.viewer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.empty-state {
  text-align: center;
  color: rgba(255, 255, 255, 0.72);
}

.empty-state span {
  display: block;
  font-size: 54px;
  margin-bottom: 10px;
}

.field,
.compact-field {
  display: grid;
  gap: 8px;
}

.field span,
.compact-field span {
  color: var(--muted);
  font-size: 13px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: var(--panel-soft);
  color: var(--text);
  outline: none;
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.24);
  outline-offset: 2px;
}

.inspector {
  display: grid;
  gap: 14px;
  align-content: start;
}

.option-stack {
  display: grid;
  gap: 8px;
}

.check-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.check-option input {
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.quality-list,
.rights-list,
.suggestions,
.jobs-list,
.pipeline-list {
  display: grid;
  gap: 8px;
}

.quality-item,
.right-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.quality-item strong,
.right-row strong {
  display: block;
  font-size: 13px;
}

.quality-item span,
.right-row span {
  color: var(--muted);
  font-size: 12px;
}

.variants,
.timeline {
  display: grid;
  gap: 10px;
}

.suggestions {
  margin-top: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.suggestion-card,
.job-card,
.empty-card,
.pipeline-row {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.suggestion-card {
  min-height: 148px;
  padding: 12px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.suggestion-card.selected {
  border-color: rgba(0, 113, 227, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.suggestion-card input {
  width: 16px;
  height: 16px;
  margin-top: 4px;
}

.suggestion-body {
  display: grid;
  gap: 8px;
}

.suggestion-body strong {
  font-size: 15px;
  line-height: 1.25;
}

.suggestion-body > span:last-child,
.empty-card span,
.job-main span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.suggestion-top {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.source-tag {
  color: var(--muted);
  font-size: 12px;
}

.variants {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.variant-card {
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--panel-soft);
  display: grid;
  gap: 10px;
}

.variant-card h3,
.variant-card p {
  overflow-wrap: anywhere;
}

.variant-card.active {
  border-color: rgba(0, 113, 227, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.score {
  height: 7px;
  background: #e6e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.score span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.timeline-ruler {
  height: 28px;
  margin: 10px 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--muted);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  font-size: 12px;
}

.timeline-clip {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 94px 36px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: #fff;
}

.clip-type {
  color: var(--muted);
  font-size: 12px;
}

.clip-bar {
  height: 34px;
  max-width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #b9c7d8, #eceff4);
  display: flex;
  align-items: center;
  padding: 0 10px;
  overflow: hidden;
  white-space: nowrap;
  font-size: 13px;
}

.clip-time {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #fff;
}

.bottom-grid {
  align-items: start;
}

.job-card {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 14px;
  align-items: center;
}

.job-card.active {
  border-color: rgba(0, 113, 227, 0.55);
  background: #fff;
}

.job-main,
.job-side,
.job-actions {
  display: grid;
  gap: 8px;
}

.job-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.job-main strong {
  overflow-wrap: anywhere;
}

.empty-card {
  padding: 14px;
  display: grid;
  gap: 5px;
}

.pipeline-list {
  margin-top: 14px;
}

.pipeline-row {
  padding: 10px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.pipeline-row span {
  color: var(--blue);
}

.pipeline-row strong {
  font-size: 13px;
}

.export-panel {
  padding: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  color: white;
  background: #111;
  border-radius: var(--radius);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .app-shell,
  .workspace-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .variants {
    grid-template-columns: 1fr;
  }

  .suggestions,
  .job-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .section-heading,
  .export-panel,
  .preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .control-row,
  .timeline-actions,
  .export-actions {
    flex-wrap: wrap;
  }

  .control-row > * {
    min-width: 100%;
  }

  .viewer {
    min-height: 360px;
  }

  .timeline-clip {
    grid-template-columns: 56px minmax(0, 1fr) 34px;
  }

  .clip-time {
    display: none;
  }
}
