:root {
  color-scheme: dark;
  --bg: #03080c;
  --panel: #0b141d;
  --panel-hover: #101c26;
  --line: #1c2d3d;
  --line-light: #2a4054;
  --text: #e2f1f8;
  --muted: #82a0b0;
  --accent: #00e5ff;
  --accent-glow: rgba(0, 229, 255, 0.15);
  --purple: #9d72ff;
  --danger: #ff5263;
  --success: #00e676;
  --font-heading: 'Outfit', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

[hidden] {
  display: none !important;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  line-height: 1.5;
  background-image: radial-gradient(circle at 50% 0%, rgba(11, 20, 29, 0.8), var(--bg) 60%);
}

.hidden { display: none !important; }

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }

.eyebrow {
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: rgba(3, 8, 12, 0.85);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar h1 { font-size: 1.25rem; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

a { color: var(--text); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent); }

button {
  cursor: pointer;
  border: 1px solid var(--line-light);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  padding: 0.5rem 0.875rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--panel-hover);
}

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

.primary {
  background: var(--accent);
  color: #002b33;
  border-color: var(--accent);
}

.primary:hover:not(:disabled) {
  background: #4dffff;
  border-color: #4dffff;
  box-shadow: 0 0 16px var(--accent-glow);
}

.danger.outline {
  background: transparent;
  border-color: rgba(255, 82, 99, 0.4);
  color: var(--danger);
}

.danger.outline:hover:not(:disabled) {
  background: rgba(255, 82, 99, 0.1);
  border-color: var(--danger);
}

.icon-btn {
  padding: 0.5rem;
}
.icon-btn svg { width: 1.1rem; height: 1.1rem; }

.icon-btn-text svg { width: 1rem; height: 1rem; }

input, textarea, select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 0.6rem 0.75rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line-light);
  border-radius: var(--radius-md);
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  white-space: nowrap;
  color: var(--muted);
  background: var(--bg);
}

.badge.draft { border-color: var(--line-light); color: var(--muted); }
.badge.approved { border-color: rgba(0, 230, 118, 0.4); color: var(--success); }
.badge.reviewed { border-color: rgba(157, 114, 255, 0.4); color: var(--purple); }
.badge.queued { border-color: rgba(0, 229, 255, 0.4); color: var(--accent); }
.badge.running { border-color: rgba(0, 229, 255, 0.8); color: var(--accent); animation: pulse 2s infinite; }

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.notice {
  margin: 1rem auto 0;
  max-width: 1400px;
  width: calc(100% - 2rem);
  padding: 0.75rem 1rem;
  border: 1px solid var(--line-light);
  border-radius: var(--radius-md);
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.notice.error { border-color: rgba(255, 82, 99, 0.4); background: rgba(255, 82, 99, 0.05); color: #ffd7dc; }
.notice.success { border-color: rgba(0, 230, 118, 0.4); background: rgba(0, 230, 118, 0.05); color: #b9f6ca; }

.notice button {
  background: transparent;
  border: none;
  padding: 0.25rem;
  color: inherit;
  opacity: 0.7;
}
.notice button:hover { opacity: 1; background: rgba(255,255,255,0.1); }

.studio-layout {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 5.5rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-light); border-radius: 4px; }

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.theme-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.theme-button {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-md);
}

.theme-button:hover {
  background: var(--panel);
  border-color: var(--line);
}

.theme-button.active {
  background: var(--panel);
  border-color: var(--line-light);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.theme-button strong { color: var(--text); font-size: 0.875rem; display: block; }
.theme-button small { color: var(--muted); font-size: 0.75rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-button-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }

/* Workspace & Editor Grid */
.workspace { min-width: 0; }

.empty-state {
  min-height: 50vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
  border: 1px dashed var(--line-light);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.empty-state h2 { font-size: 1.5rem; }
.empty-state p { color: var(--muted); max-width: 400px; }

.editor-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(340px, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.title-group h2 { font-size: 1.25rem; }
.title-group p { margin-bottom: 0.1rem; }

/* Items Column */
.items-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 5.5rem;
  max-height: calc(100vh - 7rem);
}

.list-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.item-list::-webkit-scrollbar { width: 6px; }
.item-list::-webkit-scrollbar-thumb { background: var(--line-light); border-radius: 4px; }

.item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.check {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
}

.check input {
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 1px solid var(--line-light);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-content: center;
  margin: 0;
  padding: 0;
}

.check input::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  transform: scale(0);
  transition: 120ms transform ease-in-out;
  box-shadow: inset 1em 1em white;
  transform-origin: center;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.check input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.check input:checked::before { transform: scale(1); box-shadow: inset 1em 1em #002b33; }

.item-select {
  flex: 1;
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(3, 8, 12, 0.5);
  border: 1px solid var(--line);
}

.item-select:hover { border-color: var(--line-light); background: var(--panel-hover); }
.item-select.active { border-color: var(--accent); background: var(--accent-glow); }

.item-select .slot {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent);
  text-align: center;
}

.quote-statuses { display: flex; gap: 0.25rem; align-items: center; }
.quote-status {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid var(--line-light);
  border-radius: 99px;
  padding: 0.15rem 0.3rem;
  color: var(--muted);
  background: var(--bg);
}
.quote-status.complete { border-color: rgba(0, 230, 118, 0.45); color: var(--success); }
.quote-status.suspicious { border-color: rgba(255, 190, 70, 0.55); color: #ffcf70; }
.quote-status.missing { border-color: rgba(255, 82, 99, 0.55); color: var(--danger); }
.badge.suspicious { border-color: rgba(255, 190, 70, 0.55); color: #ffcf70; }
.badge.missing { border-color: rgba(255, 82, 99, 0.55); color: var(--danger); }
.badge.complete { border-color: rgba(0, 230, 118, 0.45); color: var(--success); }
.quote-review-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  background: rgba(3, 8, 12, 0.35);
}
.quote-review-summary-header { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; }
.quote-review-summary h3 { font-size: 0.95rem; }
.quote-review-summary .hint { margin-top: 0.4rem; }
.quote-review-summary.ready { border-color: rgba(0, 230, 118, 0.4); }
.quote-review-summary.needs-review { border-color: rgba(255, 190, 70, 0.45); }
.field-label { display: flex; align-items: center; gap: 0.45rem; }
.field-help { color: var(--muted); font-size: 0.7rem; font-weight: 400; min-height: 1em; }

.item-copy { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.item-copy strong { color: var(--text); font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-copy small { color: var(--muted); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Context Area (Right Column) */
.context-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-grid .wide { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #c0d4df;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: -0.25rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.5rem;
}

.w-full { width: 100%; }
.mt-4 { margin-top: 1rem; }
.text-center { text-align: center; }

/* Batches */
.batch-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  background: var(--bg);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}
.batch-controls > button { grid-column: 1 / -1; }

.batch-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
}

.batch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  gap: 1rem;
}

.batch-row-info { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.batch-title { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.batch-stats small { color: var(--muted); font-size: 0.75rem; }

progress {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--line-light);
}
progress::-webkit-progress-bar { background: var(--line-light); }
progress::-webkit-progress-value { background: var(--accent); transition: width 0.3s ease; }
progress::-moz-progress-bar { background: var(--accent); transition: width 0.3s ease; }

.batch-row-actions { display: flex; gap: 0.25rem; }
.btn-sm { padding: 0.35rem; }

/* Item Editor Specifics */
.generation-area {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.job-status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.draft-image-container {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

#draft-image {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
}

#draft-video {
  width: 100%;
  max-height: 440px;
  background: #000;
  display: block;
}

.manual-upload-panel {
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: rgba(34, 211, 238, 0.04);
  display: grid;
  gap: 1rem;
}

.manual-upload-panel[hidden] { display: none; }
.manual-upload-panel h3 { margin: 0.2rem 0 0.35rem; font-size: 1rem; }
.manual-upload-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.75rem; align-items: end; }
.manual-upload-grid label { min-width: 0; }
.manual-upload-grid input[type="file"] { width: 100%; margin-top: 0.4rem; }
.manual-upload-grid small { display: block; color: var(--muted); margin-top: 0.35rem; font-size: 0.7rem; }

@media (max-width: 640px) {
  .manual-upload-grid { grid-template-columns: 1fr; }
}

/* Legacy & Test Accounts styling preserved */
.test-account-list { display: flex; flex-direction: column; gap: 0.5rem; }
.test-account-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.test-account-copy strong { font-size: 0.875rem; display: block; }
.test-account-copy small { font-size: 0.75rem; color: var(--muted); word-break: break-all; }
.legacy-warning {
  padding: 0.75rem;
  background: rgba(255, 82, 99, 0.05);
  border: 1px solid rgba(255, 82, 99, 0.3);
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.legacy-warning strong { color: #ffd7dc; font-size: 0.875rem; }
.legacy-warning small { color: var(--muted); font-size: 0.75rem; }
.legacy-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.legacy-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
}

@media (max-width: 1024px) {
  .studio-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: 300px; }
  .items-column { position: static; max-height: 50vh; }
  .editor-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .batch-controls { grid-template-columns: 1fr; }
  .studio-layout { padding: 1rem; }
  .panel { padding: 1rem; }
}
