:root {
  --bg: #eef1f3;
  --panel: #fbfbfa;
  --panel-strong: #ffffff;
  --ink: #20242a;
  --muted: #69717c;
  --line: #d9dee3;
  --line-strong: #bac3cc;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --warn: #ef4444;
  --shadow: 0 16px 38px rgba(22, 29, 37, 0.14);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

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

button {
  color: inherit;
}

.app-shell {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0) 240px),
    var(--bg);
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 250, 0.94);
  backdrop-filter: blur(18px);
  z-index: 5;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #1f2937;
  border-radius: 8px;
  background: #242832;
  color: #f9fafb;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 14px;
  line-height: 1.1;
}

.brand-copy span {
  min-height: 14px;
  font-size: 11px;
  color: var(--muted);
}

.board-name {
  flex: 1 1 260px;
  min-width: 140px;
  max-width: 420px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
  outline: none;
}

.board-name:focus,
select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14);
}

.topbar-group,
.timeline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.compact-selects label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

select,
.text-field,
.number-field,
.textarea-field {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

select {
  padding: 0 28px 0 9px;
}

.text-field,
.number-field {
  width: 100%;
  padding: 0 10px;
}

.textarea-field {
  width: 100%;
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
}

.icon-btn,
.text-btn,
.tool-btn,
.segmented button,
.scene-chip {
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.icon-btn:hover,
.text-btn:hover,
.tool-btn:hover,
.segmented button:hover,
.scene-chip:hover {
  background: rgba(13, 148, 136, 0.09);
  border-color: rgba(13, 148, 136, 0.18);
}

.icon-btn:active,
.text-btn:active,
.tool-btn:active,
.scene-chip:active {
  transform: translateY(1px);
}

.icon-btn:disabled,
.text-btn:disabled {
  opacity: 0.36;
  cursor: default;
}

.icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.24);
  color: var(--warn);
}

.text-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.24);
  color: var(--warn);
}

.text-btn {
  min-width: 48px;
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 320px;
  gap: 10px;
  padding: 10px;
}

.tool-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(28, 35, 43, 0.08);
}

.tool-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #3f4650;
}

.tool-btn.is-active {
  background: #1f2937;
  border-color: #1f2937;
  color: #f8fafc;
}

.tool-glyph {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
}

.board-area {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.stage-bar {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.segmented {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f3f5f6;
}

.segmented button {
  min-width: 48px;
  height: 30px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.segmented button.is-active {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(20, 30, 38, 0.08);
}

.metric-strip {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-strip span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.metric-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.zoom-control input {
  width: 94px;
  accent-color: var(--accent);
}

.pitch-wrap {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 16% 20%, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0) 26%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.64), rgba(224, 229, 233, 0.78));
  overflow: hidden;
}

.pitch-svg {
  width: min(100%, 1180px);
  height: auto;
  max-height: 100%;
  aspect-ratio: 100 / 64;
  border-radius: 8px;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
}

.pitch-wrap.is-vertical .pitch-svg {
  width: auto;
  height: min(100%, 760px);
  aspect-ratio: 64 / 100;
}

.inspector {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(28, 35, 43, 0.08);
}

.inspector h2,
.inspector h3 {
  margin: 0;
  letter-spacing: 0;
}

.inspector h2 {
  font-size: 15px;
}

.inspector h3 {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.inspector-section {
  display: grid;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.inspector-section:first-child {
  padding-top: 0;
}

.inspector-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-row {
  display: grid;
  gap: 6px;
}

.field-row label,
.field-label {
  color: var(--muted);
  font-size: 12px;
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.swatch {
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
}

.swatch.is-active {
  box-shadow:
    0 0 0 2px #1f2937,
    0 0 0 5px rgba(13, 148, 136, 0.2);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.range-row input {
  width: 100%;
  accent-color: var(--accent);
}

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

.small-btn {
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.small-btn:hover {
  border-color: rgba(13, 148, 136, 0.32);
  color: var(--accent-strong);
}

.small-btn.danger:hover {
  border-color: rgba(239, 68, 68, 0.32);
  color: var(--warn);
}

.timeline {
  min-height: 72px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(251, 251, 250, 0.96);
  z-index: 4;
}

.scene-strip {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.scene-chip {
  position: relative;
  flex: 0 0 160px;
  height: 50px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-color: var(--line);
  background: #fff;
  text-align: left;
}

.scene-chip.is-active {
  border-color: rgba(13, 148, 136, 0.62);
  box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.28);
}

.scene-index {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #242832;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.scene-meta {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.scene-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.scene-meta span {
  color: var(--muted);
  font-size: 11px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translate(-50%, 16px);
  min-width: 180px;
  max-width: min(420px, calc(100vw - 24px));
  padding: 10px 14px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: rgba(31, 41, 55, 0.94);
  color: #fff;
  text-align: center;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  z-index: 20;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1180px) {
  .topbar {
    flex-wrap: wrap;
  }

  .board-name {
    max-width: none;
  }

  .workspace {
    grid-template-columns: 58px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .inspector {
    grid-column: 2;
    max-height: 230px;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100vh;
    height: auto;
  }

  .topbar {
    align-items: stretch;
  }

  .brand-lockup {
    min-width: 132px;
  }

  .compact-selects {
    width: 100%;
    justify-content: space-between;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(360px, 1fr) auto;
  }

  .tool-rail {
    flex-direction: row;
    justify-content: center;
    overflow-x: auto;
  }

  .board-area {
    min-height: 440px;
  }

  .stage-bar {
    flex-wrap: wrap;
  }

  .metric-strip {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .pitch-wrap {
    padding: 8px;
  }

  .inspector {
    grid-column: auto;
  }

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

  .timeline-actions {
    width: fit-content;
  }
}
