:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #181a20;
  --panel-strong: #20232b;
  --line: #313641;
  --text: #f3f5f8;
  --muted: #a8b0bf;
  --soft: #707989;
  --accent: #d946ef;
  --accent-2: #8b5cf6;
  --danger: #f97373;
  --ok: #4ade80;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(217, 70, 239, 0.12), transparent 34rem),
    linear-gradient(180deg, #0f1013 0%, #15161a 100%);
  color: var(--text);
}

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

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 16px;
}

.app-header {
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  max-width: 600px;
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.model-panel,
.status-console,
.workspace,
.warning {
  border: 1px solid var(--line);
  background: rgba(24, 26, 32, 0.88);
  box-shadow: var(--shadow);
}

.model-panel {
  display: grid;
  min-width: 0;
  max-width: none;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
}

.model-panel label,
.status-label,
.field > span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

/* Workspace two-column layout: main content + sidebar */
.workspace-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
}

.workspace-main {
  min-width: 0;
}

.workspace-sidebar {
  display: grid;
  gap: 14px;
  padding: 14px;
  align-content: start;
  border-left: 1px solid var(--line);
}

.tab-side {
  display: none;
}

.tab-side.active {
  display: grid;
  gap: 12px;
  align-content: start;
}

.model-summary-grid {
  display: grid;
  gap: 10px;
}

.model-summary-card {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(32, 35, 43, 0.75);
}

.model-summary-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Model size info row */
.model-size-row {
  min-height: 1.4em;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
}

.gpu-status-row {
  min-height: 1.4em;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
}

.model-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.status-pending {
  color: var(--muted);
}

.status-ok {
  color: var(--ok);
}

.status-warn {
  color: #e8a045;
}

.status-error {
  color: var(--danger);
}

.model-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.gpu-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.gpu-controls span,
.progress-detail {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-progress {
  display: grid;
  gap: 7px;
}

.runtime-log-panel {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111319;
}

.runtime-log-panel summary {
  cursor: pointer;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.runtime-log {
  max-height: 220px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border-top: 1px solid var(--line);
  color: #d7deea;
  font-size: 0.76rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #0f1116;
  border: 1px solid var(--line);
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 180ms ease;
}

.warning {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-color: rgba(249, 115, 115, 0.42);
  border-radius: 8px;
  color: #ffd6d6;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.workspace {
  overflow: hidden;
  border-radius: 8px;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(32, 35, 43, 0.82);
}

.tab-button {
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
}

.tab-button:hover,
.tab-button:focus-visible {
  color: var(--text);
  outline: none;
}

.tab-button.active {
  color: var(--text);
  background: linear-gradient(180deg, rgba(217, 70, 239, 0.18), rgba(139, 92, 246, 0.1));
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.two-columns {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.38fr);
}

.form-stack,
.side-panel,
.result-panel {
  display: grid;
  gap: 12px;
}

.side-panel {
  align-content: start;
}

.design-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.compact {
  gap: 7px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111318;
  color: var(--text);
  outline: none;
}

textarea,
input[type="text"],
input[type="number"],
select {
  min-height: 42px;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(217, 70, 239, 0.72);
  box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.12);
}

input[type="file"] {
  padding: 10px;
}

input[type="range"] {
  accent-color: var(--accent);
}

output {
  color: var(--soft);
  font-size: 0.82rem;
}


.reference-player {
  min-height: 190px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  line-height: 1.35;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.advanced,
.instruct-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.advanced summary,
.instruct-box summary {
  padding: 13px 14px;
  cursor: pointer;
  font-weight: 800;
}

.instruct-box .field {
  padding: 0 14px 14px;
}

.advanced-grid {
  display: grid;
  gap: 14px;
  padding: 0 14px 14px;
}

.generate-button,
.load-model-button,
.secondary-button,
.download-link {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
}

.generate-button {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) var(--generate-progress, 0%), transparent var(--generate-progress, 0%)),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  overflow: hidden;
}

.generate-button.is-generating {
  opacity: 1;
}

.generate-button.is-stop-ready {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) var(--generate-progress, 0%), transparent var(--generate-progress, 0%)),
    linear-gradient(135deg, #ef4444, #b91c1c);
}

.generate-button.is-stopping {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) var(--generate-progress, 0%), transparent var(--generate-progress, 0%)),
    linear-gradient(135deg, #b91c1c, #7f1d1d);
}

.setting-check {
  align-items: start;
  min-height: 42px;
  padding: 10px 0 0;
}

.load-model-button {
  min-height: 42px;
  padding: 0 14px;
  background: var(--panel-strong);
  border: 1px solid rgba(217, 70, 239, 0.5);
}

.secondary-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #111318;
  color: var(--muted);
}

.generate-button:disabled,
.load-model-button:disabled,
.secondary-button:disabled,
.download-link.disabled {
  cursor: not-allowed;
  opacity: 0.45;
  pointer-events: none;
}

.generate-button.is-generating:disabled {
  opacity: 1;
}

.result-panel > .download-link {
  display: none;
}

.daggr-audio-player {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 6px;
  background: #1f2b38;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.daggr-audio-ui {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.daggr-audio-header,
.daggr-time-row,
.daggr-controls {
  display: flex;
  align-items: center;
}

.daggr-audio-header {
  justify-content: space-between;
  gap: 12px;
}

.daggr-audio-title {
  overflow: hidden;
  max-width: min(100%, 420px);
  padding: 6px 9px;
  border-radius: 5px;
  background: linear-gradient(135deg, #5b5cf6, #6d4ff4);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 850;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daggr-audio-title::before {
  content: "♪";
  margin-right: 6px;
}

.daggr-audio-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.daggr-audio-action,
.daggr-control {
  border: 0;
  color: #c8d1df;
  cursor: pointer;
}

.daggr-audio-action {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 4px;
  background: #1a2531;
  font-size: 0.96rem;
  text-decoration: none;
}

.daggr-audio-action[hidden] {
  display: none;
}

.daggr-waveform {
  display: block;
  width: 100%;
  height: 92px;
  border-radius: 4px;
  background: #1f2b38;
  cursor: pointer;
}

.daggr-audio-player.is-empty .daggr-waveform {
  cursor: default;
}

.daggr-time-row {
  justify-content: space-between;
  color: #c2cbd8;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.daggr-crop-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  color: #c2cbd8;
  font-size: 0.76rem;
}

.daggr-crop-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daggr-crop-button {
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(203, 213, 225, 0.38);
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.28);
  color: #d6dce7;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
}

.daggr-crop-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.daggr-controls {
  justify-content: center;
  gap: 18px;
  min-height: 34px;
}

.daggr-control {
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  background: transparent;
  font-weight: 800;
}

.daggr-control:hover,
.daggr-control:focus-visible,
.daggr-audio-action:hover,
.daggr-audio-action:focus-visible {
  color: #fff;
  outline: none;
}

.daggr-control:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.daggr-play {
  color: #aeb7c6;
  font-size: 1.7rem;
  line-height: 1;
}

.daggr-rate {
  min-width: 38px;
  min-height: 22px;
  border: 1px solid rgba(203, 213, 225, 0.6);
  border-radius: 3px;
  color: #d6dce7;
  font-size: 0.76rem;
  line-height: 1;
}

.native-audio {
  display: none;
}

.status-console {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 8px;
}

.status-console > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 14px;
  background: rgba(32, 35, 43, 0.75);
}

.status-console strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-footer {
  padding: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 14px;
  }

  .two-columns,
  .design-grid {
    grid-template-columns: 1fr;
  }

  .workspace-body {
    grid-template-columns: 1fr;
  }

  .workspace-sidebar {
    border-left: none;
    border-top: 1px solid var(--line);
    padding: 12px;
  }

  .model-actions {
    grid-template-columns: 1fr;
  }

  .model-panel {
    min-width: 0;
    max-width: 100%;
  }

  .model-controls {
    grid-template-columns: 1fr;
  }

  .gpu-controls {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab-button {
    flex: 1 0 max-content;
    padding: 0 16px;
  }

  .tab-panel {
    padding: 12px;
  }

  .status-console {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: calc(100% - 16px);
  }

  .tab-panel {
    padding: 10px;
  }

  .status-console {
    grid-template-columns: 1fr;
  }
}
