/* Research dashboard styles. Drawing-band colours are cycled in JS. */

:root {
  --bg: #f6f7f2;
  --panel: #ffffff;
  --ink: #1c2118;
  --muted: #6b7264;
  --line: #dfe3d6;
  --accent: #4a7c2f;
  --accent-soft: #eaf2df;
  --clear: #b3402f;
  --clear-soft: #fbeae7;
  /* Shared by submit and publish. */
  --submit: #8a6a12;
  --submit-soft: #fbf1d4;
  --warn: #8a6d1f;
  /* Settings; auto-Froggi is the darker shade of the same hue. */
  --setting: #7a7590;
  --setting-soft: #f4f3f8;
  --auto: #4a3f80;
  --auto-soft: #e6e3f4;
  --draw-0: #f2f6ea;
  --draw-1: #eaf1e4;
  --draw-2: #f0f4ec;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* The participant's own words. */
  --prompt-font: "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive;
  /* Froggi's own prompts, not what the participant typed. */
  --froggi-prompt-font: "Lucida Console", "Lucida Sans Typewriter", Monaco, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

/* ---------- login ---------- */

.loginpage {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.loginbox {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 30px 32px 24px; width: 100%; max-width: 350px; text-align: center;
  box-shadow: 0 2px 14px rgba(28, 33, 24, .07);
}
.loginbox .frog { font-size: 40px; line-height: 1; }
.loginbox h1 { font-size: 17px; margin: 10px 0 2px; }
.loginbox label {
  display: block; text-align: left; margin: 22px 0 5px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.loginbox input[type=password] {
  width: 100%; padding: 9px 11px; font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
.loginbox input[type=password]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.loginbox button { width: 100%; margin-top: 16px; padding: 9px; font-size: 14px; }
.loginerror {
  margin-top: 12px; padding: 7px 11px; border-radius: var(--radius);
  background: var(--clear-soft); border: 1px solid #f0cdc6;
  color: var(--clear); font-size: 13px;
}
.loginbox .foot { margin: 18px 0 0; line-height: 1.45; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 16px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; gap: 8px; align-items: center; padding-bottom: 6px;
  text-decoration: none; color: inherit; border-radius: var(--radius);
}
.brand:hover .frog { transform: scale(1.12) rotate(-6deg); }
.brand:hover h1 { color: var(--accent); }
.brand .frog { transition: transform .14s ease; }
.brand .frog { font-size: 20px; }
.brand h1 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: .01em; }
.brand .sub { font-size: 11px; color: var(--muted); }

.topright { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.signout { font-size: 12px; color: var(--muted); text-decoration: none; }
.signout:hover { color: var(--accent); text-decoration: underline; }

.tabs { display: flex; gap: 2px; }
.tabs button {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: none;
  background: none;
  padding: 5px 13px;
  font: inherit;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
}
.tabs button:hover { background: var(--accent-soft); color: var(--ink); }
.tabs button[aria-selected="true"] {
  background: var(--bg);
  border-color: var(--line);
  color: var(--ink);
  margin-bottom: -1px;
  padding-bottom: 6px;
}

main { padding: 14px 16px; max-width: 1700px; margin: 0 auto; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

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

h2 { font-size: 15px; margin: 0 0 3px; }
h3 { font-size: 13px; margin: 14px 0 6px; }
a { color: var(--accent); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }

button.btn, a.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 4px 10px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.btn:hover, a.btn:hover { background: var(--accent-soft); border-color: var(--accent); }
button.btn.primary, a.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
button.btn.primary:hover { filter: brightness(1.08); }

.crumbs { font-size: 12px; margin-bottom: 8px; color: var(--muted); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.tag {
  display: inline-block;
  padding: 3px 9px;
  margin: 0 2px 0 0;
  border-radius: 3px;
  background: #fafaf9;
  color: #4a4f45;
  border: 1px solid #a9ada1;
  font-family: var(--prompt-font);
  font-size: 12px;
  font-weight: 700;
  max-width: 90ch;
  overflow-wrap: break-word;
  vertical-align: top;
}
.tag.nowrap { white-space: nowrap; }
.tag.byfroggi {
  font-family: var(--froggi-prompt-font);
  font-size: 10.5px;
  font-weight: 400;
  color: #2d5c1c;
  background: #f3f8ec;
  border-color: #b8cfa4;
}
.tag.warn, .tag.grey, .tag.err {
  font-family: inherit; border-radius: 999px;
  font-size: 11px; font-weight: 400;
}
.tag.warn { background: #fdf5e0; color: var(--warn); border-color: #ecd9a4; }
.tag.grey { background: #f0f1ed; color: var(--muted); border-color: var(--line); }
.tag.err  { background: #fdeae2; color: #b4441c; border-color: #f0c3b0; }

.panel.prompts {
  background: var(--accent-soft);
  border-color: #cfe3bd;
}
.panel.prompts h3 { color: var(--accent); }

/* ---------- stats ---------- */

.stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 11px;
  min-width: 78px;
}
.stat .v { font-size: 16px; font-weight: 650; white-space: nowrap; }
.stat .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

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

.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

.tablebar {
  display: flex; justify-content: flex-end;
  padding: 2px 6px; border-bottom: 1px solid var(--line); background: #fbfcf9;
  position: sticky; left: 0;
}
.colToggle {
  appearance: none; background: none; border: none; cursor: pointer;
  font: inherit; font-size: 11px; color: var(--muted);
  padding: 1px 5px; border-radius: 3px;
  display: inline-flex; align-items: center; gap: 5px;
}
.colToggle svg { flex: none; }
.colToggle:hover { color: var(--accent); background: var(--accent-soft); }
/* `break-word`, not `anywhere`: `anywhere` also drops a column's minimum width
   to one character, which collapses every column next to the slack column. */
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td {
  text-align: left; padding: 3px 16px;
  border-bottom: 1px solid var(--line); vertical-align: top;
  /* No max-width: it would override the colgroup widths below. */
  overflow-wrap: break-word;
}
th.slack, td.slack { width: auto; max-width: none; padding: 0; }

/* One number per column. `.w-slack` absorbs the leftover width. */
col.w-time   { width: 8ch; }
col.w-who    { width: 9ch; }
col.w-what   { width: 62ch; }
col.w-prompt { width: 58ch; }
col.w-took   { width: 6ch; }
col.w-img    { width: 7ch; }
col.w-colx   { width: 15ch; }
col.w-slack  { width: auto; }
th { background: #fbfcf9; font-weight: 600; font-size: 11px; color: var(--muted); position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--accent-soft); }
td.timecell { white-space: nowrap; font-family: var(--mono); font-size: 11.5px; }
td.timecell .unrec { color: var(--muted); font-style: italic; font-family: inherit; }

/* Long ids scroll inside a fixed-width box. The inner div is required: a
   table cell ignores `overflow`. */
td.colx, th.colx { font-family: var(--mono); color: var(--muted); }
th.colx { font-size: 10px; white-space: nowrap; }
td.colx { max-width: none; width: 15ch; }

.cellscroll {
  font-size: 10.5px;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 15ch;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.cellscroll:hover { scrollbar-color: #c9ccc2 transparent; }
.cellscroll::-webkit-scrollbar { height: 3px; }
.cellscroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.cellscroll:hover::-webkit-scrollbar-thumb { background: #c9ccc2; }

.thumb {
  height: 30px; width: auto; max-width: 58px;
  object-fit: contain; background: #fff;
  border: 1px solid var(--line); border-radius: 3px;
  cursor: zoom-in; display: block;
}

/* Drawing bands; clears and submits get their own emphasis. */
tr.d0 td { background: var(--draw-0); }
tr.d1 td { background: var(--draw-1); }
tr.d2 td { background: var(--draw-2); }
tr.is-clear td { background: var(--clear-soft) !important; }
tr.is-clear td:first-child { box-shadow: inset 3px 0 0 var(--clear); }
tr.is-submit td { background: var(--submit-soft) !important; }
tr.is-submit td:first-child { box-shadow: inset 3px 0 0 var(--submit); }
tr.is-submit td { color: var(--submit); }
tr.is-setting td { background: var(--setting-soft) !important; color: var(--setting); }
tr.is-auto td { background: var(--auto-soft) !important; color: var(--auto); font-weight: 550; }

/* ---------- participants / sessions ---------- */

.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 7px; }
.pcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 11px; cursor: pointer; text-align: left; font: inherit; color: inherit;
}
.pcard:hover { border-color: var(--accent); background: var(--accent-soft); }
.pcard .name { font-weight: 650; font-size: 14px; margin-bottom: 4px; }
.pcard .figs { display: flex; gap: 9px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.pcard .figs b { color: var(--ink); font-weight: 600; }

.session { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 5px; background: var(--panel); }
.session > summary {
  cursor: pointer; padding: 6px 11px; display: flex; gap: 8px;
  align-items: center; flex-wrap: wrap; list-style: none;
}
.session > summary::-webkit-details-marker { display: none; }
.session > summary::before { content: '▸'; color: var(--muted); }
.session[open] > summary::before { content: '▾'; }
.session[open] > summary { border-bottom: 1px solid var(--line); background: #fbfcf9; }
.session .stitle { font-weight: 600; font-size: 12.5px; }
.session .sbody { padding: 8px 10px; }

/* ---------- session view: timeline + chat ---------- */

.sessionlayout { display: flex; gap: 11px; align-items: flex-start; }
.sessionmain { flex: 1; min-width: 0; }
.chatpane {
  width: 330px; flex: none; position: sticky; top: 58px;
  max-height: calc(100vh - 74px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.chatpane.hidden { display: none; }
.chathead { padding: 7px 11px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.chatscroll { overflow-y: auto; padding: 9px 11px; }

/* Mirrors the drawing app's chat: participant right, Froggi left. */
.chatline { display: flex; gap: 7px; margin-bottom: 7px; align-items: flex-start; }
.chatline .when {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  flex: none; width: 50px; padding-top: 3px; text-align: right;
}
.chatline .when.unrec { font-style: italic; font-family: inherit; font-size: 9.5px; }
.chatline .bubble {
  padding: 4px 9px; border-radius: 10px; font-size: 12.5px;
  background: #f1f3ed; border: 1px solid var(--line); max-width: 215px;
}

.chatline.you { flex-direction: row-reverse; }
.chatline.you .when { text-align: left; }
.chatline.you .bubble {
  background: #fff; border-color: #d6d9cf;
  border-bottom-right-radius: 3px;
}

.chatline.froggi .bubble {
  background: var(--accent-soft); border-color: #cfe3bd;
  border-bottom-left-radius: 3px;
}

/* Neither side: centred, reading as punctuation between the two. */
.chatline.meta, .chatline.clear, .chatline.submit,
.chatline.auto, .chatline.settings { justify-content: center; }
.chatline.meta .when, .chatline.clear .when, .chatline.submit .when,
.chatline.auto .when, .chatline.settings .when { width: auto; text-align: center; }
.chatline.meta .bubble { background: none; border: none; color: var(--muted); font-style: italic; padding: 3px 0; }
.chatline.clear .bubble { background: var(--clear-soft); border-color: #f0cdc6; color: var(--clear); }
.chatline.submit .bubble { background: var(--submit-soft); border-color: #e6d29a; color: var(--submit); }
.chatline.settings .bubble { background: var(--setting-soft); border-color: #e2e0ea; color: var(--setting); font-size: 11.5px; }
.chatline.auto .bubble { background: var(--auto-soft); border-color: #cbc6e6; color: var(--auto); font-weight: 550; }

.chatline .bubble .prompt { font-family: var(--prompt-font); font-weight: 700; }
.chatline .bubble .prompt.byfroggi {
  font-family: var(--froggi-prompt-font); font-weight: 400; color: #2d5c1c;
}
.chatline .bubble .took { color: var(--muted); font-size: 11px; }
.chatline .shots { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.chatline.you .shots { justify-content: flex-end; }
.chatline .shots img {
  height: 52px; border: 1px solid var(--line); border-radius: 3px;
  cursor: zoom-in; background: #fff;
}
.chatline .shots img:hover { border-color: var(--accent); }

/* ---------- All Events: facets ---------- */

.eventslayout { display: flex; gap: 11px; align-items: flex-start; }
.facets { width: 195px; flex: none; position: sticky; top: 58px; max-height: calc(100vh - 74px); overflow-y: auto; }
.facetgroup { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px; margin-bottom: 6px; }
.facetgroup h4 { margin: 0 0 5px; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facetgroup label { display: flex; gap: 5px; align-items: center; font-size: 12px; padding: 1px 0; cursor: pointer; }
.facetgroup label:hover { color: var(--accent); }
.facetgroup label .n { margin-left: auto; color: var(--muted); font-size: 11px; }
.facetgroup input[type=text], .facetgroup input[type=date], .facetgroup select {
  width: 100%; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: 4px; font: inherit; font-size: 12.5px; margin-bottom: 6px;
}
.eventsmain { flex: 1; min-width: 0; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 12px; }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed; inset: 0; background: rgba(20, 24, 18, .78);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 30px;
}
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; text-align: center; }
.lightbox img { max-width: 88vw; max-height: 82vh; background: #fff; border-radius: var(--radius); }
.lightbox figcaption { color: #eee; font-size: 13px; margin-top: 10px; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 1100px) {
  .chatpane { width: 300px; }
  .facets { width: 190px; }
}
@media (max-width: 850px) {
  .sessionlayout, .eventslayout { flex-direction: column; }
  .chatpane, .facets { width: 100%; position: static; max-height: none; }
}
