:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-alt: #f0f0f3;
  --ink: #111111;
  --ink-muted: #666670;
  --border: #e1e1e6;
  --primary: #111111;
  --ok: #15803d;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.studio-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Alerts & Banners */
.persist-warn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #f59e0b;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Top Project Hub Bar */
.project-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.brand-mark { display: flex; align-items: center; gap: 10px; }
.brand-sq {
  width: 26px; height: 26px; border-radius: 6px;
  background: #111111; color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 11px; letter-spacing: 0.04em;
}
.brand-title { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--ink-muted); letter-spacing: 0.04em; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.backup-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink-muted);
  font-weight: 600;
}
.backup-badge.warn {
  border-color: var(--warn);
  color: #b45309;
  background: #fffbeb;
}

/* Buttons & Inputs */
button, .btn-label {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: opacity 0.15s, background 0.15s;
}
button:hover, .btn-label:hover { opacity: 0.85; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
button.ok-btn  { background: var(--ok); color: #fff; border-color: var(--ok); }
button.ghost   { background: var(--surface-alt); }
button.danger  { color: var(--danger); }

input[type="text"], input[type="number"], select, textarea {
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 9px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Clip Tabs Strip */
.clip-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.clip-tab {
  white-space: nowrap;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
}
.clip-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.ratio-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(17, 17, 17, 0.08);
  margin-left: 5px;
  font-family: ui-monospace, monospace;
}
.clip-tab.active .ratio-tag { background: rgba(255, 255, 255, 0.2); color: #fff; }

/* Cinema Stage Card & Fullscreen */
.stage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.stage-card:fullscreen {
  border-radius: 0;
  border: none;
  background: #08080a;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.stage-card:fullscreen .stage-backdrop {
  flex: 1;
  min-height: 0;
  background: #08080a;
}
.stage-card:fullscreen .stage-frame:not(.vertical) {
  max-height: calc(100vh - 76px);
  width: auto;
  max-width: 100vw;
}
.stage-card:fullscreen .stage-frame.vertical {
  height: calc(100vh - 84px);
}
.stage-card:fullscreen .transport {
  background: rgba(17, 17, 17, 0.92);
  border-top-color: #26262a;
  color: #fff;
}
.stage-card:fullscreen .transport button.ghost {
  background: #222226; color: #fff; border-color: #333338;
}

.stage-backdrop {
  background: #0b0b0e;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  min-height: 360px;
}
.stage-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111111;
}
.stage-frame.vertical {
  width: auto;
  height: min(68vh, 620px);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}
.stage-frame canvas { width: 100%; height: 100%; display: block; }

.big-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 62px; height: 62px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.88);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.rec-badge {
  position: absolute;
  top: 12px; right: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.transport {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.transport-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.scrubber-wrap { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 9px; }
.scrubber-wrap input[type="range"] { flex: 1; accent-color: var(--primary); cursor: pointer; }
.beat-pills { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 2px; }
.beat-pill {
  padding: 4px 9px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  white-space: nowrap;
  background: var(--surface-alt);
}
.beat-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 4-Tab Workspace */
.workspace-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.step-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.step-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.step-tab {
  padding: 6px 12px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-muted);
  font-weight: 600;
}
.step-tab.active { background: var(--surface); color: var(--ink); border-color: var(--border); }
.step-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

/* Grids & Form Fields */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 820px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}
.field input, .field select, .field textarea { width: 100%; }

/* Beat Sheet Table */
.table-wrap {
  overflow-x: auto;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
table.beat-table { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
table.beat-table thead th {
  position: sticky; top: 0;
  background: var(--surface-alt);
  color: var(--ink-muted);
  font-size: 11px; text-transform: uppercase;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}
table.beat-table tbody td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.beat-table tbody tr { cursor: pointer; }
table.beat-table tbody tr.active { background: rgba(17, 17, 17, 0.06); }

.sum-badge {
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.sum-badge.ok   { border-color: var(--ok); color: var(--ok); background: rgba(21, 128, 61, 0.07); }
.sum-badge.warn { border-color: var(--warn); color: var(--warn); background: rgba(217, 119, 6, 0.08); }

/* Focal Point Interactive Picker */
.focal-box {
  position: relative;
  width: 100%;
  height: 118px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #111;
  cursor: crosshair;
}
.focal-box img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.92; pointer-events: none; }
.focal-dot {
  position: absolute;
  width: 16px; height: 16px;
  margin-left: -8px; margin-top: -8px;
  border-radius: 999px;
  border: 2px solid #ffffff;
  background: rgba(245, 196, 0, 0.85);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

/* Media Bin */
.media-bin { display: flex; gap: 7px; overflow-x: auto; padding: 5px 2px; }
.media-thumb {
  width: 88px; height: 52px;
  border-radius: 6px; overflow: hidden;
  border: 2px solid transparent;
  flex-shrink: 0; cursor: pointer; position: relative; background: #111;
}
.media-thumb.active { border-color: #111; box-shadow: 0 0 0 2px #f5c400; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb span {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 9px; color: #fff; background: rgba(0, 0, 0, 0.72);
  padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Director Summary Cards */
.director-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 760px) { .director-grid { grid-template-columns: 1fr; } }
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
}
.info-card h3 {
  margin: 0 0 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted);
}
.info-card .val { font-weight: 700; font-size: 13px; margin-bottom: 3px; }
.info-card .sub { font-size: 12px; color: var(--ink-muted); }

/* Clip Creation Wizard Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 10, 14, 0.56);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 100;
}
.modal-card {
  width: 100%; max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.toast {
  position: fixed; bottom: 18px; right: 18px;
  background: #111111; color: #fff;
  padding: 9px 14px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  z-index: 110;
}
