:root {
  --bg: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --line: #e3e6eb;
  --blue: #4262ff;
  --blue-ink: #ffffff;
  --ok: #0a7d3f;
  --ok-bg: #e3f5eb;
  --bad: #b3261e;
  --bad-bg: #fdeceb;
  --warn: #8a5300;
  --warn-bg: #fdf3e0;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 18px; margin: 0 0 8px; }
h2 { font-size: 15px; margin: 0 0 6px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.wrap { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- entry page */

body.entry { padding: 32px; max-width: 640px; }
.status { padding: 10px 12px; border-radius: var(--radius); background: #f4f5f7; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.status.bad { background: var(--bad-bg); color: var(--bad); }

/* ----------------------------------------------------------------- lab shell */

/*
 * The lab scrolls inside #root rather than relying on the document scrolling. An embedder
 * controls the iframe, and an iframe that forbids document scrolling would otherwise leave the
 * panel with content it cannot reach; a scroll container the app owns works either way.
 */
body.lab { padding: 0; overflow: hidden; }
#root {
  display: flex; flex-direction: column; gap: 10px;
  height: 100%; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
}
#root > * { min-width: 0; }

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #f8f9fb;
}
.banner.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.banner .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none;
}
body.is-top .banner .dot { background: var(--ok); }
body.in-miro .banner .dot { background: var(--blue); }
body.is-framed:not(.in-miro) .banner .dot { background: var(--warn); }

/* -------------------------------------------------------------------- viewer */

.viewer-block { display: flex; flex-direction: column; gap: 6px; }
.canvas-wrap {
  position: relative; width: 100%; height: 180px;
  border-radius: var(--radius); overflow: hidden; background: #0e1116;
}
.canvas-wrap canvas { display: block; width: 100%; height: 100%; }
.viewer-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* --------------------------------------------------------------------- cards */

.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; min-width: 0; }
.card > summary {
  cursor: pointer; padding: 9px 10px; font-weight: 600; display: flex; align-items: center; gap: 8px;
  list-style: none;
}
.card > summary::-webkit-details-marker { display: none; }
.card > summary::after { content: '▸'; margin-left: auto; color: var(--muted); }
.card[open] > summary::after { content: '▾'; }
.card > summary .num {
  width: 18px; height: 18px; border-radius: 50%; background: var(--blue); color: #fff;
  font-size: 11px; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.card-body { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card-body > * { min-width: 0; }
details.sub { border-top: 1px solid var(--line); padding-top: 6px; }
details.sub > summary { cursor: pointer; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ controls */

.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  font: inherit; font-size: 13px; color: var(--ink);
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
  width: 100%;
}
.field textarea { font-family: ui-monospace, Menlo, monospace; font-size: 11px; resize: vertical; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-actions input { flex: 1 1 140px; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }

button {
  font: inherit; font-size: 13px; cursor: pointer;
  padding: 6px 11px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
button:hover:not(:disabled) { background: #f4f5f7; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--blue); border-color: var(--blue); color: var(--blue-ink); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: #f0c7c4; }
button.small-btn { padding: 3px 8px; font-size: 12px; }

/* -------------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; min-width: 0; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
td .mono { overflow-wrap: anywhere; }

/*
 * In a narrow panel the Set button matters more than the stored value, which is already on show
 * in the 3D scene and in the findings card. Drop the value column rather than push the button
 * into the table's horizontal scroller.
 */
@media (max-width: 439px) {
  #cookie-table th:nth-child(4), #cookie-table td:nth-child(4) { display: none; }
  #cookie-table th, #cookie-table td { padding: 5px 4px; }
}

dl.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 2px 10px; margin: 0; font-size: 12px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, Menlo, monospace; font-size: 11px; }

/* --------------------------------------------------------------------- bits */

.pill {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: #eef0f4; color: var(--muted);
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.note { color: var(--muted); border-left: 2px solid var(--line); padding-left: 8px; }
.note-list { margin: 0; padding-left: 14px; display: flex; flex-direction: column; gap: 4px; }
.note-list li { padding: 0; }
.auth-state { padding: 8px 10px; border-radius: 6px; background: #f8f9fb; border: 1px solid var(--line); }

.log {
  max-height: 180px; overflow-y: auto; background: #0e1116; color: #cfd6e4;
  border-radius: 6px; padding: 6px 8px; font-family: ui-monospace, Menlo, monospace; font-size: 11px;
}
.log:empty { display: none; }
.log-line { padding: 1px 0; overflow-wrap: anywhere; }
.log-line.ok { color: #7ee2a8; }
.log-line.bad { color: #ff9c94; }
.log-line.warn { color: #ffd08a; }
.log-line a { color: #9db8ff; }

/* ------------------------------------------------------------------- blocked */

.blocked { padding: 24px; max-width: 520px; margin: 40px auto; text-align: left; }
.blocked h2 { color: var(--bad); font-size: 18px; }
.blocked .mono { background: #f4f5f7; padding: 6px 8px; border-radius: 6px; font-size: 12px; }

/* ---------------------------------------------------------------- auth page */

body.auth { padding: 28px 20px; background: #f4f5f7; }
.auth-card {
  max-width: 460px; margin: 0 auto; background: #fff; padding: 22px;
  border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.auth-card form { display: flex; flex-direction: column; gap: 10px; }
.result { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ------------------------------------------------------------ wide surfaces */

@media (min-width: 760px) {
  #root { padding: 16px 20px; }
  .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .canvas-wrap { height: 300px; }
}
