:root {
  --ink: #181514;
  --panel: rgba(255, 252, 244, 0.91);
  --paper: #fffaf0;
  --muted: #756f66;
  --line: rgba(24, 21, 20, 0.16);
  --lime: #b7f03a;
  --cyan: #18c4c9;
  --coral: #ff6f4d;
  --violet: #6e5cff;
  --dark: #0d1110;
  --shadow: 0 20px 50px rgba(8, 12, 11, 0.18);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: #f6efe2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  overflow-x: hidden;
}

a, a:hover, .sourceLink {
  text-decoration: none;
}

button, input, textarea, select {
  font: inherit;
}

button, .ghost {
  min-height: 40px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--ink);
  color: #fffaf0;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

button:hover, .ghost:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(24, 21, 20, 0.16);
}

button:disabled {
  opacity: .45;
  cursor: wait;
  transform: none;
}

.ghost {
  background: rgba(255, 250, 240, 0.72);
  color: var(--ink);
}

.square {
  width: 42px;
  padding: 0;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  resize: vertical;
}

input:focus, textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(24, 196, 201, 0.16);
}

label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 6px;
}

#prismCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(183, 240, 58, .16), transparent 24%),
    radial-gradient(circle at 12% 92%, rgba(255, 111, 77, .20), transparent 28%),
    linear-gradient(155deg, #fbf4e5 0%, #edf7ef 54%, #f8eadc 100%);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1760px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 16px 0 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brandIcon {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: linear-gradient(135deg, var(--lime), var(--cyan) 58%, var(--coral));
  box-shadow: var(--shadow);
}

.brand strong {
  display: block;
  font-size: clamp(23px, 2.2vw, 34px);
  line-height: 1;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.topActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 0;
}

.metric {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.72);
  backdrop-filter: blur(18px);
  padding: 13px;
  box-shadow: 0 14px 30px rgba(24, 21, 20, 0.08);
}

.metric b {
  display: block;
  font-size: 24px;
  line-height: 1.05;
}

.metric span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  min-height: calc(100vh - 172px);
  display: grid;
  grid-template-columns: minmax(270px, 350px) minmax(420px, 1fr) minmax(300px, 380px);
  gap: 12px;
}

.queue, .detail, .actionRail {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  min-width: 0;
}

.queue {
  padding: 14px;
}

.queueHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--coral);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .12em;
  font-weight: 800;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1;
}

.dossierList {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding-right: 3px;
}

.dossierItem {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.66);
  cursor: pointer;
}

.dossierItem.active {
  border-color: var(--ink);
  background: linear-gradient(135deg, rgba(183, 240, 58, .22), rgba(24, 196, 201, .13));
}

.dossierItem h3 {
  font-size: 14px;
  line-height: 1.25;
  margin-bottom: 10px;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffaf0;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
}

.chip.hot { color: #9c3412; border-color: rgba(255, 111, 77, .45); background: rgba(255, 111, 77, .12); }
.chip.good { color: #336600; border-color: rgba(183, 240, 58, .7); background: rgba(183, 240, 58, .20); }
.chip.cool { color: #087176; border-color: rgba(24, 196, 201, .45); background: rgba(24, 196, 201, .12); }

.detail {
  padding: 18px;
  overflow: hidden;
}

.detailView {
  height: 100%;
  overflow: auto;
  padding-right: 4px;
}

.heroDetail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 18px;
  align-items: stretch;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.heroDetail h2 {
  margin-bottom: 12px;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1.04;
  max-width: 950px;
}

.sourceLink {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.scoreDial {
  width: min(100%, 160px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--lime) var(--pct), rgba(24, 21, 20, .10) 0);
  border: 1px solid var(--line);
}

.scoreDial div {
  width: 72%;
  height: 72%;
  border-radius: 50%;
  background: var(--paper);
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid var(--line);
}

.scoreDial b {
  font-size: 31px;
  line-height: 1;
}

.scoreDial span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
}

.ribbon {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.ribbon div, .logItem, .empty {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.62);
  padding: 12px;
}

.ribbon b {
  display: block;
  font-size: 20px;
}

.ribbon span, .logItem span {
  color: var(--muted);
  font-size: 12px;
}

.summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.summaryBlock {
  border-top: 3px solid var(--ink);
  padding-top: 12px;
}

.summaryBlock h3, .sectionHead h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tab {
  background: rgba(255, 250, 240, 0.75);
  color: var(--ink);
  border-color: var(--line);
}

.tab.active {
  background: var(--ink);
  color: var(--paper);
}

.logGrid {
  display: grid;
  gap: 8px;
}

.logItem {
  display: grid;
  gap: 6px;
}

.logItem strong {
  overflow-wrap: anywhere;
}

.actionRail {
  padding: 12px;
  max-height: calc(100vh - 172px);
  overflow: auto;
}

.actionBlock {
  display: grid;
  gap: 9px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.actionBlock:first-child {
  padding-top: 0;
}

.actionBlock:last-child {
  border-bottom: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  z-index: 5;
  max-width: min(680px, calc(100vw - 30px));
  padding: 12px 14px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: var(--paper);
  background: var(--dark);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
  .actionRail { grid-column: 1 / -1; max-height: none; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 18px, 1760px); padding-top: 8px; }
  .topbar { align-items: flex-start; flex-direction: column; padding-bottom: 10px; }
  .topActions { width: 100%; justify-content: stretch; }
  .topActions > * { flex: 1; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; min-height: 0; }
  .dossierList { max-height: 360px; }
  .heroDetail { grid-template-columns: 1fr; }
  .scoreDial { width: 180px; }
  .ribbon, .summary { grid-template-columns: 1fr; }
}
