/* Lively for Web — flat, friendly, and out of the way of the picture.
   Brand colours come from the iPhone app icon: coral, blue, amber, mint. */

:root {
  --coral: #ff6b6b;
  --coral-deep: #ef5559;
  --blue: #3d7dff;
  --amber: #ffb84c;
  --mint: #2ecc9b;
  --violet: #8a6cff;
  --navy: #173056;

  --bg: #f2f3f6;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef2;
  --line: #e2e5eb;
  --line-strong: #cfd4dd;
  --text: #151a24;
  --muted: #687084;
  --faint: #9aa1b0;
  --stage: #121418;
  --shadow: 0 1px 2px rgba(20, 26, 36, 0.06), 0 8px 24px -12px rgba(20, 26, 36, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans GB", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --tl-muted: #8a90a0;
  --tl-wave: rgba(104, 112, 132, 0.28);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: #16191f;
    --surface-2: #1b1f26;
    --surface-3: #232831;
    --line: #262b34;
    --line-strong: #353c48;
    --text: #eceef2;
    --muted: #9aa2b2;
    --faint: #6c7484;
    --stage: #07080a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
    --tl-muted: #7e8696;
    --tl-wave: rgba(160, 170, 190, 0.22);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.45em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font: 600 12px/1.5 var(--font);
  text-align: center;
}

.lv-hidden-media {
  position: fixed;
  left: 0;
  top: 0;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface-3);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--coral); color: #fff; box-shadow: 0 6px 16px -8px rgba(255, 107, 107, 0.9); }
.btn.primary:hover:not(:disabled) { background: var(--coral-deep); }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.text { background: transparent; color: var(--blue); padding: 0 6px; }
.btn.small { min-height: 30px; padding: 0 11px; font-size: 13px; }
.btn.text.small { padding: 0 4px; }
.btn.big { min-height: 50px; padding: 0 26px; font-size: 16px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn.is-on { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }

/* ------------------------------------------------------------- top bar */

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
}
.brand:hover { background: var(--surface-3); }
.brand-copy { display: flex; align-items: baseline; gap: 5px; }
.brand-copy strong { font-size: 17px; letter-spacing: -0.01em; }
.brand-copy span { color: var(--muted); font-size: 13px; }

.doc-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-name:not(:empty)::before { content: "/"; margin-right: 10px; color: var(--line-strong); }

.bar-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.bar-sep { width: 1px; height: 22px; margin: 0 6px; background: var(--line); }
.bar-tools .btn.primary { margin-left: 8px; }
.bar-links { display: flex; gap: 18px; margin-left: auto; font-weight: 500; }
.bar-links a { color: var(--muted); }
.bar-links a:hover { color: var(--text); text-decoration: none; }

.app[data-state="empty"] .bar-tools,
.app[data-state="loading"] .bar-tools,
.app[data-state="unsupported"] .bar-tools { display: none; }
.app[data-state="editing"] .bar-links { display: none; }
.app[data-state="empty"] .brand { pointer-events: none; }

/* ------------------------------------------------------------- welcome */

.welcome {
  display: none;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(40px, 8vh, 88px) 0 40px;
}
.app[data-state="empty"] .welcome { display: block; }

.welcome-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  align-items: center;
  gap: clamp(28px, 6vw, 80px);
}
.welcome-hero { max-width: 640px; }

.demo { margin: 0; }
.demo-screen {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  background: #000;
  box-shadow: 0 0 0 8px var(--surface), 0 0 0 9px var(--line), 0 40px 80px -30px rgba(20, 26, 36, 0.55);
  line-height: 0;
  transform: rotate(1.5deg);
}
.demo-screen canvas { width: 100%; height: auto; aspect-ratio: 3 / 4; }
.demo-look {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #151a24;
  font: 700 12.5px/1 var(--font);
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.5);
}
.demo-chips { display: flex; justify-content: center; gap: 6px; margin-top: 22px; }
.demo-chips i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: width 0.3s, background-color 0.3s;
}
.demo-chips i.is-on { width: 22px; border-radius: 4px; background: var(--coral); }
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
}
.kicker .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--coral) 22%, transparent);
}
.welcome h1 {
  margin: 0;
  font-size: clamp(40px, 6.4vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 800;
}
.lede { max-width: 600px; margin: 20px 0 0; color: var(--muted); font-size: 17px; line-height: 1.55; }
.welcome-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; margin-top: 30px; }
.or { color: var(--muted); }
.privacy { display: flex; align-items: center; gap: 7px; margin: 22px 0 0; color: var(--muted); font-size: 13px; }

.welcome-samples { margin-top: 56px; }
.welcome-samples h2 { margin: 0 0 14px; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sample-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.sample-card {
  display: flex;
  flex-direction: column;
  width: min-content;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s;
}
.sample-card:hover { transform: translateY(-3px); box-shadow: 0 16px 40px -18px rgba(20, 26, 36, 0.35); }
.sample-media { display: block; background: #000; }
.sample-card canvas { display: block; height: 230px; width: auto; }
.sample-copy { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 14px; }
.sample-copy small { color: var(--muted); }

.features {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 56px 0 0;
  padding: 0;
  list-style: none;
}
.features li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.features li::before {
  content: "";
  width: 28px;
  height: 6px;
  border-radius: 3px;
  background: var(--coral);
  margin-bottom: 6px;
}
.features li:nth-child(2)::before { background: var(--blue); }
.features li:nth-child(3)::before { background: var(--violet); }
.features li:nth-child(4)::before { background: var(--mint); }
.features span { color: var(--muted); font-size: 13.5px; }
.welcome-foot { margin: 40px 0 0; color: var(--faint); font-size: 13px; }

/* -------------------------------------------------------------- editor */

.editor { display: none; }
.app[data-state="editing"] .editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "stage insp" "tl insp";
  height: calc(100dvh - 56px);
  min-height: 560px;
}

.stage {
  grid-area: stage;
  position: relative;
  display: flex;
  min-height: 0;
  padding: 22px;
  background: var(--stage);
  background-image: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.04), transparent 70%);
}
.stage-box {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}
.canvas-wrap { position: relative; line-height: 0; }
#view {
  display: block;
  border-radius: 6px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8);
  cursor: pointer;
  touch-action: none;
}
.app[data-tab="crop"] #view { cursor: grab; }
.app[data-tab="crop"] #view:active { cursor: grabbing; }

.badge {
  position: absolute;
  left: 12px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px 5px 7px;
  border-radius: 6px;
  background: rgba(20, 22, 28, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font: 700 11px/1 var(--font);
  letter-spacing: 0.08em;
  pointer-events: none;
}
.badge::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.6px dashed rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 0 0 2.4px rgba(20, 22, 28, 0.55), inset 0 0 0 5px #fff;
}

.original-tag {
  position: absolute;
  right: 12px;
  top: 12px;
  padding: 5px 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: #151a24;
  font: 700 11px/1 var(--font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}
.stage.is-original .original-tag { opacity: 1; }

.crop-grid {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 6px;
}
.app[data-tab="crop"] .crop-grid { display: block; }
.crop-grid i { position: absolute; background: rgba(255, 255, 255, 0.4); }
.crop-grid i:nth-child(1) { left: 33.33%; top: 0; bottom: 0; width: 1px; }
.crop-grid i:nth-child(2) { left: 66.66%; top: 0; bottom: 0; width: 1px; }
.crop-grid i:nth-child(3) { top: 33.33%; left: 0; right: 0; height: 1px; }
.crop-grid i:nth-child(4) { top: 66.66%; left: 0; right: 0; height: 1px; }

.split {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  cursor: ew-resize;
  touch-action: none;
}
.split::before { content: ""; position: absolute; inset: 0 -14px; }
.split-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.split-knob::before, .split-knob::after {
  content: "";
  position: absolute;
  top: 10px;
  border: 5px solid transparent;
}
.split-knob::before { left: 3px; border-right-color: #151a24; }
.split-knob::after { right: 3px; border-left-color: #151a24; }
.split em {
  position: absolute;
  bottom: 12px;
  padding: 4px 8px;
  border-radius: 5px;
  background: rgba(20, 22, 28, 0.6);
  color: #fff;
  font: 700 10.5px/1 var(--font);
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
}
.split-l { right: 12px; }
.split-r { left: 12px; }

.busy {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(20, 22, 28, 0.78);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.busy-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--coral);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: calc(100dvh - 56px);
  color: var(--muted);
  font-weight: 600;
}
.loading-state .busy-ring { border-color: var(--line); border-top-color: var(--coral); }
.app[data-state="loading"] .loading-state { display: flex; }

.unsupported { display: none; max-width: 520px; margin: 12vh auto; padding: 0 20px; text-align: center; }
.unsupported p { color: var(--muted); }
.app[data-state="unsupported"] .unsupported { display: block; }

/* ----------------------------------------------------------- inspector */

.inspector {
  grid-area: insp;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.insp-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--line);
}
.insp-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px 9px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}
.insp-tab:hover { color: var(--text); }
.insp-tab.is-on { color: var(--coral); border-bottom-color: var(--coral); }

.insp-panels { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.panel { padding: 16px 18px 28px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.panel-actions { display: flex; align-items: center; gap: 4px; }
.panel-note { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }
.panel-sub {
  margin: 20px 0 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.panel-sub.small { margin-top: 16px; }

/* sliders */
.sl { padding: 7px 0 3px; }
.sl-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.sl-label { font-weight: 500; cursor: default; user-select: none; }
.sl-value { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.sl.is-set .sl-value { color: var(--coral); font-weight: 600; }
.sl.is-disabled { opacity: 0.4; pointer-events: none; }
.sl input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  --a: 0%;
  --b: 0%;
}
.sl input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background:
    linear-gradient(90deg, transparent var(--a), var(--coral) var(--a), var(--coral) var(--b), transparent var(--b)),
    var(--surface-3);
}
.sl input[type=range]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background:
    linear-gradient(90deg, transparent var(--a), var(--coral) var(--a), var(--coral) var(--b), transparent var(--b)),
    var(--surface-3);
}
.sl input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 0 0 1px rgba(20, 26, 36, 0.16), 0 2px 6px rgba(20, 26, 36, 0.25);
}
.sl input[type=range]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 0 0 1px rgba(20, 26, 36, 0.16), 0 2px 6px rgba(20, 26, 36, 0.25);
}
.sl input[type=range]:focus-visible { outline: none; }
.sl input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 45%, transparent); }

/* looks */
.look-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.look {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.look canvas {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--surface-3);
  box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow 0.15s, transform 0.15s;
}
.look:hover canvas { transform: translateY(-1px); }
.look.is-on { color: var(--text); }
.look.is-on canvas { box-shadow: 0 0 0 2.5px var(--coral); }
.look-del {
  position: absolute;
  top: -6px;
  right: -6px;
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
}
.look-del svg { width: 12px; height: 12px; }
.look:hover .look-del { display: grid; }
#inspector .look-grid + .sl { margin-top: 12px; }
.panel[data-panel="looks"] > .btn { margin-top: 18px; width: 100%; }

/* live effects */
.effect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.effect {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: left;
  transition: border-color 0.15s, background-color 0.15s;
}
.effect:hover { border-color: var(--line-strong); }
.effect small { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.effect-icon { color: var(--muted); margin-bottom: 2px; }
.effect.is-on { border-color: var(--coral); background: color-mix(in srgb, var(--coral) 7%, var(--surface)); }
.effect.is-on .effect-icon { color: var(--coral); }

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-3);
  flex-wrap: wrap;
}
.seg button {
  flex: 1;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20, 26, 36, 0.16); }
.seg.aspect button { flex: 1 1 28%; }

.key-card { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: start; }
.key-thumb { width: 96px; height: 96px; border-radius: 10px; background: var(--surface-3); box-shadow: 0 0 0 1px var(--line); }
.key-copy p { margin: 0 0 4px; color: var(--muted); font-size: 12.5px; }
.key-time { display: block; margin-bottom: 8px; font-weight: 600; font-size: 12.5px; }
.key-actions { display: flex; flex-wrap: wrap; gap: 4px; }

.row-actions { display: flex; gap: 8px; }

/* audio */
.with-icon { display: grid; grid-template-columns: 36px 1fr; align-items: end; gap: 6px; }
.with-icon .icon-btn { margin-bottom: 1px; }
.icon-btn.is-muted { color: var(--coral); }
.src-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.src-btn, .synth {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: left;
  color: var(--muted);
}
.src-btn span, .synth span { display: flex; flex-direction: column; color: var(--text); min-width: 0; }
.src-btn small, .synth small { color: var(--muted); font-size: 11.5px; }
.src-btn:hover, .synth:hover { border-color: var(--line-strong); }
.synth-list { display: grid; gap: 8px; }
.synth.is-on { border-color: var(--violet); color: var(--violet); }
.rec-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--coral) 10%, var(--surface));
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--coral); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-meter { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.rec-meter span { display: block; height: 100%; width: 0; background: var(--coral); transition: width 0.08s; }
.track-editor { margin-top: 2px; }
.track-head { display: flex; align-items: center; gap: 8px; padding: 10px 6px 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--violet) 12%, var(--surface)); }
.track-icon { display: inline-grid; color: var(--violet); }
.track-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ timeline */

.timeline {
  grid-area: tl;
  padding: 10px 16px 14px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
}
.tl-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.tl-transport { display: flex; align-items: center; gap: 10px; }
.tl-play {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
}
.tl-play::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 3px;
  border-left: 12px solid currentColor;
  border-top: 7.5px solid transparent;
  border-bottom: 7.5px solid transparent;
}
.tl-play.is-playing::before {
  width: 11px;
  height: 13px;
  margin-left: 0;
  border: 0;
  background: linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px, currentColor 7px);
}
.tl-time { font: 600 15px/1 var(--mono); font-variant-numeric: tabular-nums; }
.tl-len { color: var(--muted); font: 500 13px/1 var(--mono); margin-left: -6px; }
.tl-hint { flex: 1; color: var(--muted); font-size: 12.5px; text-align: center; }
.tl-keybtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
  font-size: 12.5px;
}
.tl-keybtn:hover { background: var(--surface-2); }
.tl-diamond { width: 9px; height: 9px; background: var(--text); transform: rotate(45deg); border-radius: 1.5px; }

.tl-overview {
  position: relative;
  height: 14px;
  margin: 0 18px 8px;
  border-radius: 7px;
  background: var(--surface-3);
  cursor: pointer;
  touch-action: none;
}
.tl-ov-trim { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; background: var(--amber); }
.tl-ov-window { position: absolute; top: 0; bottom: 0; border-radius: 7px; box-shadow: inset 0 0 0 2px var(--text); }
.tl-ov-head { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--coral); }

.tl-body { position: relative; touch-action: none; }
.tl-ruler { display: block; width: 100%; height: 18px; cursor: pointer; }
.tl-video {
  position: relative;
  height: 58px;
  margin-top: 2px;
  border-radius: 8px;
  cursor: pointer;
}
.tl-film { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 8px; }
.tl-shade { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--surface) 72%, transparent); pointer-events: none; }
.tl-trim {
  position: absolute;
  top: -3px;
  bottom: -3px;
  border: 3px solid var(--amber);
  border-left-width: 14px;
  border-right-width: 14px;
  border-radius: 9px;
  margin-left: -14px;
  box-sizing: content-box;
  cursor: grab;
}
.tl-grip {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 22px;
  cursor: ew-resize;
}
.tl-grip::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 18px;
  margin: -9px 0 0 -1.5px;
  border-radius: 2px;
  background: rgba(60, 40, 0, 0.55);
}
.tl-grip.in { left: -18px; }
.tl-grip.out { right: -18px; }
.tl-trim-len {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--amber);
  color: #3c2800;
  font: 700 10.5px/1.5 var(--mono);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.timeline.is-dragging .tl-trim-len, .tl-trim:hover .tl-trim-len { opacity: 1; }

.tl-key {
  position: absolute;
  top: -8px;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ew-resize;
}
.tl-key::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--text);
  transform: rotate(45deg);
}
.tl-key::after {
  content: "";
  position: absolute;
  left: 7.5px;
  top: 14px;
  width: 1px;
  height: 52px;
  background: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

.tl-audio { position: relative; height: 34px; margin-top: 8px; }
.tl-orig-wave { position: absolute; inset: 2px 0; width: 100%; height: 30px; pointer-events: none; }
.tl-track-clip { position: absolute; top: 0; bottom: 0; overflow: hidden; border-radius: 8px; }
.tl-track {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 7px;
  background: var(--violet);
  color: #fff;
  cursor: grab;
  overflow: hidden;
}
.tl-track-wave { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.8; }
.tl-track-name {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11.5px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  pointer-events: none;
}
.tl-tgrip { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; }
.tl-tgrip.in { left: 0; border-left: 3px solid rgba(255, 255, 255, 0.8); }
.tl-tgrip.out { right: 0; border-right: 3px solid rgba(255, 255, 255, 0.8); }
.tl-add {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 18px;
  padding: 0 12px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.tl-add:hover { color: var(--violet); border-color: var(--violet); }

.tl-playhead {
  position: absolute;
  left: 0;
  top: 0;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  background: var(--coral);
  pointer-events: none;
  z-index: 3;
}
.tl-playhead span {
  position: absolute;
  top: 0;
  left: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 3px 3px 50% 50%;
  background: var(--coral);
}

/* --------------------------------------------------------------- dialogs */

dialog {
  width: min(560px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5);
}
dialog::backdrop { background: rgba(10, 12, 16, 0.5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.exp-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 6px 22px; }
.exp-head h2 { margin: 0; font-size: 19px; }
.exp-setup, .exp-progress, .exp-result { padding: 8px 22px 22px; }
.fmt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fmt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: left;
}
.fmt small { color: var(--muted); }
.fmt.is-on { border-color: var(--coral); background: color-mix(in srgb, var(--coral) 7%, var(--surface)); }
.opts { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 18px; }
.opt { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.opt.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 14px; align-self: flex-end; padding-bottom: 8px; }
.opt.check input { width: 18px; height: 18px; accent-color: var(--coral); }
.field {
  min-width: 170px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
}
.exp-summary { margin: 16px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.exp-warn { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--amber) 18%, var(--surface)); font-size: 13px; }
.exp-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.exp-bar { height: 8px; margin-top: 10px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.exp-bar span { display: block; width: 0; height: 100%; border-radius: 4px; background: var(--coral); transition: width 0.15s; }
.exp-stage { margin: 12px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.exp-media { display: grid; place-items: center; max-height: 46vh; overflow: hidden; border-radius: 12px; background: var(--stage); }
.exp-media video, .exp-media img { display: block; max-width: 100%; max-height: 46vh; }

.keys-list { display: grid; gap: 2px; margin: 0; padding: 6px 22px 22px; }
.keys-list div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.keys-list div:last-child { border-bottom: 0; }
.keys-list dt { display: flex; gap: 4px; }
.keys-list dd { margin: 0; color: var(--muted); text-align: right; }

/* ------------------------------------------------------------- overlays */

.drop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--coral) 18%, rgba(10, 12, 16, 0.55));
  pointer-events: none;
}
.drop-card {
  padding: 28px 36px;
  border: 2px dashed #fff;
  border-radius: 20px;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(520px, calc(100% - 32px));
  padding: 11px 16px;
  border-radius: 12px;
  background: #151a24;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.noscript { max-width: 520px; margin: 20vh auto; text-align: center; }

/* the site terminal would sit on top of the timeline while editing */
body.is-editing .site-terminal-section { display: none; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .welcome-top { grid-template-columns: 1fr; }
  .demo { max-width: 300px; margin: 8px auto 0; }
}

@media (max-width: 960px) {
  .app[data-state="editing"] .editor {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas: "stage" "tl" "insp";
    height: auto;
  }
  .stage { height: var(--stage-h, min(62vh, 560px)); padding: 14px; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); }
  .insp-tabs { position: sticky; top: 56px; z-index: 5; background: var(--surface); }
  .insp-panels { overflow: visible; }
  .panel { padding-bottom: 40px; }
  .look-grid { grid-template-columns: repeat(4, 1fr); }
  .tl-hint { display: none; }
  .tl-head { justify-content: space-between; }
}

@media (max-width: 640px) {
  .bar { padding: 0 10px; gap: 6px; }
  .brand-copy span, .doc-name, .bar-links a:first-child { display: none; }
  .bar-tools .icon-btn#btn-keys { display: none; }
  .bar-tools .btn.primary span { display: none; }
  .bar-tools .btn.primary { padding: 0 11px; }
  .welcome { width: calc(100% - 32px); padding-top: 32px; }
  .features { grid-template-columns: 1fr; }
  .sample-card canvas { height: 170px; }

  .look-grid { grid-template-columns: repeat(3, 1fr); }
  .src-row { grid-template-columns: 1fr; }
  .fmt-grid { grid-template-columns: 1fr; }
  .tl-keybtn { font-size: 0; gap: 0; padding: 0 10px; }
  .tl-keybtn .tl-diamond { width: 10px; height: 10px; }
  .timeline { padding: 10px 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
