:root {
  color-scheme: dark;
  font-family: Inter, "Noto Sans SC", ui-sans-serif, system-ui, sans-serif;
  color: #edf4f4;
  background: #080b10;
  font-synthesis: none;
  --surface: #10151d;
  --line: #25303d;
  --line-bright: #354455;
  --muted: #8997a7;
  --mint: #65d6b4;
  --danger: #ef7c78;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 12% -5%, rgba(70, 164, 139, .13), transparent 30rem),
    radial-gradient(circle at 86% -10%, rgba(93, 123, 201, .12), transparent 28rem),
    #080b10;
}
button, select, input, textarea { font: inherit; }
button, .button {
  min-height: 34px;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  padding: 7px 11px;
  color: #e7eeef;
  background: #19212c;
  cursor: pointer;
  transition: .15s border-color, .15s background, .15s transform;
}
button:hover:not(:disabled), .button:hover { border-color: #52677e; background: #202b38; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary, .button.primary { border-color: #438f7b; background: #26735f; }
button.primary:hover:not(:disabled) { border-color: #69d1b2; background: #2e8770; }
button.quiet, .button.quiet { background: transparent; }
button.danger { color: #ffaaa6; border-color: rgba(239, 124, 120, .35); background: rgba(128, 45, 45, .13); }
button.text-button { min-height: 0; border: 0; padding: 4px; color: var(--muted); background: transparent; }
button.wide { width: 100%; }

.topbar, .statusbar, .studio, footer {
  width: min(1720px, calc(100% - 32px));
  margin-inline: auto;
}
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand, .brand-line, .toolbar, .statusbar > div, .panel-head, .transport, .timeline-actions, .drawer-head, .drawer-actions, .clip-actions {
  display: flex;
  align-items: center;
}
.brand { gap: 12px; flex: none; }
.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(101, 214, 180, .46);
  border-radius: 11px;
  color: var(--mint);
  background: rgba(49, 136, 109, .1);
  font: 22px/1 Georgia, serif;
}
.brand-line { gap: 9px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 19px; letter-spacing: -.02em; }
h2 { margin-top: 4px; font-size: 15px; }
h3 { font-size: 13px; }
.brand p { margin-top: 2px; color: var(--muted); font-size: 11px; }
.version {
  padding: 3px 7px;
  border: 1px solid rgba(101, 214, 180, .32);
  border-radius: 999px;
  color: var(--mint);
  background: rgba(49, 136, 109, .09);
  font: 10px/1.2 ui-monospace, monospace;
}
.toolbar { justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.select-control {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 10px;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  color: var(--muted);
  background: #141b24;
  font-size: 11px;
}
select {
  border: 0;
  outline: 0;
  padding: 0 25px 0 2px;
  color: #e3ebed;
  background: transparent;
}
.file-button { position: relative; display: inline-grid; place-items: center; font-size: 13px; }
.file-button input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }

.statusbar {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 2px;
  border-top: 1px solid rgba(53, 68, 85, .35);
  color: var(--muted);
  font-size: 11px;
}
.statusbar > div { gap: 10px; }
.state { padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: #c9d1d6; }
.state::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.state.ready::before { background: var(--mint); box-shadow: 0 0 8px rgba(101, 214, 180, .7); }
.state.working::before { background: #f0b768; animation: pulse 1s infinite alternate; }
.state.error { color: #ffaaa6; }
.state.error::before { background: var(--danger); }
@keyframes pulse { to { opacity: .35; } }

.studio {
  min-height: calc(100vh - 154px);
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(540px, 1fr) minmax(290px, 340px);
  gap: 10px;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(16, 21, 29, .96);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .13);
}
.library-panel, .inspector-panel { padding: 15px; overflow: auto; }
.panel-head { justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.eyebrow { color: var(--mint); font: 9px/1.2 ui-monospace, monospace; letter-spacing: .16em; }
.count, .section-title > span {
  min-width: 25px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
  font: 10px/1 ui-monospace, monospace;
}
.panel-copy, .timeline-help { color: var(--muted); font-size: 11px; line-height: 1.55; }
.panel-copy { margin: -2px 0 14px; }

.timbre-list { display: grid; gap: 7px; }
.timbre-card {
  position: relative;
  width: 100%;
  min-height: 63px;
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  overflow: hidden;
  text-align: left;
  background: #121923;
}
.timbre-card.selected { border-color: color-mix(in srgb, var(--accent) 58%, #344150); background: color-mix(in srgb, var(--accent) 8%, #121923); }
.timbre-accent { align-self: stretch; border-radius: 999px; background: var(--accent); }
.timbre-main { min-width: 0; display: grid; gap: 4px; }
.timbre-main strong { overflow: hidden; color: #eef4f4; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.timbre-main small, .node-count { color: var(--muted); font-size: 9px; }
.node-count { font-family: ui-monospace, monospace; }

.center-column { min-width: 0; display: grid; grid-template-rows: 190px minmax(420px, 1fr); gap: 10px; }
.transport-panel { padding: 12px 14px; }
.transport { gap: 8px; }
.round { width: 34px; padding: 0; border-radius: 50%; }
.time-readout { margin-left: 4px; color: #c9d3d7; font: 11px/1 ui-monospace, monospace; }
.time-readout i { padding: 0 7px; color: #536273; font-style: normal; }
audio { display: none; }
#waveform {
  display: block;
  width: 100%;
  height: 118px;
  margin-top: 11px;
  border: 1px solid #202b37;
  border-radius: 8px;
  background: #0c1118;
}
.timeline-panel { min-height: 0; display: flex; flex-direction: column; padding: 14px 0 10px; overflow: hidden; }
.timeline-panel > .panel-head, .timeline-help { margin-inline: 14px; }
.timeline-actions { gap: 7px; color: var(--muted); font: 10px/1 ui-monospace, monospace; }
.icon-button { width: 30px; min-height: 28px; padding: 0; font-size: 16px; }
.timeline-scroll { flex: 1; min-height: 300px; overflow: auto; border-block: 1px solid #202a35; background: #0d1219; }
.timeline { min-width: 100%; }
.ruler-row, .track-row { display: grid; grid-template-columns: 150px var(--canvas-width); }
.ruler-row { position: sticky; top: 0; z-index: 5; height: 30px; background: #0d1219; }
.ruler-label, .track-label {
  position: sticky;
  left: 0;
  z-index: 4;
  padding: 0 12px;
  border-right: 1px solid #27313d;
  background: #111720;
}
.ruler-label { display: flex; align-items: center; color: #607081; font: 8px/1 ui-monospace, monospace; letter-spacing: .13em; }
.ruler { position: relative; border-bottom: 1px solid #26313d; }
.ruler span { position: absolute; inset-block: 0; border-left: 1px solid #26313d; }
.ruler span i { display: block; height: 7px; border-left: 1px solid #607081; }
.ruler span b { position: absolute; top: 11px; left: 5px; color: #6f7e8e; font: 8px/1 ui-monospace, monospace; }
.track-row { min-height: 72px; border-bottom: 1px solid #202a35; }
.track-label { display: grid; align-content: center; gap: 5px; }
.track-label strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.track-label small { color: var(--muted); font-size: 9px; }
.track-lane {
  position: relative;
  min-height: 72px;
  background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(var(--pps) - 1px), rgba(52, 64, 78, .35) calc(var(--pps) - 1px), rgba(52, 64, 78, .35) var(--pps));
}
.clip {
  position: absolute;
  top: 11px;
  height: 50px;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--clip-color) 48%, #293443);
  border-left: 4px solid var(--clip-color);
  border-radius: 6px;
  color: #eaf0f1;
  text-align: left;
  touch-action: none;
  background: color-mix(in srgb, var(--clip-color) 13%, #17202a);
  user-select: none;
  cursor: grab;
}
.clip:active { cursor: grabbing; }
.clip:hover { background: color-mix(in srgb, var(--clip-color) 19%, #17202a); }
.clip.selected { outline: 1px solid var(--clip-color); outline-offset: 2px; }
.clip-content {
  min-width: 0;
  flex: 1;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 5px 4px;
  pointer-events: none;
}
.clip-handle {
  position: relative;
  z-index: 2;
  width: 8px;
  flex: 0 0 8px;
  cursor: ew-resize;
  touch-action: none;
}
.clip-handle::after {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--clip-color) 72%, white);
  opacity: .45;
}
.clip-handle.start::after { left: 3px; }
.clip-handle.end::after { right: 3px; }
.clip:hover .clip-handle::after,
.clip.selected .clip-handle::after { opacity: .95; }
.clip strong, .clip small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.clip strong { font-size: 10px; }
.clip small { color: #aebbc2; font: 8px/1 ui-monospace, monospace; }
.timeline-help { margin-top: 9px; }

.inspector { display: grid; gap: 14px; }
.summary-card {
  padding: 13px;
  border: 1px solid #283441;
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(101, 214, 180, .07), rgba(122, 162, 255, .04));
}
.summary-card .origin { color: var(--mint); font: 9px/1 ui-monospace, monospace; letter-spacing: .1em; }
.summary-card h3 { margin-top: 8px; font-size: 16px; }
.summary-card p { margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.name-input {
  width: 100%;
  margin-top: 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: 0;
  padding: 4px 0;
  color: #eef4f4;
  background: transparent;
  font-size: 16px;
  font-weight: 700;
}
.metrics, .descriptor, .observed dl { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 0; }
.metrics div, .descriptor div, .observed dl div { padding: 9px; border: 1px solid #26313d; border-radius: 7px; background: #0f151d; }
dt { color: var(--muted); font-size: 9px; }
dd { margin: 5px 0 0; color: #e5edef; font: 12px/1 ui-monospace, monospace; }
.section { display: grid; gap: 8px; padding-top: 3px; }
.section > h3, .section-title { margin-bottom: 2px; }
.section-title { display: flex; align-items: center; justify-content: space-between; }
.field-row { display: grid; grid-template-columns: minmax(70px, 1fr) 128px; align-items: center; gap: 8px; color: #c3cdd2; font-size: 11px; }
.field-row select, .number-wrap {
  min-height: 31px;
  border: 1px solid #303c4b;
  border-radius: 7px;
  background: #0e141c;
}
.field-row select { width: 100%; padding: 5px 8px; }
.number-wrap { display: flex; align-items: center; overflow: hidden; }
.number-wrap input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  padding: 6px 8px;
  color: #e3ecee;
  background: transparent;
  font: 11px/1 ui-monospace, monospace;
}
.number-wrap i { padding-right: 7px; color: var(--muted); font: 9px/1 ui-monospace, monospace; font-style: normal; }
.style-grid { display: grid; gap: 9px; }
.range-field { display: grid; grid-template-columns: 67px 1fr 43px; align-items: center; gap: 7px; color: #c3cdd2; font-size: 10px; }
input[type="range"] { width: 100%; accent-color: var(--mint); }
.range-field output { color: var(--muted); text-align: right; font: 9px/1 ui-monospace, monospace; }
.variant-list { display: grid; gap: 6px; }
.variant-list button { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; background: #111821; }
.variant-list button.prototype { border-color: rgba(101, 214, 180, .48); }
.variant-list small { color: var(--muted); font-size: 9px; }
.operation-cloud { display: flex; flex-wrap: wrap; gap: 5px; }
.operation-cloud span { padding: 5px 7px; border: 1px solid #283440; border-radius: 6px; color: #bdc9cf; background: #101720; font: 9px/1 ui-monospace, monospace; }
.operation-cloud b { margin-left: 3px; color: var(--mint); }
.observed { padding: 9px; border: 1px solid #26313d; border-radius: 8px; }
.observed summary { color: #bcc7cd; cursor: pointer; font-size: 10px; }
.observed dl { margin-top: 9px; }
.clip-actions { gap: 7px; }
.clip-actions button { flex: 1; }
.architecture { display: grid; grid-template-columns: auto 12px auto 12px auto; align-items: center; gap: 4px; color: #9ba9b4; font: 9px/1 ui-monospace, monospace; }
.architecture span, .architecture b { padding: 6px; border: 1px solid #293541; border-radius: 5px; text-align: center; }
.architecture b { grid-row: 2; font-weight: 400; }
.architecture i { color: #546475; font-style: normal; }

.source-drawer {
  position: fixed;
  z-index: 20;
  inset: 58px 3vw 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #39485a;
  border-radius: 12px;
  background: #0d131b;
  box-shadow: 0 28px 100px rgba(0, 0, 0, .65);
}
.drawer-head { min-height: 61px; justify-content: space-between; gap: 16px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.drawer-actions { gap: 8px; }
.drawer-view {
  min-height: 34px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  background: #141b24;
}
.drawer-view select { padding-left: 9px; }
#source-meta { color: var(--muted); font: 10px/1 ui-monospace, monospace; }
.source-feedback {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 10px 14px;
  border-bottom: 1px solid #3a2d32;
  color: #ffb2ad;
  background: rgba(109, 37, 42, .22);
}
.source-feedback.working {
  border-color: #3d372b;
  color: #e8c985;
  background: rgba(102, 75, 29, .18);
}
.source-feedback.success {
  border-color: #27463d;
  color: #8ce0c5;
  background: rgba(37, 105, 84, .15);
}
.feedback-dot {
  width: 7px;
  height: 7px;
  margin-top: 4px;
  border-radius: 50%;
  background: currentColor;
}
.source-feedback.working .feedback-dot { animation: pulse 1s infinite alternate; }
#source-feedback-text {
  min-width: 0;
  margin: 0;
  overflow: auto;
  color: inherit;
  font: 11px/1.5 ui-monospace, "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#source {
  flex: 1;
  width: 100%;
  resize: none;
  border: 0;
  outline: 0;
  padding: 20px;
  color: #dce8e9;
  background: #0e141c;
  caret-color: var(--mint);
  font: 13px/1.65 "SFMono-Regular", Consolas, monospace;
  tab-size: 2;
}
footer { min-height: 42px; display: flex; align-items: center; justify-content: space-between; color: #5f6d7b; font-size: 10px; }
.empty { color: var(--muted); font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 1180px) {
  .studio { grid-template-columns: 230px minmax(500px, 1fr); }
  .inspector-panel { grid-column: 1 / -1; max-height: none; }
  .inspector { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 820px) {
  .topbar { align-items: flex-start; flex-direction: column; padding-block: 12px; }
  .toolbar { justify-content: flex-start; }
  .studio { grid-template-columns: 1fr; }
  .library-panel { max-height: 310px; }
  .center-column { grid-template-rows: 185px minmax(430px, 1fr); }
  .inspector { grid-template-columns: 1fr; }
  .statusbar { align-items: flex-start; flex-direction: column; padding-block: 8px; }
}
@media (max-width: 560px) {
  .topbar, .statusbar, .studio, footer { width: calc(100% - 18px); }
  .toolbar > * { flex: 1; }
  .toolbar .select-control { flex-basis: 100%; }
  .ruler-row, .track-row { grid-template-columns: 110px var(--canvas-width); }
  .ruler-label, .track-label { padding-inline: 8px; }
  .source-drawer { inset: 8px; }
  .drawer-head { align-items: flex-start; flex-direction: column; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; }
}
