:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --bg: oklch(96.5% 0.006 86);
  --surface: oklch(99% 0.003 86);
  --surface-soft: oklch(97.5% 0.006 86);
  --line: oklch(88% 0.012 82);
  --line-strong: oklch(78% 0.023 78);
  --text: oklch(23% 0.018 74);
  --muted: oklch(50% 0.018 74);
  --faint: oklch(66% 0.014 74);
  --accent: oklch(47% 0.082 72);
  --accent-strong: oklch(38% 0.088 70);
  --accent-soft: oklch(92% 0.035 78);
  --danger: oklch(54% 0.16 28);
  --success: oklch(48% 0.12 145);
  --shadow: 0 18px 44px oklch(45% 0.024 74 / 0.08);
  --sidebar-bg: oklch(98.4% 0.004 86);
  --field-bg: oklch(99.5% 0.002 86);
  --active-bg: oklch(97% 0.012 76);
  --summary-cell: var(--surface-soft);
  --overlay: oklch(14% 0.012 74 / 0.32);
  --menu-bg: var(--surface);
  --media-badge-bg: oklch(24% 0.018 74 / 0.62);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(17% 0.012 74);
  --surface: oklch(22% 0.014 74);
  --surface-soft: oklch(26% 0.014 74);
  --line: oklch(34% 0.018 74);
  --line-strong: oklch(45% 0.03 76);
  --text: oklch(92% 0.006 82);
  --muted: oklch(70% 0.012 78);
  --faint: oklch(56% 0.014 78);
  --accent: oklch(68% 0.09 76);
  --accent-strong: oklch(78% 0.08 76);
  --accent-soft: oklch(30% 0.04 76);
  --danger: oklch(70% 0.14 28);
  --success: oklch(70% 0.12 145);
  --shadow: 0 18px 44px oklch(8% 0.012 74 / 0.24);
  --sidebar-bg: oklch(13.5% 0.011 74);
  --field-bg: oklch(18% 0.012 74);
  --active-bg: oklch(22% 0.03 76);
  --summary-cell: oklch(20% 0.012 74);
  --overlay: oklch(8% 0.012 74 / 0.58);
  --menu-bg: oklch(12.5% 0.012 74);
  --media-badge-bg: oklch(10% 0.012 74 / 0.72);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
  color: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.hidden { display: none !important; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand-area {
  position: relative;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.brand {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.brand-badge,
.title-icon,
.task-icon,
.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid oklch(84% 0.034 78);
}

.brand-badge {
  width: 36px;
  height: 36px;
  font-size: 13px;
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 19px;
  line-height: 1.15;
  color: var(--accent-strong);
  white-space: nowrap;
}

.brand small,
.account small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.theme-trigger {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  margin-right: 14px;
}

.theme-trigger:hover,
.theme-trigger[aria-expanded="true"] {
  background: var(--surface-soft);
  color: var(--text);
}

.theme-menu {
  position: absolute;
  left: 0;
  top: 64px;
  z-index: 15;
  width: 158px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--menu-bg);
  box-shadow: var(--shadow);
}

.theme-menu p {
  margin: 0 0 4px;
  padding: 3px 2px 6px;
  color: var(--muted);
  font-size: 12px;
}

.theme-option {
  width: 100%;
  min-height: 34px;
  display: grid;
  grid-template-columns: 12px 24px 1fr;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 0 6px;
  text-align: left;
}

.theme-option:hover {
  background: var(--surface-soft);
}

.theme-check {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}

.theme-option[aria-checked="true"] .theme-check {
  background: var(--text);
}

.theme-icon {
  color: var(--text);
  text-align: center;
}

.theme-option strong {
  font-size: 14px;
  font-weight: 650;
}

.nav-groups {
  flex: 1;
  padding: 18px 14px;
}

.nav-group + .nav-group {
  margin-top: 20px;
}

.nav-group p {
  margin: 0 10px 8px;
  color: var(--muted);
  font-size: 13px;
}

.nav-link {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  padding: 0 13px;
  text-align: left;
  color: var(--muted);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.nav-link:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-link.active {
  color: var(--accent-strong);
  border-color: oklch(60% 0.075 76);
  background: var(--active-bg);
  box-shadow: inset 0 0 0 1px oklch(76% 0.045 78 / 0.42), 0 8px 18px oklch(30% 0.045 74 / 0.08);
}

.nav-link.active::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--accent);
}

.line-icon {
  width: 21px;
  height: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  flex: 0 0 auto;
}

.line-icon svg,
.mini-line-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mini-line-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-strong);
  vertical-align: -3px;
}

.mini-line-icon svg {
  width: 17px;
  height: 17px;
}

.title-icon svg,
.task-icon svg,
.empty-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link:hover .line-icon {
  color: var(--text);
}

.nav-link.active .line-icon {
  color: var(--accent);
}

.sidebar-bottom {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.balance-card {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 10px 12px;
  text-align: left;
}

.balance-card span {
  color: var(--muted);
  font-size: 13px;
}

.balance-card strong {
  color: var(--accent-strong);
  font-size: 13px;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 8px 10px;
}

.avatar {
  width: 38px;
  height: 38px;
}

.workspace {
  min-width: 0;
  padding: 72px 28px 42px;
}

.view-panel {
  display: none;
  max-width: 1180px;
  margin: 0 auto;
}

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

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.page-header > div:first-child {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 0 12px;
  align-items: center;
}

.title-icon {
  width: 34px;
  height: 34px;
  grid-row: span 2;
}

h1, h2, h3, p {
  margin-top: 0;
}

.page-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
}

.page-header p {
  grid-column: 2;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost-button,
.gold-button,
.primary-button,
.mini-button,
.text-button,
.save-button {
  min-height: 38px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 14px;
  font-weight: 650;
}

.danger-button {
  color: var(--danger);
}

.danger-button.armed {
  border-color: var(--danger);
  background: oklch(96% 0.02 28);
}

.gold-button,
.primary-button,
.save-button {
  border-color: var(--accent);
  background: var(--accent);
  color: oklch(99% 0.004 76);
}

.primary-button {
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  font-size: 16px;
  box-shadow: 0 16px 28px oklch(42% 0.07 72 / 0.17);
}

.text-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  margin-top: 8px;
}

.mini-button {
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--accent-strong);
  white-space: nowrap;
  flex: 0 0 auto;
}

.summary-strip,
.filter-panel,
.composer-card,
.task-card,
.metric-grid > div,
.library-content {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 1px 2px oklch(45% 0.018 74 / 0.04);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 28px;
  overflow: hidden;
}

.summary-strip > div {
  min-height: 76px;
  padding: 16px 20px;
  background: var(--summary-cell);
}

.summary-strip > div + div {
  border-left: 1px solid oklch(92% 0.008 82);
}

.summary-strip span,
.metric-grid span,
.task-meta dt,
.estimate-list span,
.filter-panel span,
.field-label,
.form-grid label span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.summary-strip strong,
.metric-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 15px;
}

.summary-strip small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.creator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 22px;
  align-items: start;
}

.reverse-layout {
  grid-template-columns: minmax(0, 1fr) 390px;
}

.creator-main {
  display: grid;
  gap: 20px;
}

.composer-card,
.task-card {
  padding: 24px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.section-title > div {
  min-width: 0;
}

.section-title .line-icon {
  float: left;
  margin: 2px 8px 0 0;
}

.section-title h2,
.task-card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.section-title p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.section-title.compact {
  margin-bottom: 18px;
}

.field-label {
  margin-bottom: 8px;
  font-weight: 650;
  color: var(--text);
}

.field-label b,
.form-grid b {
  color: var(--danger);
}

.prompt-box {
  position: relative;
}

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

textarea:focus,
input:focus,
select:focus {
  border-color: oklch(64% 0.052 74);
  box-shadow: 0 0 0 3px oklch(87% 0.036 78 / 0.65);
}

textarea {
  min-height: 160px;
  padding: 18px;
  resize: vertical;
  line-height: 1.6;
}

.large-textarea {
  min-height: 172px;
}

.char-count {
  position: absolute;
  right: 12px;
  top: -32px;
  min-width: 54px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.hint-row,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hint-row {
  margin-top: 14px;
}

.prompt-chip,
.image-chip,
.filter-chip,
.quantity-row button,
.tab-pair button,
.view-switch button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 0 13px;
}

.prompt-chip:hover,
.image-chip:hover,
.filter-chip:hover,
.quantity-row button:hover,
.tab-pair button:hover,
.view-switch button:hover {
  border-color: var(--line-strong);
}

.filter-chip.active,
.quantity-row button.active,
.tab-pair button.active,
.view-switch button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: oklch(99% 0.004 76);
}

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

.form-grid label {
  display: grid;
  gap: 7px;
}

select,
input {
  min-height: 46px;
  padding: 0 13px;
}

.price-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--accent-strong);
  font-size: 13px;
  white-space: nowrap;
}

.reference-zone {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.reference-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: color-mix(in oklch, var(--surface) 72%, var(--surface-soft));
}

.reference-panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.reference-panel h3 {
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.reference-panel h3 > span {
  color: var(--accent);
}

.reference-panel h3 small {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.reference-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.reference-add {
  min-height: 36px;
}

.upload-reference {
  width: 100%;
  min-height: 82px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--muted);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.upload-reference:hover {
  border-color: var(--accent);
  background: var(--active-bg);
}

.upload-reference.compact {
  width: min(212px, 100%);
  min-height: 118px;
  justify-self: start;
  border-radius: 14px;
  padding: 14px;
}

.upload-reference span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.upload-reference strong {
  color: var(--text);
}

:root[data-theme="dark"] .upload-reference {
  border-color: oklch(42% 0.03 76);
  background: oklch(19% 0.013 74);
  color: var(--faint);
}

:root[data-theme="dark"] .upload-reference:hover {
  border-color: var(--accent);
  background: oklch(24% 0.022 76);
}

:root[data-theme="dark"] .upload-reference span {
  background: oklch(27% 0.045 76);
  color: var(--accent-strong);
}

:root[data-theme="dark"] .reference-panel {
  background: oklch(19% 0.013 74);
  border-color: oklch(34% 0.018 74);
}

.task-column {
  display: grid;
  gap: 20px;
}

.task-card {
  box-shadow: var(--shadow);
}

.task-preview {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.task-icon {
  width: 42px;
  height: 42px;
}

.task-icon svg {
  width: 22px;
  height: 22px;
}

.task-preview strong {
  display: block;
  margin-bottom: 3px;
}

.task-preview small {
  color: var(--muted);
  line-height: 1.45;
}

.task-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0 0;
}

.task-meta div {
  min-width: 0;
}

.task-meta dd {
  margin: 5px 0 0;
  font-weight: 700;
  line-height: 1.35;
}

.estimate-list {
  display: grid;
  gap: 11px;
  padding: 16px 0 0;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.estimate-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.result-state {
  min-height: 202px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

.result-state strong {
  color: var(--text);
}

.result-state p {
  margin: 0;
  line-height: 1.5;
}

.task-progress-panel {
  width: 100%;
  display: grid;
  gap: 13px;
}

.task-progress-panel .empty-icon {
  margin: 0 auto;
  color: var(--accent-strong);
}

.stage-track {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.stage-track span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.stage-track span.active {
  border-color: oklch(78% 0.05 78);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.progress-meter {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: oklch(89% 0.012 82);
}

.progress-meter span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), oklch(62% 0.105 92));
  transition: width 220ms ease-out;
}

.task-wait-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  text-align: left;
}

.task-wait-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 9px 10px;
}

.task-wait-grid span,
.library-progress span,
.library-status-stack small {
  color: var(--muted);
  font-size: 12px;
}

.task-wait-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 13px;
}

.task-id-line,
.task-live-note,
.poll-warning {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.poll-warning {
  border: 1px solid oklch(78% 0.05 78);
  border-radius: 10px;
  padding: 8px 10px;
  background: oklch(96% 0.022 78);
  color: var(--accent-strong);
}

:root[data-theme="dark"] .progress-meter {
  background: oklch(32% 0.018 74);
}

:root[data-theme="dark"] .poll-warning {
  background: oklch(24% 0.028 76);
}

.result-state.error {
  color: var(--danger);
  background: oklch(96% 0.025 28);
  border-color: oklch(78% 0.06 28);
}

.empty-icon {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  font-size: 40px;
  color: var(--faint);
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.result-success {
  display: grid;
  gap: 12px;
}

.result-success video,
.result-link {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  background: oklch(18% 0.018 74);
}

.result-link {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: oklch(96% 0.006 86);
  text-align: center;
}

.result-success a,
.copy-result-button {
  min-height: 42px;
  border-radius: 14px;
  background: var(--accent);
  color: oklch(99% 0.004 76);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  border: 0;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(280px, 360px);
  gap: 18px;
  padding: 28px 14px 24px;
  margin-bottom: 22px;
}

.filter-panel > .chip-row {
  grid-column: 1 / -1;
}

.search-field {
  position: relative;
}

.search-field span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-field input {
  padding-left: 38px;
}

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

.inspiration-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 1px 2px oklch(45% 0.018 74 / 0.04);
}

.inspiration-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-soft);
}

.inspiration-media img,
.inspiration-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.inspiration-media video {
  background: oklch(14% 0.014 74);
}

.media-badges {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.media-badges span,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--media-badge-bg);
  color: oklch(98% 0.004 86);
  padding: 0 8px;
  font-size: 12px;
}

.inspiration-body {
  padding: 14px;
}

.inspiration-body h3 {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.35;
}

.inspiration-body p {
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.inspiration-body .inspiration-desc {
  min-height: 40px;
  margin: 0 0 10px;
  color: var(--text);
  opacity: 0.78;
  -webkit-line-clamp: 2;
}

.tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-row .tag {
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.card-actions button,
.card-actions a {
  flex: 1;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  font-weight: 650;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.card-actions .use-button {
  background: var(--accent);
  border-color: var(--accent);
  color: oklch(99% 0.004 76);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.metric-grid > div {
  min-height: 112px;
  padding: 28px 16px;
}

.tab-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.tab-pair button {
  border-radius: 14px;
}

.reverse-output {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
  padding: 16px;
}

.reverse-output span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.reverse-output strong {
  display: block;
  margin-top: 5px;
  line-height: 1.45;
}

.reverse-output ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.reverse-output textarea {
  min-height: 158px;
  resize: vertical;
  background: var(--field-bg);
}

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

.wide {
  width: 100%;
  margin-top: 12px;
}

.quantity-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.quantity-row button {
  border-radius: 12px;
}

.view-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 4px;
}

.view-switch button {
  border: 0;
  border-radius: 10px;
}

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

.library-filter-top {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(240px, 360px);
  align-items: center;
  gap: 16px;
}

.library-filter-top > div {
  display: grid;
  gap: 5px;
}

.library-search input {
  width: 100%;
}

.library-content {
  min-height: 314px;
  padding: 24px;
}

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

.video-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.library-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.video-thumb {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, oklch(91% 0.028 78), oklch(83% 0.032 214));
  color: var(--accent-strong);
  font-size: 38px;
}

.library-video-preview {
  background: oklch(18% 0.018 74);
}

.library-video-preview video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: oklch(18% 0.018 74);
}

.library-placeholder,
.library-link-preview {
  align-content: center;
  gap: 8px;
  font-size: 34px;
}

.library-placeholder .empty-icon,
.library-link-preview .empty-icon {
  width: 38px;
  height: 38px;
}

.library-placeholder small,
.library-link-preview small {
  font-size: 12px;
  color: var(--muted);
}

.library-placeholder.failed {
  background: oklch(94% 0.025 28);
  color: var(--danger);
}

.library-placeholder.succeeded {
  background: oklch(94% 0.025 145);
  color: var(--success);
}

.video-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 14px;
}

.video-card h3 {
  margin: 0;
  font-size: 15px;
}

.video-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.library-card .video-card-body > p {
  min-height: 40px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.library-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.library-meta > span:not(.status-pill) {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.library-progress {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 10px;
}

.progress-meter.compact {
  height: 7px;
}

.library-progress div:last-of-type {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.library-progress p {
  margin: 0;
  color: var(--accent-strong);
  font-size: 12px;
  line-height: 1.45;
}

.library-status-stack {
  display: grid;
  gap: 5px;
}

.library-status-stack small {
  display: block;
  white-space: nowrap;
}

.video-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.video-card footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-error {
  min-height: 34px;
  border-radius: 8px;
  padding: 8px 10px;
  background: oklch(96% 0.018 28);
  color: var(--danger);
}

.library-card-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.library-action {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 0 11px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.library-action:hover {
  border-color: var(--line-strong);
}

.library-action.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: oklch(99% 0.004 76);
}

.library-action.danger {
  color: var(--danger);
}

.library-action.small {
  min-height: 30px;
  border-radius: 8px;
  padding: 0 9px;
}

.library-action:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.status-pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.status-pill.succeeded {
  color: var(--success);
  border-color: oklch(78% 0.05 145);
}

.status-pill.processing {
  color: var(--accent-strong);
  border-color: oklch(78% 0.05 78);
}

.status-pill.failed {
  color: var(--danger);
  border-color: oklch(78% 0.06 28);
}

.status-pill.draft {
  color: var(--muted);
  border-color: var(--line-strong);
}

.library-table {
  width: 100%;
  border-collapse: collapse;
}

.library-table th,
.library-table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.library-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.library-row-title {
  font-weight: 700;
  color: var(--text);
}

.library-row-prompt {
  max-width: 360px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.empty-library {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 12px;
  color: var(--muted);
}

.empty-library .empty-icon {
  font-size: 54px;
}

.empty-library h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  background: var(--overlay);
}

.settings-drawer {
  width: min(440px, 100vw);
  min-height: 100vh;
  display: grid;
  align-content: start;
  gap: 16px;
  background: var(--surface);
  padding: 26px;
  box-shadow: -20px 0 55px oklch(20% 0.02 74 / 0.18);
}

.drawer-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.drawer-top span {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.drawer-top h2 {
  margin: 5px 0 0;
}

.drawer-top button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-size: 24px;
}

.settings-drawer label {
  display: grid;
  gap: 7px;
}

.settings-drawer label span {
  font-size: 13px;
  font-weight: 800;
  color: oklch(36% 0.018 74);
}

.inferred-box {
  display: grid;
  gap: 8px;
  border: 1px solid oklch(84% 0.036 78);
  background: oklch(96% 0.02 78);
  border-radius: 14px;
  padding: 14px;
  color: oklch(35% 0.04 76);
}

.inferred-box code {
  padding: 10px;
  border-radius: 10px;
  background: var(--surface);
  overflow-wrap: anywhere;
}

.drawer-message {
  margin: 0;
  color: var(--accent-strong);
  font-weight: 700;
}

.save-button {
  min-height: 46px;
}

.spin { animation: spin 900ms linear infinite; }

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .creator-layout,
  .reverse-layout {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
  }

  .brand {
    min-height: 66px;
  }

  .nav-groups {
    padding: 10px 12px 14px;
  }

  .nav-group p,
  .sidebar-bottom {
    display: none;
  }

  .nav-group,
  .nav-group + .nav-group {
    margin: 0;
  }

  .nav-groups {
    display: grid;
    gap: 8px;
  }

  .nav-group {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav-group::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    width: auto;
    min-width: max-content;
    min-height: 42px;
    border-radius: 14px;
    padding: 0 12px;
  }

  .workspace {
    padding: 28px 14px 34px;
  }

  .page-header {
    display: grid;
  }

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

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

  .summary-strip > div + div {
    border-left: 0;
  }

  .summary-strip > div:nth-child(even) {
    border-left: 1px solid oklch(92% 0.008 82);
  }

  .form-grid,
  .task-column,
  .filter-panel,
  .inspiration-grid,
  .library-grid {
    grid-template-columns: 1fr;
  }

  .reference-panel-head {
    display: grid;
  }

  .task-meta {
    grid-template-columns: 1fr;
  }

  .task-wait-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page-header > div:first-child {
    grid-template-columns: 1fr;
  }

  .title-icon {
    grid-row: auto;
    margin-bottom: 10px;
  }

  .page-header p {
    grid-column: auto;
  }

  .page-header h1 {
    font-size: 26px;
  }

  .summary-strip,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .summary-strip > div:nth-child(even) {
    border-left: 0;
  }

  .composer-card,
  .task-card,
  .filter-panel,
  .library-content {
    padding: 18px;
    border-radius: 16px;
  }

  .section-title {
    display: grid;
  }

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

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

  .library-progress div:last-of-type {
    display: grid;
  }

  .library-table {
    min-width: 640px;
  }

  .library-content.table-mode {
    overflow-x: auto;
  }
}
