/* =========================================================================
   Styles. Three parts: study chrome (identical in both conditions),
   Messaging frame, Tool frame. Reviewer-mode styles are at the end.
   ========================================================================= */

:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #1d2128;
  --muted: #5f6672;
  --faint: #8a919c;
  --line: #dfe2e7;
  --accent: #2b59c3;
  --accent-soft: #e9effb;
  --danger: #b4232c;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* The AI's words use the same size and line height in both interfaces. */
  --reply-size: 15px;
  --reply-line: 1.5;

  /* Messaging */
  --chat-out: #5847c9;
  --chat-out-ink: #ffffff;
  --chat-in: #eceef2;
  --chat-in-ink: #1d2128;

  /* Tool */
  --tool-line: #d4d8de;
  --tool-cell: #e3e6ea;
  --tool-head: #f0f2f4;
  --tool-chrome: #e8ebee;
  --tool-sel: #2b59c3;

  --rb-h: 0px;
}
body.is-review { --rb-h: 52px; }

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  padding-top: var(--rb-h);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
code { font-family: var(--mono); font-size: .92em; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  appearance: none; border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; cursor: pointer; font-weight: 600; line-height: 1.2;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #234ca9; }
.btn.primary:disabled { background: #b9c3d7; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: #cfd4db; }
.btn.secondary:hover:not(:disabled) { border-color: #9aa2ad; }
.btn.secondary:disabled { color: var(--faint); border-color: var(--line); cursor: default; }
.btn.danger { background: #fff; color: var(--danger); border-color: #e7b9bc; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

.config-errors {
  background: #fff1f1; color: #7d1d22; border-bottom: 2px solid var(--danger);
  padding: 12px 20px; font-size: 14px; position: relative; z-index: 70;
}
.config-errors ul { margin: 6px 0 0; padding-left: 20px; }
.ph-note { color: #8a5a00; background: #fff6df; border-radius: 6px; padding: 6px 10px; font-size: 13.5px; }

/* ---------- full-page screens ---------- */
.page {
  max-width: 760px; margin: 40px auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 36px;
}
.consent {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 20px; padding: 14px;
  background: var(--bg); border-radius: 8px; cursor: pointer;
}
.consent input { margin-top: 4px; }
.steps { padding-left: 22px; }
.steps li { margin: 6px 0; }
.block-prompt { margin-top: 26px; font-weight: 600; }
.form-missing { color: var(--danger); font-weight: 600; margin-top: 12px; }
.researcher { margin-top: 28px; border-top: 1px dashed #c9ced6; padding-top: 4px; }
.researcher h3 { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.researcher-body { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.researcher-body a.btn { text-decoration: none; }
.pid-warning { background: #fff6df; color: #7a5300; border: 1px solid #f0d58a; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.scen-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 4px; margin-top: 14px; }
.scen-title { font-weight: 650; }
.scen-sub { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

/* ---------- rating rows ---------- */
.rate-list { margin-top: 10px; }
.rate-row { padding: 10px 6px; border-top: 1px solid var(--line); border-radius: 6px; }
.rate-row.is-missing { background: #fff3f3; }
.rate-text { margin-bottom: 6px; }
.rate-scale { display: grid; grid-template-columns: minmax(70px, 1fr) auto minmax(70px, 1fr); align-items: center; gap: 10px; }
.rate-end { font-size: 12.5px; color: var(--muted); line-height: 1.25; }
.rate-end--low { text-align: right; }
.rate-opts { display: flex; gap: 6px; }
.rate-opt { position: relative; }
.rate-opt input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.rate-opt span {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid #c9ced6; font-size: 13px; color: var(--muted); background: #fff;
}
.rate-opt input:hover + span { border-color: var(--accent); }
.rate-opt input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rate-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
/* In the narrower study panel: circles on one row, end labels underneath. */
.study-panel .rate-scale { grid-template-columns: 1fr 1fr; grid-template-areas: "opts opts" "low high"; gap: 2px 8px; }
.study-panel .rate-opts { grid-area: opts; justify-content: space-between; gap: 2px; max-width: 300px; }
.study-panel .rate-end--low { grid-area: low; text-align: left; }
.study-panel .rate-end--high { grid-area: high; text-align: right; }
.study-panel .rate-opt span { width: 32px; height: 32px; }
.study-panel .rate-scale { max-width: 300px; }

/* =========================================================================
   ITEM LAYOUT: neutral study panel (left) + interface frame (right)
   ========================================================================= */
.item-layout {
  display: grid; grid-template-columns: minmax(360px, 5fr) minmax(440px, 7fr); gap: 20px;
  max-width: 1440px; margin: 0 auto; padding: 20px;
  height: calc(100vh - var(--rb-h)); height: calc(100dvh - var(--rb-h));
}
.study-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px 26px; overflow-y: auto; min-height: 0;
}
.frame-col { min-height: 0; }
.frame { height: 100%; }
@media (max-width: 960px) {
  .item-layout { grid-template-columns: 1fr; height: auto; padding: 12px; }
  .frame { height: 640px; }
  .page { margin: 16px; padding: 22px 18px; }
}

.panel-head { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.pill { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 3px 10px; }
.pill--practice { background: #fff3d6; color: #7a5300; }
.pill--ph { background: #fff6df; color: #8a5a00; font-weight: 500; }
.len-warn { margin: 6px 0 0; padding: 6px 10px 6px 26px; background: #fff6df; color: #8a5a00; border-radius: 6px; font-size: 12.5px; }
.scenario { font-size: 15.5px; }
.scenario p { margin-bottom: 10px; }

.options { display: grid; gap: 8px; margin: 14px 0 6px; }
.option { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fbfbfc; }
.option-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.option-text { margin-top: 2px; }

.compare { width: 100%; border-collapse: collapse; margin: 14px 0 6px; font-size: 14px; }
.compare th, .compare td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.compare thead th { border-bottom: 2px solid var(--line); }
.compare tbody th { font-weight: 500; color: var(--muted); }
.compare td { font-variant-numeric: tabular-nums; }
.compare-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.compare-name { font-weight: 650; }
.compare-text { font-weight: 400; color: var(--muted); font-size: 13px; }

.answer { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; }
.answer.is-active { border-color: #b9c8ec; background: #fafcff; box-shadow: 0 0 0 3px var(--accent-soft); }
.answer.is-done { background: #fafafa; }
.answer.is-done .answer-q { color: var(--muted); }
.answer-q { font-weight: 650; }
.answer-sub { font-size: 13.5px; color: var(--muted); }

.hint { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--bg); color: var(--muted); font-size: 14px; }
.hint--go { background: var(--accent-soft); color: #1f3f8a; font-weight: 600; }
.optional { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.optional-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-right: 4px; }
.pending-note { font-size: 13px; color: var(--muted); }
.item-ratings .rate-row:first-of-type { border-top: 0; }

/* ---------- slider (identical in both conditions) ---------- */
.slider { --thumb: 22px; margin: 6px 0 2px; }
.slider-track { position: relative; padding: 8px 0 2px; }
.slider.has-marker .slider-track { padding-top: 30px; }
.slider-track::before {           /* centre tick */
  content: ""; position: absolute; left: 50%; bottom: 4px; width: 2px; height: 18px;
  background: #b3bac5; transform: translateX(-1px); pointer-events: none;
}
.slider-track::after {            /* one small tick per whole step (0–10) */
  content: ""; position: absolute; bottom: 7px; height: 8px; pointer-events: none;
  left: calc(var(--thumb) / 2 - 1px); width: calc(100% - var(--thumb) + 2px);
  background: linear-gradient(to right, #c3c9d2 2px, transparent 2px) 0 0 / calc((100% - 2px) / 10) 100% repeat-x;
}
.slider input[type=range] {
  -webkit-appearance: none; appearance: none; position: relative; z-index: 1;
  width: 100%; height: 26px; margin: 0; background: transparent; cursor: pointer;
}
.slider input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: #cdd3dc; }
.slider input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: #cdd3dc; }
.slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: var(--thumb); height: var(--thumb); margin-top: -8px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--accent), 0 1px 3px rgba(0,0,0,.3);
}
.slider input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--accent), 0 1px 3px rgba(0,0,0,.3);
}
.slider.is-untouched input[type=range]::-webkit-slider-thumb { opacity: 0; }
.slider.is-untouched input[type=range]::-moz-range-thumb { opacity: 0; }
.slider.is-locked input[type=range] { cursor: default; }
.slider.is-locked input[type=range]::-webkit-slider-thumb { background: #8a93a3; box-shadow: 0 0 0 1px #8a93a3; }
.slider.is-locked input[type=range]::-moz-range-thumb { background: #8a93a3; box-shadow: 0 0 0 1px #8a93a3; }
.slider-marker {
  position: absolute; top: 2px; z-index: 0; pointer-events: none;
  left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--v) / 100);
  transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; text-align: center;
}
.slider-marker::after { content: ""; display: block; width: 2px; height: 10px; margin: 1px auto 0; background: #7d8592; }
.slider-labels { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.slider-labels span:nth-child(2) { text-align: center; }
.slider-labels span:last-child { text-align: right; }

/* =========================================================================
   MESSAGING FRAME
   ========================================================================= */
.chat {
  height: 100%; display: flex; flex-direction: column; position: relative;
  background: #fff; border: 1px solid var(--line); border-radius: 22px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fbfbfc; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: #d9dde4; color: #4a515d; font-weight: 700;
}
.avatar--persona { background: linear-gradient(135deg, #f1a36b, #cf5f8c); color: #fff; }
.avatar--sm { width: 28px; height: 28px; font-size: 13px; }
.chat-name { font-weight: 650; line-height: 1.2; }
.chat-status { font-size: 12.5px; color: var(--muted); }
.chat-log { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.turn { display: flex; flex-direction: column; gap: 10px; }
.avatar--second { background: #cfd8cf; color: #3f5140; }
.avatar--persona.avatar--second { background: linear-gradient(135deg, #6bb3f1, #5f7fcf); color: #fff; }
.chat--minimal .avatar, .chat--minimal .msg-meta, .chat--minimal .chat-day, .chat--minimal .chat-status { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 14px 0; border-top: 1px solid var(--line); background: #fbfbfc; }
.chip { border: 1px solid #c9c4ea; background: #fff; color: #3d2fa6; border-radius: 999px; padding: 6px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip:disabled { color: var(--faint); border-color: var(--line); cursor: default; }
.chips + .composer, .chips + .frame-lock { border-top: 0; }
.chat-day { align-self: center; font-size: 12px; color: var(--faint); margin: 2px 0 4px; }
.msg { display: flex; gap: 8px; max-width: 84%; }
.msg--out { align-self: flex-end; flex-direction: column; align-items: flex-end; }
.msg--in { align-self: flex-start; align-items: flex-end; }
.msg-col { display: flex; flex-direction: column; min-width: 0; }
.bubble { padding: 10px 14px; border-radius: 18px; font-size: var(--reply-size); line-height: var(--reply-line); }
.bubble p { margin: 0 0 .5em; }
.bubble p:last-child { margin-bottom: 0; }
.msg--out .bubble { background: var(--chat-out); color: var(--chat-out-ink); border-bottom-right-radius: 6px; }
.msg--in .bubble { background: var(--chat-in); color: var(--chat-in-ink); border-bottom-left-radius: 6px; }
.msg-meta { font-size: 11px; color: var(--faint); margin-top: 3px; padding: 0 6px; }
.msg-caption { font-size: 12px; color: var(--muted); margin: 0 0 3px 6px; }
.quote { margin-top: 8px; padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.16); font-size: 14px; line-height: 1.4; }
.bubble--typing { display: flex; gap: 4px; padding: 14px 16px; }
.bubble--typing span { width: 7px; height: 7px; border-radius: 50%; background: #9aa1ad; animation: typing 1.2s infinite ease-in-out; }
.bubble--typing span:nth-child(2) { animation-delay: .15s; }
.bubble--typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.composer { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); background: #fbfbfc; }
.composer-field {
  flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 20px;
  background: #fff; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.composer-field.is-empty, .composer-field.is-locked { color: var(--faint); }
.send-btn { border: 0; border-radius: 20px; padding: 10px 20px; background: var(--chat-out); color: #fff; font-weight: 600; cursor: pointer; }
.send-btn:disabled { background: #cdc8ea; cursor: not-allowed; }
.frame-lock { text-align: center; font-size: 12.5px; color: var(--muted); padding: 6px 10px; background: #f7f8fa; border-top: 1px solid var(--line); }

/* Same attention cue on Ask and Run */
.is-ready { animation: ready 1.6s ease-in-out 3; }
@keyframes ready { 0%, 100% { box-shadow: 0 0 0 0 rgba(43,89,195,0); } 50% { box-shadow: 0 0 0 5px rgba(43,89,195,.28); } }

/* =========================================================================
   TOOL FRAME
   ========================================================================= */
.tool {
  height: 100%; display: flex; flex-direction: column; position: relative; overflow: hidden;
  background: #fff; border: 1px solid var(--tool-line); border-radius: 3px; font-size: 13px;
}
.tool-title { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--tool-chrome); border-bottom: 1px solid var(--tool-line); font-size: 12px; color: #3c434d; }
.doc-icon { width: 11px; height: 13px; border: 1.5px solid #6b7480; border-radius: 1px; }
.tool-menu { display: flex; gap: 16px; padding: 4px 10px; border-bottom: 1px solid var(--tool-line); background: #fafbfc; font-size: 12.5px; color: #3c434d; }
.tool-toolbar { display: flex; align-items: center; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--tool-line); background: #fafbfc; }
.tb-icon { min-width: 26px; height: 24px; display: grid; place-items: center; border-radius: 3px; color: #59616d; font-size: 13px; padding: 0 4px; }
.tb-sep { width: 1px; height: 18px; background: var(--tool-line); margin: 0 6px; }
.run-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid #aeb6c1; background: #fff;
  border-radius: 3px; padding: 4px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: #1d2128;
}
.run-btn:hover:not(:disabled) { background: #f2f5fa; }
.run-btn:disabled { color: #a0a7b2; background: #f3f4f6; border-color: #d4d8de; cursor: not-allowed; }
.run-icon { font-size: 10px; color: #2f7d4f; }
.run-btn:disabled .run-icon { color: #a0a7b2; }
.formula-bar { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-bottom: 1px solid var(--tool-line); }
.cellref { width: 52px; flex: none; text-align: center; border: 1px solid var(--tool-line); padding: 2px 0; font-family: var(--mono); font-size: 12px; }
.fx { font-style: italic; color: var(--faint); font-family: Georgia, "Times New Roman", serif; }
.formula-bar code { flex: 1; min-width: 0; font-size: 12.5px; color: #2d333b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool > .frame-lock { border-top: 0; border-bottom: 1px solid var(--tool-line); background: #fafbfc; }
.grid-wrap { overflow: auto; flex: 0 1 auto; max-height: 36%; min-height: 110px; border-bottom: 1px solid var(--tool-line); }
.grid { border-collapse: collapse; width: 100%; table-layout: fixed; }
.grid col.c-n { width: 36px; } .grid col.c-a { width: 17%; } .grid col.c-b { width: 31%; }
.grid col.c-c { width: 31%; } .grid col.c-d { width: 14%; } .grid col.c-e { width: 7%; }
.grid th, .grid td { border: 1px solid var(--tool-cell); padding: 3px 6px; vertical-align: top; text-align: left; font-weight: 400; height: 23px; overflow: hidden; }
.grid .col-heads th { position: sticky; top: 0; z-index: 1; background: var(--tool-head); color: #59616d; text-align: center; font-size: 11.5px; border-color: var(--tool-line); }
.grid tr > th:first-child { background: var(--tool-head); color: #59616d; text-align: center; font-size: 11.5px; border-color: var(--tool-line); }
.grid tr.is-head td { font-weight: 600; background: #f8f9fa; }
.grid td.is-field { color: #3c434d; }
.grid td.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.is-selected { outline: 2px solid var(--tool-sel); outline-offset: -2px; }
.cell-busy { color: var(--faint); font-style: italic; }
.cell-link { color: var(--tool-sel); }
.tool-output { flex: 1 1 auto; min-height: 44%; display: flex; flex-direction: column; background: #fbfbfc; }
.out-head {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: #59616d; background: var(--tool-head); border-bottom: 1px solid var(--tool-line);
}
.out-status { margin-left: auto; font-weight: 500; text-transform: none; letter-spacing: 0; }
.out-actions { display: flex; gap: 6px; text-transform: none; letter-spacing: 0; }
.out-btn { border: 1px solid #aeb6c1; background: #fff; border-radius: 3px; padding: 2px 10px; font-size: 12.5px; font-weight: 600; color: #1d2128; cursor: pointer; }
.out-btn:disabled { color: #a0a7b2; background: #f3f4f6; border-color: #d4d8de; cursor: default; }
.out-body { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.out-empty { color: var(--faint); font-style: italic; padding: 4px 2px; }
.run { border: 1px solid var(--tool-line); background: #fff; border-radius: 2px; }
.run-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 5px 10px; border-bottom: 1px solid #eceef1; background: #f7f8f9; font-size: 12px; color: #59616d; }
.run-n { font-weight: 700; }
.run-head code { font-size: 12px; }
.run-cap { font-size: 11px; border: 1px solid var(--tool-line); padding: 0 6px; border-radius: 2px; background: #fff; }
.run-time { margin-left: auto; font-family: var(--mono); font-size: 11.5px; }
.run-body { padding: 10px 12px; font-size: var(--reply-size); line-height: var(--reply-line); color: var(--text); }
.run-body p { margin: 0 0 .5em; }
.run-body p:last-child { margin-bottom: 0; }
.run-body.is-busy { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.bar { width: 120px; height: 4px; background: #e3e6ea; overflow: hidden; position: relative; border-radius: 2px; display: inline-block; }
.bar i { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: var(--tool-sel); animation: slide 1.1s infinite linear; }
@keyframes slide { to { left: 100%; } }
.tool-tabs { display: flex; gap: 2px; padding: 0 8px; background: var(--tool-chrome); border-top: 1px solid var(--tool-line); font-size: 12px; }
.tab { padding: 4px 12px; color: #59616d; }
.tab.on { background: #fff; border: 1px solid var(--tool-line); border-top: 0; color: var(--text); font-weight: 600; }
.tool-status { display: flex; gap: 10px; align-items: center; padding: 3px 10px; min-height: 23px; font-size: 11.5px; color: #59616d; background: var(--tool-chrome); border-top: 1px solid var(--tool-line); }

/* Tool, light look */
.tool--light { border-radius: 10px; }
.tl-head { padding: 12px 16px; font-weight: 650; font-size: 14px; border-bottom: 1px solid var(--tool-line); }
.tl-body { padding: 8px 16px 14px; border-bottom: 1px solid var(--tool-line); flex: 0 1 auto; max-height: 54%; overflow-y: auto; }
.tl-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 10px 0 4px; }
.tl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tl-table th, .tl-table td { border-bottom: 1px solid #eceef1; padding: 4px 6px; text-align: left; vertical-align: top; font-weight: 400; }
.tl-table thead th { font-weight: 600; color: var(--muted); }
.tl-table tbody th { color: var(--muted); width: 22%; }
.tl-query { padding: 6px 10px; border: 1px solid var(--tool-line); border-radius: 6px; background: #fafbfc; }
.tl-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.tl-status { color: var(--muted); font-size: 12.5px; }
.tool--light .frame-lock { border: 0; background: none; text-align: left; padding: 6px 0 0; }

/* Tool, app look: decision-support software, styled like a printed report.
   Square corners, neutral grays, no accent color, monospace system labels.
   The AI text itself (.run-body) keeps the shared size and line height. */
.tool--app { border-radius: 0; background: #f2f2f2; border-color: #c8c8c8; }
.ap-bar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: #e4e4e4; color: #222; border-bottom: 1px solid #c8c8c8; }
.ap-logo { width: 10px; height: 10px; background: #555; flex: none; }
.ap-title { font-weight: 600; font-size: 13px; }
.ap-ver { font-family: var(--mono); font-size: 11px; color: #555; }
.ap-state { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11.5px; color: #444; text-transform: uppercase; letter-spacing: .04em; }
.ap-state i { width: 7px; height: 7px; background: #555; }
.ap-state.is-busy i { background: #999; }
.ap-main { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(220px, 2fr) minmax(300px, 3fr); grid-template-rows: minmax(0, 1fr); }
@media (max-width: 1100px) { .ap-main { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); } .ap-in { border-right: 0; border-bottom: 1px solid #c8c8c8; max-height: 45vh; } }
.ap-pane-head { display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 4px 12px; font-family: var(--mono); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #333; background: #ececec; border-bottom: 1px solid #c8c8c8; }
.ap-pane-head .out-actions { margin-left: auto; }
.ap-in { display: flex; flex-direction: column; min-height: 0; background: #fff; border-right: 1px solid #c8c8c8; }
.ap-in-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 12px 10px; }
.ap-label { display: block; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #555; margin: 10px 0 4px; }
.ap-query { padding: 6px 8px; border: 1px solid #b5b5b5; background: #fff; box-shadow: inset 0 1px 2px rgba(0,0,0,.06); font-size: 13px; color: #222; }
.ap-cards { display: grid; grid-template-columns: 1fr; border: 1px solid #c8c8c8; }
.ap-card { background: #fff; font-size: 13px; }
.ap-card + .ap-card { border-top: 1px solid #c8c8c8; }
.ap-card-head { padding: 3px 8px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #333; background: #f3f3f3; border-bottom: 1px solid #e2e2e2; }
.ap-card-name { padding: 6px 8px 0; font-weight: 600; }
.ap-card-text { padding: 5px 8px 7px; color: #222; }
.ap-attrs { border-top: 1px solid #e2e2e2; padding: 3px 8px 5px; }
.ap-attr { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; font-size: 12.5px; }
.ap-attr span { color: #555; }
.ap-attr b { font-weight: 600; font-variant-numeric: tabular-nums; }
.ap-actions { padding: 8px 12px; border-top: 1px solid #c8c8c8; background: #f7f7f7; }
.tool--app .run-btn { border-radius: 0; font-family: var(--mono); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.ap-run.is-ready { background: #333; border-color: #333; color: #fff; }
.ap-run.is-ready .run-icon { color: #fff; }
.ap-run.is-ready:hover:not(:disabled) { background: #111; }
.tool--app .frame-lock { border: 0; background: none; text-align: left; padding: 6px 0 0; }
.ap-out { display: flex; flex-direction: column; min-height: 0; background: #f2f2f2; }
.tool--app .out-btn { border-radius: 0; font-family: var(--mono); font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.ap-tabs { display: flex; gap: 0; padding: 6px 10px 0; border-bottom: 1px solid #c8c8c8; background: #f2f2f2; }
.ap-tab { font-family: var(--mono); font-size: 11.5px; padding: 4px 12px; margin-bottom: -1px; border: 1px solid transparent; background: none; color: #555; cursor: pointer; }
.ap-tab:hover { color: #111; }
.ap-tab.on { background: #fff; border-color: #c8c8c8; border-bottom-color: #fff; color: #111; font-weight: 700; }
.ap-tab-busy { color: #999; }
.ap-out-body { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; background: #fff; }
.ap-out-body .out-empty { padding: 14px 12px; }
.ap-report { padding: 10px 12px 14px; }
.ap-fields { border-collapse: collapse; width: 100%; font-size: 12.5px; margin-bottom: 4px; }
.ap-fields th, .ap-fields td { border: 1px solid #e0e0e0; padding: 3px 8px; text-align: left; vertical-align: top; }
.ap-fields th { width: 30%; font-family: var(--mono); font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: .05em; color: #555; background: #f7f7f7; }
.ap-fields td { font-family: var(--mono); font-size: 12px; color: #222; }
.ap-res-label { padding: 10px 0 0; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #555; }
.ap-report .run-body { padding: 4px 0 0; }
.ap-res-label--details { padding-top: 16px; margin-bottom: 4px; border-top: 1px solid #e0e0e0; margin-top: 14px; }
.ap-report > .ap-res-label:first-child { padding-top: 0; }
.ap-report .run-body.is-busy { padding-top: 10px; }
.tool--app .bar { border-radius: 0; background: #ddd; }
.tool--app .bar i { background: #666; }
.ap-foot { display: flex; gap: 16px; padding: 3px 12px; min-height: 22px; align-items: center; font-family: var(--mono); font-size: 11px; color: #555; background: #e4e4e4; border-top: 1px solid #c8c8c8; }
.ap-foot-id { margin-left: auto; }

/* =========================================================================
   REVIEWER MODE
   ========================================================================= */
#review-bar {
  position: fixed; top: 0; left: 0; right: 0; min-height: 44px; z-index: 50;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 7px 14px;
  background: #1f2430; color: #e9ecf1; font-size: 13px; white-space: nowrap;
}
.rb-badge { background: #f2c94c; color: #1f2430; font-weight: 700; padding: 3px 8px; border-radius: 4px; font-size: 12px; }
.rb-group { display: flex; align-items: center; gap: 6px; }
.rb-label { color: #a9b1bf; }
.rb-spacer { flex: 1; }
#review-bar select {
  font: inherit; font-size: 13px; background: #2b3140; color: #e9ecf1; border: 1px solid #485063;
  border-radius: 4px; padding: 3px 6px; max-width: 210px;
}
#review-bar select:disabled { opacity: .45; }
.rb-btn { font-size: 13px; background: #2b3140; color: #e9ecf1; border: 1px solid #485063; border-radius: 4px; padding: 4px 10px; cursor: pointer; }
.rb-btn:hover { background: #343b4d; }
.rb-btn.on, .rb-btn--hi.on { background: #e9ecf1; color: #1f2430; }
.rb-btn--hi { border-color: #f2c94c; }
.rb-check { display: flex; align-items: center; gap: 5px; cursor: pointer; color: #cfd5de; }
.seg { display: inline-flex; border: 1px solid #485063; border-radius: 5px; overflow: hidden; }
.seg button { background: transparent; color: #cfd5de; border: 0; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.seg button + button { border-left: 1px solid #485063; }
.seg button.on { background: #e9ecf1; color: #1f2430; font-weight: 600; }

.rb-where { font: 12px var(--mono); color: #f2c94c; background: #2b3140; border-radius: 4px; padding: 3px 8px; user-select: all; }

/* While the drawer is open the study shifts left, so you can see each switch take effect. */
body.drawer-open .item-layout { margin-right: min(420px, 100vw); grid-template-columns: minmax(300px, 4fr) minmax(380px, 7fr); }
body.drawer-open .page { margin-right: calc(min(420px, 100vw) + 20px); }
#drawer {
  position: fixed; top: var(--rb-h); right: 0; bottom: 0; width: min(420px, 100vw); z-index: 60;
  background: #fff; border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(0,0,0,.14); overflow-y: auto;
}
.dr-panel { padding: 16px 22px 40px; }
.dr-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -16px; background: #fff; padding: 12px 0 10px; margin-top: -12px; z-index: 1; }
.dr-close { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.dr-intro { color: var(--muted); font-size: 13.5px; }
.opt { border-top: 1px solid var(--line); padding: 14px 0 12px; }
.opt h3 { margin: 0 0 3px; }
.opt-what { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.seg--light { border-color: #cfd4db; flex-wrap: wrap; }
.seg--light button { color: var(--text); padding: 6px 12px; }
.seg--light button + button { border-left-color: #cfd4db; }
.seg--light button.on { background: var(--accent); color: #fff; }
.seg--light small { font-size: 10.5px; opacity: .75; font-weight: 500; margin-left: 3px; }
.opt-notes { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.opt-notes li { padding: 7px 9px; border-radius: 6px; border: 1px solid transparent; }
.opt-notes li.on { background: var(--accent-soft); border-color: #cddaf6; color: var(--text); }
.opt-num { display: flex; align-items: center; gap: 10px; }
.opt-num input { width: 110px; padding: 5px 8px; border: 1px solid #cfd4db; border-radius: 6px; font: inherit; }
.dr-foot { border-top: 1px solid var(--line); padding-top: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 6px 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; white-space: nowrap; }
.data-table th { color: var(--muted); font-weight: 600; }
.dr-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 6px; }
.rb-inline { font-size: 13px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.dr-danger { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.dr-actions a.btn { text-decoration: none; }

/* Last screen: withdraw box and "saved / could not send" status */
.consent.withdraw { margin-top: 4px; }
.sync-status { margin: 16px 0 4px; font-weight: 600; color: var(--muted); }
.sync-status:empty { display: none; }
.sync-status.is-ok { color: #1f6f43; }
.sync-status.is-bad { color: var(--danger); font-weight: 500; line-height: 1.6; }
.sync-status .btn { margin-top: 8px; }
.code-line { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.code-line b { font-family: var(--mono); color: var(--text); letter-spacing: .03em; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; font-weight: 500; }
