:root {
  color-scheme: dark;
  --bg: #101114;
  --surface: #17191e;
  --surface-2: #20232a;
  --surface-3: #292d35;
  --line: #343945;
  --text: #f4f5f7;
  --muted: #a9afbd;
  --subtle: #7f8798;
  --brand: #ff8a1c;
  --brand-2: #ffb156;
  --green: #31d07f;
  --blue: #4ca3ff;
  --red: #ff5a66;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    linear-gradient(180deg, rgba(255, 138, 28, 0.08), transparent 300px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 17, 20, 0.92);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #16100a;
  font-weight: 900;
  font-size: 24px;
  flex: 0 0 auto;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(49, 208, 127, 0.12);
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--line);
}

.modebar {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 10px;
  max-width: 1556px;
  margin: 18px auto 0;
  padding: 0 24px;
}

.mode-button,
.quick-actions button,
.chip,
.tab,
.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius);
  min-height: 40px;
  padding: 0 14px;
}

.mode-button {
  height: 48px;
  font-weight: 800;
}

.mode-button.active {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(255, 138, 28, 0.26), rgba(76, 163, 255, 0.12));
}

.workspace {
  width: min(1556px, 100%);
  margin: 18px auto 0;
  padding: 0 24px 28px;
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(500px, 1.38fr) minmax(300px, 0.84fr);
  gap: 14px;
  align-items: start;
}

.left-column,
.center-column,
.right-column {
  display: grid;
  gap: 14px;
}

.right-column {
  position: sticky;
  top: 90px;
}

.panel {
  background: rgba(23, 25, 30, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-2);
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
  font-weight: 800;
}

h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.switch {
  display: inline-flex;
  align-items: center;
  width: 48px;
  height: 28px;
  position: relative;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.switch span::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 3px;
  left: 4px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s ease, background 0.16s ease;
}

.switch input:checked + span {
  border-color: rgba(49, 208, 127, 0.55);
  background: rgba(49, 208, 127, 0.2);
}

.switch input:checked + span::after {
  transform: translateX(18px);
  background: var(--green);
}

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

.field span,
.range-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

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

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

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 86px;
  padding: 12px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 138, 28, 0.14);
}

.source-row,
.context-tools,
.quick-actions,
.compiled-tabs,
.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.source-row {
  margin: 12px 0;
  color: var(--muted);
  font-size: 12px;
}

.source-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.source-row input {
  width: auto;
  min-height: auto;
}

.primary,
.secondary {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  color: #130d06;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-weight: 900;
}

.primary.small {
  min-height: 42px;
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: grayscale(0.5);
}

.secondary {
  color: var(--text);
  border: 1px solid rgba(76, 163, 255, 0.4);
  background: rgba(76, 163, 255, 0.16);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  font-weight: 800;
}

.drop-zone {
  display: grid;
  gap: 8px;
  min-height: 150px;
  align-content: center;
  justify-items: center;
  text-align: center;
  border: 1px dashed #596170;
  border-radius: var(--radius);
  background: #12151b;
  color: var(--muted);
  padding: 14px;
  margin-bottom: 12px;
}

.drop-zone.dragging {
  border-color: var(--brand);
  background: rgba(255, 138, 28, 0.08);
}

.drop-zone strong {
  color: var(--text);
}

.drop-zone span {
  font-size: 12px;
}

.context-tools {
  margin-bottom: 12px;
}

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

.chip.active {
  color: var(--text);
  border-color: rgba(255, 138, 28, 0.55);
  background: rgba(255, 138, 28, 0.14);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
}

.asset-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}

.asset-grid.empty {
  display: grid;
  min-height: 76px;
  place-items: center;
  color: var(--subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #12151b;
  font-size: 13px;
}

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

.asset-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(255, 138, 28, 0.15);
}

.asset-thumb {
  aspect-ratio: 1 / 0.78;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(76, 163, 255, 0.28), rgba(49, 208, 127, 0.14)),
    #111319;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  padding: 8px;
}

.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asset-body {
  padding: 9px;
  display: grid;
  gap: 7px;
}

.asset-title {
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.asset-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--subtle);
  font-size: 11px;
}

.asset-body select {
  min-height: 30px;
  padding: 0 8px;
  font-size: 11px;
}

.research-results {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.research-results.empty {
  min-height: 70px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--subtle);
  background: #12151b;
  text-align: center;
  font-size: 13px;
}

.research-card {
  border: 1px solid var(--line);
  background: #12151b;
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 9px;
}

.research-card h3 {
  margin: 0;
  font-size: 16px;
}

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

.source-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-list a {
  color: var(--blue);
  text-decoration: none;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.prompt-field textarea {
  min-height: 170px;
  font-size: 17px;
}

.quick-actions {
  margin: 12px 0;
}

.quick-actions button {
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quick-actions button:hover,
.ghost-button:hover,
.mode-button:hover,
.chip:hover,
.tab:hover {
  border-color: var(--brand);
}

.slot-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.slot {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #12151b;
  padding: 10px;
}

.slot span {
  display: block;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 8px;
}

.slot strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.prompt-score {
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 900;
}

.prompt-score.ready {
  color: #0f2118;
  border-color: transparent;
  background: var(--green);
}

.search-input {
  max-width: 170px;
  min-height: 36px;
}

.library-grid {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.compiled-tabs {
  margin-bottom: 10px;
}

.tab {
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tab.active {
  color: var(--text);
  border-color: rgba(76, 163, 255, 0.55);
  background: rgba(76, 163, 255, 0.14);
}

pre {
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0d10;
  color: #d9dee8;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 13px;
}

.range-field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.range-field span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

input[type="range"] {
  padding: 0;
  min-height: 24px;
  accent-color: var(--brand);
}

.validation-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.validation-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.validation-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--subtle);
  font-size: 11px;
  font-weight: 900;
}

.validation-item.ok .validation-icon {
  color: #0f2118;
  background: var(--green);
}

.validation-item.blocked .validation-icon {
  color: #2b080c;
  background: var(--red);
}

.action-stack {
  display: grid;
  gap: 10px;
}

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

.timeline-item {
  border-left: 3px solid var(--brand);
  padding: 8px 10px;
  background: #12151b;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.timeline-item.muted {
  border-left-color: var(--line);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.result-grid.empty {
  min-height: 130px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #12151b;
  color: var(--subtle);
  text-align: center;
  font-size: 13px;
}

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

.result-card img {
  width: 100%;
  aspect-ratio: 4 / 5;
  display: block;
  object-fit: cover;
  background: #0b0d10;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.result-meta a {
  color: var(--brand-2);
  text-decoration: none;
  font-weight: 900;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(280px, 0.9fr) minmax(440px, 1.3fr);
  }

  .right-column {
    grid-column: 1 / -1;
    position: static;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .modebar {
    overflow-x: auto;
    grid-template-columns: repeat(7, 132px);
  }

  .workspace,
  .right-column {
    grid-template-columns: 1fr;
  }

  .slot-board,
  .field-grid.two {
    grid-template-columns: 1fr;
  }

  .prompt-field textarea {
    min-height: 140px;
  }
}

@media (max-width: 560px) {
  .topbar,
  .modebar,
  .workspace {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .panel {
    padding: 12px;
  }
}
