/* The stylesheet of every page. The pages' CSP loads styles from the site itself only, so it is a file: no <style>, no style="". */

:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #566170;
  --line: #d6dce3;
  --accent: #2457d6;
  --on-accent: #ffffff;
  --accent-soft: #e8eefc;
  --danger: #b3261e;
  --danger-soft: #fbeceb;
  --ok: #1d7a3e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1d2127;
    --text: #e8ebef;
    --muted: #9aa5b1;
    --line: #353c46;
    --accent: #7aa2f7;
    --on-accent: #0b1220;
    --accent-soft: #1f2a44;
    --danger: #f2877f;
    --danger-soft: #3a2224;
    --ok: #6fcf8f;
  }
}

* {
  box-sizing: border-box;
}

/* An element with `hidden` stays hidden whatever else sets its display. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Sarabun", Roboto, "Helvetica Neue", sans-serif;
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

main.wide {
  max-width: 72rem;
}

h1,
h2 {
  line-height: 1.25;
  margin: 0 0 1rem;
}

h1.brand {
  font-size: 1.5rem;
  letter-spacing: 0.01em;
}

h2 {
  font-size: 1.15rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 0 0 1rem;
}

label {
  display: block;
  font-weight: 600;
  margin: 0.85rem 0 0.3rem;
}

input,
select {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}

input[type="checkbox"] {
  width: auto;
  flex: none;
  margin: 0.2rem 0 0;
  accent-color: var(--accent);
}

button,
a.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  margin-top: 1rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* A second step beside the first: the same size, quieter. */
button.quiet {
  color: var(--accent);
  background: transparent;
}

/* A way to another view, or a small step: text that is a button. */
button.link {
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font-weight: 500;
  text-decoration: underline;
}

a {
  color: var(--accent);
}

/* Thai first, then English. A paragraph says both, the English on its own line, quieter. */
.say > [lang="en"],
.note > [lang="en"] {
  display: block;
  color: var(--muted);
  font-size: 0.92em;
}

/* A heading, a label, a button or a link says both on one line. */
.pair > [lang="en"]::before {
  content: " · ";
}

.pair > [lang="en"] {
  font-weight: 400;
  opacity: 0.85;
}

.say {
  margin: 0 0 0.6rem;
}

.small {
  font-size: 0.9rem;
}

.note {
  color: var(--danger);
  margin: 0.85rem 0 0;
}

.note > [lang="en"] {
  color: inherit;
  opacity: 0.85;
}

.note[data-tone="ok"] {
  color: var(--ok);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 1rem 0 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 0;
}

.check {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-weight: 500;
}

/* The page's head: the brand, and who is signed in. */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.top h1 {
  margin: 0;
}

.who {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.who button.link {
  margin-left: 0.5rem;
}

.status,
.days,
.progress {
  color: var(--muted);
}

.days {
  font-weight: 600;
}

.progress {
  margin: -0.25rem 0 1rem;
}

/* The trial's cards, numbered in their order: waiting ones are dimmed, the one to act on stands out, a done one is ticked. */
#trial {
  counter-reset: step;
}

.step {
  counter-increment: step;
}

.step h2::before {
  content: counter(step) ". ";
}

.step[data-phase="waiting"] {
  opacity: 0.6;
}

.step[data-phase="active"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.step[data-phase="done"] h2::after {
  content: " ✓";
  color: var(--ok);
}

.words p {
  margin: 0 0 0.6rem;
}

/* Claude's last error, in its own words. */
.banner {
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin: 0.5rem 0 0.75rem;
}

.banner p {
  margin: 0;
}

.banner .quote {
  margin-top: 0.3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

/* The QR code: black on white whatever the theme, its own quiet zone in it, large enough for a phone's camera. */
.qr {
  width: fit-content;
  margin: 0.25rem 0 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.qr svg {
  display: block;
  width: 240px;
  height: 240px;
  max-width: 70vw;
  max-height: 70vw;
}

/*
 * "Open LINE": on a phone the QR is on its own screen, so the link is a button there, and only there. The selector is as
 * specific as `a.button`'s and comes after it, so that it wins on every screen; `[hidden]` still wins over both.
 */
a.button.phone-only {
  display: none;
}

@media (max-width: 600px), (pointer: coarse) {
  a.button.phone-only {
    display: inline-block;
  }
}

.foot {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.9rem;
}

/* The privacy page. */
.notice section {
  margin-bottom: 1.25rem;
}

.notice h2 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.notice ul {
  margin: 0;
  padding-left: 1.2rem;
}

.notice li {
  margin-bottom: 0.35rem;
}

/* ---- the admin page ---- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.bar h2 {
  margin: 0;
}

.bar button {
  margin: 0;
}

.scroll {
  overflow-x: auto;
  margin-top: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  /* A long word (a failure's text) breaks, but no column is squeezed below its longest word: the wrapper scrolls instead. */
  overflow-wrap: break-word;
}

th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

td:first-child {
  white-space: nowrap;
}

td.acts {
  white-space: nowrap;
}

td.acts button {
  margin: 0 0.35rem 0 0;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
}

.done {
  color: var(--ok);
  margin: 0.85rem 0 0;
}

.capacity {
  margin: 0.5rem 0 0;
}

/* The callback page: Thai first, large; English under it. */
.message p {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.message p[lang="en"] {
  font-size: 1rem;
  color: var(--muted);
}

.message .links {
  margin: 1rem 0 0;
  font-size: 1rem;
}
