@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap");

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f8f9ff;
  --line: #e5e7ef;
  --line-strong: #d6dae6;
  --text: #111827;
  --body: #374151;
  --muted: #6b7280;
  --brand-blue: #3b3bff;
  --brand-blue-soft: rgba(59, 59, 255, 0.08);
  --brand-red: #ef2f55;
  --brand-red-hover: #dc1f46;
  --brand-green: #00a466;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow-sm: 0 4px 16px -12px rgb(17 24 39 / 0.2);
  --shadow-card: 0 12px 28px -22px rgb(17 24 39 / 0.28);
  --ease: 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: Inter, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  overflow: hidden;
}

a {
  color: var(--brand-blue);
}

a:hover {
  color: #2f2fdd;
}

h1,
h2,
h3,
h4,
h5,
p {
  margin: 0;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

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

.studio-shell {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

.studio-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  z-index: 30;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 16px 16px;
  gap: 18px;
}

.sidebar-brand {
  padding: 2px 8px;
}

.academy-logo {
  width: min(228px, 100%);
  height: auto;
  display: block;
  margin: 0 0 6px;
}

.brand-mark {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-blue);
  font-weight: 800;
  margin-bottom: 3px;
}

.topbar-title {
  font-size: 28px;
  line-height: 1.05;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.main-tab-button {
  width: 100%;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  transition:
    border-color var(--ease),
    background-color var(--ease),
    color var(--ease),
    box-shadow var(--ease);
}

.main-tab-button:hover {
  border-color: #d9dded;
  background: #f9fafe;
  color: var(--text);
}

.main-tab-button.active,
.main-tab-button[aria-current="page"] {
  border-color: var(--brand-blue);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(59, 59, 255, 0.18);
  background: #fff;
}

.nav-icon {
  width: 18px;
  min-width: 18px;
  text-align: center;
  font-size: 15px;
  line-height: 1;
}

.nav-label {
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
}

.settings-btn {
  margin-top: 0;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-btn {
  text-decoration: none;
  border-color: rgba(37, 211, 102, 0.35);
}

.help-btn:hover {
  border-color: rgba(37, 211, 102, 0.75);
  box-shadow: inset 0 0 0 1px rgba(37, 211, 102, 0.24);
}

.studio-grid {
  margin-left: 280px;
  height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.studio-topbar {
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 28px;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-chip {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.studio-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 28px 20px;
}

.status-banner {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--body);
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.35;
}

.status-banner:empty {
  display: none;
}

.status-banner.warn {
  border-color: rgba(239, 47, 85, 0.45);
  color: #b51f3f;
  background: rgba(239, 47, 85, 0.03);
}

.main-panel,
.sub-tab-panel,
.run-view-panel {
  display: none;
}

.main-panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.main-panel.active {
  display: flex;
  flex-direction: column;
}

.sub-tab-panel.active,
.run-view-panel.active {
  display: block;
}

#main-create .sub-tab-panel.active,
#main-runs .sub-tab-panel.active,
#main-voice .sub-tab-panel.active,
#main-admin .sub-tab-panel.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.library-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.library-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.library-sync-bar {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.library-sync-bar .subtle {
  flex: 1;
}

.library-filters label {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.library-filters input,
.library-filters select {
  height: 36px;
}

.library-filters input {
  width: min(340px, 100%);
}

.library-filters select {
  width: 180px;
}

#library-scope-filter {
  width: 230px;
}

.library-metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-height: 78px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.library-metric-value {
  color: var(--text);
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
}

.library-metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.library-metric.library-meta {
  align-content: flex-start;
  gap: 5px;
}

.warn-copy {
  color: #b02644;
}

.library-shelf {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.library-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 0.42fr) minmax(0, 1fr);
  gap: 10px;
}

.library-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-height: 146px;
  padding: 12px;
  display: grid;
  align-content: flex-start;
  gap: 7px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font: inherit;
  line-height: 1.35;
}

button.library-item {
  appearance: none;
  border: 1px solid var(--line);
}

.library-item:disabled {
  cursor: default;
}

.library-item-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.library-list-header {
  padding: 0 2px;
}

.library-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.library-pagination .ghost-btn {
  min-height: 30px;
  padding: 0 10px;
}

.library-item.active {
  border-color: var(--brand-blue);
}

.library-item:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

.library-item-footer {
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.library-item .ghost-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.library-tag {
  display: inline-flex;
  border: 1px solid #dce1ef;
  border-radius: 999px;
  background: #f7f9ff;
  color: #526079;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  margin: 0 4px 4px 0;
}

.library-detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  min-height: 0;
  overflow: auto;
}

.library-assets-list {
  display: grid;
  gap: 10px;
}

.library-asset-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.library-export-panel {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.library-export-panel h5 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.library-run-links {
  display: grid;
  gap: 10px;
}

.library-run-links h5 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.library-run-link {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.library-resource-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.library-resource-section h5 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.resource-link-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.resource-link-list li {
  margin: 0;
  font-size: 12px;
  color: var(--body);
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.sub-tab-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.sub-tab-button {
  border: 0;
  border-radius: 999px;
  background: #eef1f8;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  min-height: 34px;
  padding: 0 16px;
  transition:
    color var(--ease),
    background-color var(--ease),
    transform var(--ease);
}

.sub-tab-button:hover {
  color: var(--text);
}

.sub-tab-button.active {
  background: #111827;
  color: #fff;
}

.wizard-panel {
  flex: 1;
  min-height: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}

.wizard-panel.compact {
  padding: 22px;
}

.wizard-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.eyebrow {
  color: var(--brand-blue);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
}

.wizard-header h2 {
  font-size: 42px;
  line-height: 1.06;
  letter-spacing: -0.03em;
  font-weight: 900;
  color: var(--text);
  text-wrap: balance;
}

.wizard-copy {
  color: var(--muted);
  font-size: 14px;
  margin-top: 2px;
}

.wizard-stepper {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.step-btn {
  border: 2px solid var(--line);
  border-right-width: 1px;
  background: #fff;
  min-height: 72px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  transition:
    border-color var(--ease),
    background-color var(--ease);
}

.step-btn:first-child {
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
}

.step-btn:last-child {
  border-right-width: 2px;
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
}

.step-btn:not(.active):hover {
  border-color: #cfd5e7;
}

.step-btn.active {
  border-color: var(--brand-blue);
  background: #fff;
}

.step-num {
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  font-weight: 900;
}

.step-text {
  color: #4b5563;
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
}

.wizard-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #eceef8;
  overflow: hidden;
}

.wizard-progress-bar {
  width: 33.33%;
  height: 100%;
  background: var(--brand-blue);
  border-radius: inherit;
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.wizard-form {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.wizard-step-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.wizard-step-panel.active {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  padding: 10px 12px;
  transition:
    border-color var(--ease),
    box-shadow var(--ease);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(59, 59, 255, 0.12);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #9aa2b5;
}

textarea {
  resize: none;
}

.url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.source-hero {
  width: min(860px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.source-hero-icon,
.generate-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--brand-blue-soft);
  color: var(--brand-blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
}

.hero-title {
  color: var(--text);
  font-size: 34px;
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.step-source-main {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}

.hero-url-row {
  width: 100%;
  margin-top: 2px;
}

.step-source-bottom {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-source-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.manual-source textarea {
  height: 100px;
}

.source-side-panel {
  border-left: 1px solid var(--line);
  padding-left: 16px;
}

.headline-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.headline-row input {
  height: 42px;
}

.field-help.spacer {
  visibility: hidden;
}

.fetch-skeleton {
  width: min(860px, 100%);
  background: #f7f8fc;
  border: 1px solid #e8ebf5;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.skeleton-line {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e5e9f5 0%, #f4f6fc 50%, #e5e9f5 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.w-40 {
  width: 40%;
}

.w-60 {
  width: 60%;
}

.w-70 {
  width: 70%;
}

.w-80 {
  width: 80%;
}

.w-90 {
  width: 90%;
}

.voice-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f1f3fb;
  color: #3f4454;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
}

.channels {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.channel-pill {
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-height: 182px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition:
    border-color var(--ease),
    box-shadow var(--ease);
}

.channel-pill:has(input[type="checkbox"]:checked) {
  border-color: var(--brand-blue);
  box-shadow: inset 0 0 0 1px rgba(59, 59, 255, 0.18);
}

.channel-main {
  display: block;
}

.channel-main input[type="checkbox"] {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand-blue);
}

.channel-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 20px;
}

.channel-name {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.channel-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.channel-count {
  margin-top: auto;
}

.channel-count input[type="number"] {
  width: 74px;
  height: 30px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
}

.generate-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 4px 0;
}

.generate-main .field-help {
  max-width: 620px;
  font-size: 15px;
}

.step-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.step-source-bottom .step-actions {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.step-actions-end {
  justify-content: flex-end;
}

.step-actions-start {
  justify-content: flex-start;
}

button,
.primary-btn,
.secondary-btn,
.ghost-btn {
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  min-height: 40px;
  padding: 0 16px;
  transition:
    transform var(--ease),
    background-color var(--ease),
    border-color var(--ease),
    box-shadow var(--ease),
    color var(--ease);
}

button:disabled,
.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button:not(:disabled):hover,
.primary-btn:not(:disabled):hover,
.secondary-btn:not(:disabled):hover,
.ghost-btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #fff;
  box-shadow: 0 12px 24px -18px rgba(59, 59, 255, 0.85);
}

.primary-btn:hover {
  background: #3232e9;
  border-color: #3232e9;
}

.secondary-btn {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: #fff;
  box-shadow: 0 12px 24px -20px rgba(239, 47, 85, 0.85);
}

.secondary-btn:hover {
  background: var(--brand-red-hover);
  border-color: var(--brand-red-hover);
}

.ghost-btn {
  background: transparent;
  border-color: #d7dcea;
  color: #5c6579;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: #c7cee0;
  background: #f8f9fd;
}

.start-btn {
  min-width: 164px;
  border-radius: 999px;
  font-weight: 800;
}

.fetch-btn {
  min-width: 168px;
  min-height: 48px;
}

.continue-btn {
  min-width: 116px;
}

.generate-btn {
  width: min(520px, 100%);
  min-height: 56px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 800;
}

details {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 10px 12px;
}

details summary {
  cursor: pointer;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
}

details > * + * {
  margin-top: 10px;
}

.inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4b5563;
}

.inline-checkbox input {
  accent-color: var(--brand-blue);
}

.runs-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.runs-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.runs-metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.runs-metric-value {
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  color: var(--text);
}

.runs-metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.runs-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.runs-filters label {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.runs-filters select,
.runs-filters input {
  height: 36px;
}

.runs-filters select {
  width: 164px;
}

.runs-filters input {
  width: min(340px, 100%);
}

.runs-layout {
  display: grid;
  grid-template-columns: minmax(350px, 0.4fr) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  flex: 1;
}

#runs-list,
#run-detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  overflow: auto;
  min-height: 0;
  max-height: min(66vh, 760px);
}

#run-detail {
  display: block;
}

.run-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 6px;
  transition: border-color var(--ease);
}

.run-item + .run-item {
  margin-top: 8px;
}

.run-item:hover {
  border-color: rgba(59, 59, 255, 0.35);
}

.run-item.active {
  border-color: var(--brand-blue);
}

.run-item p {
  color: #4b5563;
  font-size: 13px;
}

.run-item p:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.run-item p strong {
  color: var(--text);
}

.run-item button[data-action="open-run"] {
  border: 0;
  background: transparent;
  color: var(--brand-blue);
  font-size: 13px;
  font-weight: 700;
  padding: 0;
  min-height: 0;
}

.empty-state-card {
  border: 1px dashed #ccd2e4;
  border-radius: 12px;
  background: #fbfcff;
  padding: 18px;
  display: grid;
  gap: 10px;
}

.empty-state-illustration {
  display: flex;
  gap: 8px;
  color: #7f87a1;
  font-size: 18px;
}

.status-chip,
.status-pill {
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 800;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-chip.processing,
.status-chip.queued,
.status-pill.processing,
.status-pill.queued {
  background: rgba(59, 59, 255, 0.1);
  color: var(--brand-blue);
  border-color: rgba(59, 59, 255, 0.24);
}

.status-chip.completed,
.status-pill.completed {
  background: rgba(0, 164, 102, 0.1);
  color: #0f8d5b;
  border-color: rgba(0, 164, 102, 0.25);
}

.status-chip.failed,
.status-pill.failed {
  background: rgba(239, 47, 85, 0.08);
  color: #bb2748;
  border-color: rgba(239, 47, 85, 0.25);
}

.status-chip.canceled,
.status-pill.canceled {
  background: #eef1f8;
  color: #6b7280;
  border-color: #d6dbea;
}

.playbook-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.playbook-toolbar label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.playbook-toolbar input {
  width: min(280px, 100%);
  height: 36px;
}

.playbook-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.playbook-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  min-height: 0;
}

#voice-packs {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.playbook-item {
  border: 2px solid transparent;
  border-radius: 10px;
  background: #f6f8ff;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
  min-height: 38px;
  padding: 0 12px;
  text-align: left;
}

.playbook-item:hover {
  color: var(--text);
}

.playbook-item.active {
  border-color: var(--brand-blue);
  background: #fff;
  color: var(--text);
}

.playbook-editor-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.playbook-preview-gallery,
.playbook-grounding {
  display: grid;
  gap: 10px;
}

.playbook-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.playbook-preview-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.playbook-preview-card.active {
  border-color: var(--brand-blue);
}

.preview-chip {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: var(--brand-blue-soft);
  color: var(--brand-blue);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
}

.playbook-preview-card h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.playbook-preview-card p {
  color: #4b5563;
  font-size: 13px;
  line-height: 1.45;
}

.voice-card,
.voice-pack-item,
.function-card,
.detail-card,
.asset-item,
.citation-item,
.export-item,
.log-item,
.workspace-file-item,
.grounding-doc,
.preview-log,
.preview-asset,
.usage-log-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.voice-pack-item {
  margin-bottom: 8px;
}

.voice-pack-item.active {
  border-color: var(--brand-blue);
  box-shadow: inset 0 0 0 1px rgba(59, 59, 255, 0.16);
}

.voice-sample {
  margin: 0;
  border-left: 3px solid rgba(59, 59, 255, 0.32);
  padding-left: 10px;
  color: #4b5563;
  font-style: italic;
  font-size: 13px;
}

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

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

.inline-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.function-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.function-card h3,
.detail-card h3,
.asset-item strong,
.usage-log-item strong {
  color: var(--text);
}

.technical-panel {
  border: 1px solid #e2e7f3;
  background: #f7f9ff;
}

.technical-panel pre,
.asset-content pre,
pre {
  margin: 0;
  border-radius: 10px;
  border: 1px solid #e0e6f4;
  background: #fbfcff;
  color: #1f2937;
  font-size: 12px;
  line-height: 1.5;
  max-width: 100%;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}

.asset-content summary {
  font-size: 12px;
}

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

.detail-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid #d5daea;
  background: #fff;
  color: #4b5563;
}

.detail-actions button:not(:disabled):hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.run-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.run-view-button {
  border: 1px solid #d3d9ea;
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.run-view-button.active {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  background: rgba(59, 59, 255, 0.08);
}

.playbook-grounding h3 {
  font-size: 14px;
  font-weight: 800;
}

.usage-log-list {
  display: grid;
  gap: 8px;
}

.preview-sidebar {
  display: none !important;
}

.preview-panel {
  display: grid;
  gap: 8px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-header h2 {
  font-size: 16px;
  font-weight: 800;
}

.preview-meta,
.preview-stream,
.summary-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
}

.auth-lock-note {
  border: 1px solid rgba(239, 47, 85, 0.28);
  border-radius: 12px;
  background: rgba(239, 47, 85, 0.04);
  padding: 12px;
  display: grid;
  gap: 6px;
}

.auth-lock-note h3 {
  color: #b02644;
  font-size: 13px;
  font-weight: 800;
}

.auth-lock-note p {
  color: #5f6679;
  font-size: 13px;
  line-height: 1.45;
}

.hidden-form {
  display: none;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(17, 24, 39, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.busy-overlay.hidden {
  display: none;
}

.busy-card {
  width: min(460px, 100%);
  border-radius: 16px;
  border: 1px solid #d9dff0;
  background: #fff;
  box-shadow: var(--shadow-card);
  padding: 18px;
  display: grid;
  gap: 10px;
}

.busy-card h3 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 3px solid rgba(59, 59, 255, 0.18);
  border-top-color: var(--brand-blue);
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.busy-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #eceef8;
  overflow: hidden;
}

.busy-progress-bar {
  width: 5%;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-blue);
  transition: width 300ms ease;
}

.busy-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 1400px) {
  .channels {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .playbook-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .studio-sidebar {
    width: 240px;
  }

  .studio-grid {
    margin-left: 240px;
  }

  .wizard-header h2 {
    font-size: 34px;
  }

  .step-source-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .source-side-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 12px;
  }

  .channels {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .runs-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .playbook-layout {
    grid-template-columns: 1fr;
  }

  .settings-grid,
  .function-grid {
    grid-template-columns: 1fr;
  }

  .library-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .library-layout {
    grid-template-columns: 1fr;
  }

  .runs-layout {
    grid-template-columns: 1fr;
  }

  #runs-list,
  #run-detail {
    max-height: none;
  }
}

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

  .studio-shell {
    min-height: 100%;
  }

  .studio-sidebar {
    position: static;
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 12px;
    gap: 10px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .main-tab-button {
    width: auto;
    min-width: 150px;
  }

  .settings-btn {
    margin-top: 0;
  }

  .sidebar-footer {
    margin-top: 0;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .sidebar-footer .main-tab-button {
    width: auto;
    min-width: 150px;
  }

  .studio-grid {
    margin-left: 0;
    height: auto;
    min-height: calc(100vh - 210px);
  }

  .studio-topbar {
    padding: 0 12px;
  }

  .studio-main {
    overflow: visible;
    padding: 10px 12px 16px;
  }

  .main-panel {
    overflow: visible;
  }

  #main-create .sub-tab-panel.active,
  #main-runs .sub-tab-panel.active,
  #main-voice .sub-tab-panel.active,
  #main-admin .sub-tab-panel.active {
    overflow: visible;
  }

  .wizard-panel,
  .wizard-panel.compact {
    overflow: visible;
    min-height: 0;
    padding: 14px;
  }

  .wizard-header h2 {
    font-size: 28px;
  }

  .hero-title {
    font-size: 28px;
  }

  .hero-url-row {
    grid-template-columns: 1fr;
  }

  .channels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 420px;
  }

  .runs-filters {
    align-items: flex-start;
    flex-direction: column;
  }

  .runs-filters input,
  .runs-filters select {
    width: 100%;
  }

  .library-filters {
    align-items: flex-start;
    flex-direction: column;
  }

  .library-sync-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .library-filters input,
  .library-filters select {
    width: 100%;
  }

  .runs-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .library-summary,
  .library-shelf {
    overflow: visible;
  }

  .library-detail {
    overflow: visible;
  }

  .playbook-preview-grid {
    grid-template-columns: 1fr;
  }

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