/* IHS Playground — black & gold (theihs.ai tokens) */
:root {
  --accent: #FFC105;            /* gold — hsl(45 100% 51%) from theihs.ai */
  --accent-hover: #E6AE00;
  --accent-soft: rgba(255, 193, 5, .10);
  --accent-ink: #121212;        /* text on gold */
  --bg: #121212;                /* background 7% */
  --bg-rail: #161616;           /* sidebar 11%-ish */
  --surface: #1A1A1A;           /* card 10% */
  --input: #212121;
  --border: #2E2E2E;            /* 18% */
  --border-soft: #242424;
  --text: #F2F2F2;              /* 95% */
  --text-2: #B0B0B0;
  --text-3: #8C8C8C;            /* 55% */
  --danger: #EF4444;
  --ok: #22C55E;
  /* categorical chart palette — validated for dark surface #1A1A1A */
  --ch-chat: #1B8FD4;
  --ch-image: #B88300;
  --ch-video: #8B5CF6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 24px rgba(0, 0, 0, .35);
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Sora", "Manrope", -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #444; }
.hidden { display: none !important; }
code { font-family: var(--mono); font-size: .85em; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 5px; }

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------------- left rail ---------------- */
.rail {
  width: 78px;
  flex: none;
  background: var(--bg-rail);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px;
  gap: 6px;
}
.rail-logo { margin-bottom: 16px; filter: drop-shadow(0 2px 10px rgba(255, 193, 5, .25)); }
.rail-spacer { flex: 1; }
.rail-item {
  width: 62px;
  padding: 10px 0 8px;
  border: 0;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: color .15s, background .15s;
}
.rail-item svg { width: 21px; height: 21px; fill: currentColor; }
.rail-item:hover { background: #202020; color: var(--text); }
.rail-item.active { background: var(--accent-soft); color: var(--accent); }

/* ---------------- page layout ---------------- */
.page { display: none; flex: 1; min-width: 0; }
.page.active { display: flex; }
.page-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page-main.wide { padding: 0 30px 30px; overflow-y: auto; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 30px 16px;
}
.page-head h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.head-actions { display: flex; gap: 10px; align-items: center; }
.hint { color: var(--text-3); font-size: 12.5px; }

.params {
  width: 296px;
  flex: none;
  background: var(--bg-rail);
  border-left: 1px solid var(--border-soft);
  padding: 22px 20px;
  overflow-y: auto;
}
.params h3 {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent);
  margin-bottom: 18px;
  font-weight: 600;
}

/* ---------------- fields ---------------- */
.field { display: block; margin-bottom: 17px; }
.field > span { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; letter-spacing: .01em; }
.field > span b { color: var(--accent); font-family: var(--font-display); font-weight: 600; }
.field small { color: var(--text-3); font-weight: 400; font-size: 11.5px; display: block; margin-top: 4px; }
.field input[type="text"], .field input[type="number"], .field input[type="password"],
.field input:not([type]), .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 193, 5, .12);
}
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field.toggle { display: flex; align-items: center; justify-content: space-between; }
.field.toggle > span { margin: 0; }
.field.toggle input { width: 36px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.inline-check { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.inline-check input { accent-color: var(--accent); }

/* ---------------- buttons ---------------- */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  transition: all .15s;
}
.btn-primary {
  background: linear-gradient(180deg, #FFD34D, var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .2) inset, 0 2px 10px rgba(255, 193, 5, .18);
}
.btn-primary:hover { background: linear-gradient(180deg, #FFDA6A, #FFC821); box-shadow: 0 2px 16px rgba(255, 193, 5, .32); }
.btn-primary:disabled { opacity: .5; cursor: default; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: none; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { border-color: var(--danger); }
.icon-btn {
  width: 40px; height: 40px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .15s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------------- canvas / empty states ---------------- */
.canvas { flex: 1; overflow-y: auto; padding: 0 30px; }
.empty-state { text-align: center; padding: 80px 20px 40px; color: var(--text-2); }
.empty-icon { font-size: 38px; margin-bottom: 14px; opacity: .9; }
.empty-state h2 { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; letter-spacing: -.01em; }
.empty-state p { max-width: 460px; margin: 0 auto; font-size: 13px; color: var(--text-3); }

/* ---------------- composer ---------------- */
.composer {
  margin: 12px 30px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  transition: border-color .15s;
}
.composer:focus-within { border-color: rgba(255, 193, 5, .5); }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1;
  border: 0;
  resize: none;
  outline: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  max-height: 160px;
  padding: 10px 2px;
}
.composer textarea::placeholder { color: var(--text-3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:not(:empty) { margin-bottom: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 193, 5, 0.08);
  border: 1px solid rgba(255, 193, 5, 0.35);
  border-radius: 999px;
  padding: 3px 10px 3px 3px;
  font-size: 12px;
  max-width: 340px;
  font-weight: 600;
}
.chip img, .chip .chip-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 11px;
  flex: none;
}
.chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; color: #FFC105; letter-spacing: 0.2px; }
.chip .chip-at { color: #FFC105; margin-right: 1px; }
.chip select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 6px;
  font-size: 11px;
  padding: 2px 4px;
  font-family: inherit;
}
.chip .chip-x { border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 14px; padding: 2px; }
.chip .chip-x:hover { color: var(--danger); }

/* ---------------- chat ---------------- */
.chat-thread { flex: 1; overflow-y: auto; padding: 6px 30px; }
.msg { display: flex; gap: 12px; margin-bottom: 20px; max-width: 860px; }
.msg-avatar {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  font-family: var(--font-display);
}
.msg.user .msg-avatar { background: #2E2E2E; color: var(--text-2); }
.msg.assistant .msg-avatar { background: linear-gradient(180deg, #FFD34D, var(--accent)); color: var(--accent-ink); }
.msg-body { min-width: 0; flex: 1; }
.msg-role { font-size: 11px; font-weight: 700; color: var(--text-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .08em; }
.msg-content { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; color: var(--text); }
.msg-content .cursor { display: inline-block; width: 8px; height: 15px; background: var(--accent); animation: blink 1s infinite; vertical-align: text-bottom; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.msg-images { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.msg-images img { height: 90px; border-radius: 8px; border: 1px solid var(--border); }
.msg-error { color: var(--danger); font-size: 13px; }

/* ---------------- image gallery ---------------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; padding-bottom: 24px; }
.gen-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.gen-card:hover { border-color: var(--border); transform: translateY(-1px); }
.gen-card img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; }
.gen-card video { width: 100%; display: block; background: #000; }
.gen-meta { padding: 9px 12px; font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gen-meta .uri { font-family: var(--mono); font-size: 11px; cursor: pointer; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen-meta .dl { color: var(--text-3); text-decoration: none; }
.gen-meta .dl:hover { color: var(--accent); }
.gen-card.loading { display: grid; place-items: center; aspect-ratio: 1; color: var(--text-3); font-size: 13px; }
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- video tasks ---------------- */
.task-list { display: flex; flex-direction: column; gap: 14px; padding-bottom: 24px; max-width: 880px; }
.task-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.task-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.task-id { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.badge { font-size: 10.5px; font-weight: 800; padding: 2px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: .06em; }
.badge.queued, .badge.running { background: var(--accent-soft); color: var(--accent); }
.badge.succeeded { background: rgba(34, 197, 94, .12); color: var(--ok); }
.badge.failed, .badge.expired, .badge.cancelled { background: rgba(239, 68, 68, .1); color: var(--danger); }
.task-prompt { font-size: 13px; color: var(--text-2); margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-card video { width: 100%; max-height: 420px; border-radius: var(--radius-sm); background: #000; }
.task-foot { display: flex; gap: 12px; align-items: center; margin-top: 10px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.task-foot .uri { font-family: var(--mono); color: var(--accent); cursor: pointer; }
.task-foot a { color: var(--text-2); }
.task-progress { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 13px; padding: 18px 0; justify-content: center; }
.task-progress .spinner { margin: 0; width: 18px; height: 18px; border-width: 2px; }

/* ---------------- assets ---------------- */
.assets-note { color: var(--text-2); font-size: 13px; margin-bottom: 18px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.asset-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.asset-card:hover { border-color: var(--border); }
.asset-thumb { aspect-ratio: 16/10; background: var(--input); display: grid; place-items: center; font-size: 30px; overflow: hidden; position: relative; }
.asset-thumb img, .asset-thumb video { width: 100%; height: 100%; object-fit: cover; }
.asset-thumb audio { width: 92%; }
.asset-kind { position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, .7); color: var(--accent); font-size: 9.5px; font-weight: 800; padding: 2px 8px; border-radius: 5px; text-transform: uppercase; letter-spacing: .08em; }
.asset-info { padding: 10px 12px; }
.asset-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-uri { font-family: var(--mono); font-size: 11px; color: var(--accent); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-uri:hover { text-decoration: underline; }
.asset-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 11px; color: var(--text-3); }
.asset-del { border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 12px; }
.asset-del:hover { color: var(--danger); }
.picker-grid .asset-card { cursor: pointer; }
.picker-grid .asset-card:hover { border-color: var(--accent); }

/* ---------------- analytics ---------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.tile .tile-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.tile .tile-value { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.tile .tile-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.type-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.type-dot.chat { background: var(--ch-chat); }
.type-dot.image { background: var(--ch-image); }
.type-dot.video { background: var(--ch-video); }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.chart-title { font-family: var(--font-display); font-size: 14px; font-weight: 600; }
.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: none; color: var(--text-3); font-family: inherit; font-size: 12px; font-weight: 700; padding: 5px 12px; cursor: pointer; }
.seg button.active { background: var(--accent-soft); color: var(--accent); }
.legend { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--text-2); margin: 6px 0 10px; }
.legend span { display: flex; gap: 6px; align-items: center; }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; }
.chart-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 40px 0; }
.tooltip {
  position: fixed;
  z-index: 300;
  background: #0D0D0D;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: var(--shadow);
  min-width: 130px;
}
.tooltip .tt-title { font-weight: 700; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: var(--text-2); }
.tooltip .tt-row b { color: var(--text); font-weight: 600; }

.jobs-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.jobs-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.jobs-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); color: var(--text-2); vertical-align: middle; }
.jobs-table td.mono { font-family: var(--mono); font-size: 11px; }
.jobs-table .jt-type { display: flex; align-items: center; gap: 7px; color: var(--text); font-weight: 600; text-transform: capitalize; }
.jobs-table .jt-prompt { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs-table tr:hover td { background: rgba(255, 255, 255, .015); }

/* ---------------- modals ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: min(440px, 92vw);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  max-height: 86vh;
  overflow-y: auto;
}
.modal-lg { width: min(760px, 94vw); }
.modal h2 { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin-bottom: 18px; letter-spacing: -.01em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.picker-toolbar { margin-bottom: 12px; }
.picker-grid { max-height: 48vh; overflow-y: auto; }

/* ---------------- toasts ---------------- */
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #F2F2F2;
  color: #121212;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: 560px;
  animation: toast-in .18s ease;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .88); z-index: 150; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }
