/* Apple HIG-inspired theme with Liquid Glass controls: the same theme as the Ask Me Anything app.
   - Liquid Glass is used for the control/navigation layer only (nav bar, segmented controls,
     the one primary action). Content (cards, fields) sits on solid surfaces.
   - System colors, SF system font, 17px body, 44px touch targets on touch devices.
   - Respects prefers-reduced-transparency, prefers-reduced-motion and dark mode.
   Used by the notebook, the Room Board and the trainer page. The notebook's service worker
   caches this file, so the notebook keeps its look with Wi-Fi off. */
:root {
  /* HIG system colors (light) */
  --bg: #f2f2f7;                       /* systemGroupedBackground */
  --surface: #ffffff;                  /* secondarySystemGroupedBackground */
  --text: #000000;                     /* label */
  --secondary: rgba(60, 60, 67, 0.6);  /* secondaryLabel */
  --tertiary: rgba(60, 60, 67, 0.3);   /* tertiaryLabel */
  --separator: rgba(60, 60, 67, 0.12);
  --fill: rgba(120, 120, 128, 0.12);
  --blue: #007aff;
  --green: #34c759;
  --green-text: #248a3d;
  --orange-text: #b25000;
  --red: #ff3b30;
  --purple: #af52de;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --radius: 22px;

  /* Liquid Glass material */
  --glass-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.34));
  --glass-bg-hover: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.46));
  --glass-rim: rgba(255, 255, 255, 0.75);
  --glass-hi: rgba(255, 255, 255, 0.95);
  --glass-glow: rgba(255, 255, 255, 0.45);
  --glass-shadow: 0 6px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.08);
  --glass-blur: blur(14px) saturate(180%);

  --ambient-1: rgba(0, 122, 255, 0.16);
  --ambient-2: rgba(175, 82, 222, 0.12);
  --ambient-3: rgba(52, 199, 89, 0.1);

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue",
    "Sukhumvit Set", "Noto Sans Thai", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.014em;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #ffffff;
    --secondary: rgba(235, 235, 245, 0.6);
    --tertiary: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.6);
    --fill: rgba(120, 120, 128, 0.24);
    --blue: #0a84ff;
    --green: #30d158;
    --green-text: #30d158;
    --orange-text: #ff9f0a;
    --red: #ff453a;
    --purple: #bf5af2;
    --card-shadow: none;

    --glass-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06));
    --glass-bg-hover: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.1));
    --glass-rim: rgba(255, 255, 255, 0.22);
    --glass-hi: rgba(255, 255, 255, 0.35);
    --glass-glow: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);

    --ambient-1: rgba(10, 132, 255, 0.22);
    --ambient-2: rgba(191, 90, 242, 0.16);
    --ambient-3: rgba(48, 209, 88, 0.08);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }
body { margin: 0; line-height: 1.47; font-size: 17px; min-height: 100vh; }
/* Soft ambient light behind everything, so the glass has something to refract. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(55% 45% at 12% 0%, var(--ambient-1), transparent 70%),
    radial-gradient(45% 40% at 92% 8%, var(--ambient-2), transparent 70%),
    radial-gradient(60% 45% at 50% 105%, var(--ambient-3), transparent 70%),
    var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Liquid Glass ----------
   Used sparingly: only the floating nav bar, segmented controls and the one primary action. */
.glass,
.seg,
.nav-inner {
  position: relative;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-rim);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),          /* top specular highlight */
    inset 0 0 10px var(--glass-glow),        /* soft inner glow */
    var(--glass-shadow);
}
/* Subtle specular sheen on the nav bar and the primary button */
.nav-inner::after,
button.primary::after {
  content: "";
  position: absolute;
  inset: 1px 1px 50% 1px;
  border-radius: inherit;
  border-bottom-left-radius: 40% 30%;
  border-bottom-right-radius: 40% 30%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
  pointer-events: none;
  opacity: 0.6;
}

/* ---------- Floating glass nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 16px 0;
}
.nav-inner {
  max-width: 820px;
  margin: 0 auto;
  min-height: 56px;
  padding: 6px 8px 6px 22px;
  border-radius: 980px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--text); white-space: nowrap; }
.nav a { font-size: 0.88rem; font-weight: 500; color: var(--text); white-space: nowrap; }
.nav a:hover { text-decoration: none; opacity: 0.7; }

/* ---------- Layout & type (HIG Large Title / Title 3 / Body) ---------- */
main { max-width: 820px; margin: 0 auto; padding: 48px 22px 96px; }
main.narrow { max-width: 720px; }
h1 {
  font-size: clamp(2.125rem, 6vw, 3.5rem);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
}
.eyebrow { font-size: 0.82rem; font-weight: 600; color: var(--secondary); margin: 0 0 8px; }
.sub { color: var(--secondary); font-size: 1.25rem; line-height: 1.4; margin: 0 0 32px; letter-spacing: -0.015em; }
.spacer { flex: 1; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 22px;
}

/* ---------- Buttons ----------
   Default: HIG "gray" capsule (plain fill, no glass). Primary: tinted glass. */
button, a.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 0.94rem;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--text);
  background: var(--fill);
  border: 0;
  border-radius: 980px;
  min-height: 36px;
  padding: 7px 18px;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s, box-shadow 0.2s, filter 0.2s;
}
a.button:hover { text-decoration: none; }
button:hover, a.button:hover { background: color-mix(in srgb, var(--fill) 100%, var(--text) 6%); }
button:active { transform: scale(0.97); }
/* Liquid Glass controls "lift" and brighten under the finger */
button.primary:active, .seg button:active { transform: scale(1.04); filter: brightness(1.06); }
button:disabled { opacity: 0.4; cursor: default; transform: none; filter: none; }
button:focus-visible, a.button:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 2px; }

/* Tinted glass: primary action */
button.primary {
  color: #fff;
  font-weight: 600;
  font-size: 1.06rem;
  min-height: 50px;
  padding: 12px 32px;
  border: 1px solid color-mix(in srgb, var(--blue) 60%, white);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--blue) 82%, white),
    color-mix(in srgb, var(--blue) 92%, black));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 4px rgba(0, 0, 0, 0.1),
    0 6px 18px color-mix(in srgb, var(--blue) 28%, transparent),
    0 1px 3px rgba(0, 0, 0, 0.1);
}
button.primary:hover { filter: brightness(1.06); }
button.small { font-size: 0.85rem; min-height: 32px; padding: 5px 14px; }
button.danger { color: var(--red); }
/* Filled blue: a selected or secondary-prominent control inside content */
button.tinted, a.button.tinted { color: #fff; background: var(--blue); }
button.tinted:hover, a.button.tinted:hover { background: color-mix(in srgb, var(--blue) 90%, white); }

/* Glass segmented control with a floating glass thumb */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 980px;
}
.seg button {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  min-height: 32px;
  padding: 5px 16px;
  font-size: 0.86rem;
  color: var(--secondary);
}
.seg button::after { display: none; }
.seg button:hover { background: transparent; color: var(--text); }
.seg button[aria-pressed="true"] {
  color: var(--text);
  font-weight: 600;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.75));
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 #fff, 0 3px 10px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
}
@media (prefers-color-scheme: dark) {
  .seg button[aria-pressed="true"] {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.16));
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 3px 10px rgba(0, 0, 0, 0.4);
  }
}
.lang-toggle button { padding: 4px 12px; min-height: 30px; font-size: 0.8rem; }

/* ---------- Text fields (content: solid surface) ---------- */
.field {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--separator);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent);
}
textarea, .field input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1.45;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
}
textarea { min-height: 96px; resize: vertical; }
textarea::placeholder { color: var(--tertiary); }
.msg { min-height: 1.4em; color: var(--secondary); font-size: 0.95rem; margin: 0; }
.msg.ok { color: var(--green-text); }
.msg.err { color: var(--red); }

/* Live status with a dot, as on the Ask Me Anything questions page */
.net { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--secondary); white-space: nowrap; }
.net::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tertiary); }
.net.offline, .net.live { color: var(--green-text); font-weight: 600; }
.net.offline::before, .net.live::before {
  background: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent);
}

/* ================= Lab Notebook ================= */
.saved { font-size: 0.82rem; color: var(--tertiary); white-space: nowrap; }
.note { font-size: 0.82rem; color: var(--secondary); margin: 10px 0 0; }
b.ui { font-weight: 600; }

/* Sample files */
.downloads { padding-bottom: 8px; margin-bottom: 12px; }
.downloads-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.downloads-head h2 { font-size: 1.25rem; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.downloads-head p { margin: 2px 0 0; color: var(--secondary); font-size: 0.82rem; }
.downloads-head button { margin-left: auto; }
.file { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--separator); }
.file-name { font-weight: 600; word-break: break-all; }
.file-where { display: block; color: var(--secondary); font-size: 0.82rem; font-weight: 400; word-break: normal; }
.file a { margin-left: auto; font-weight: 500; white-space: nowrap; }

/* Step index */
.index { padding: 18px 22px 12px; margin-bottom: 28px; }
.index-head { display: flex; align-items: baseline; gap: 12px; }
.index-head h2 { font-size: 1.25rem; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.index-count { margin-left: auto; font-size: 0.82rem; color: var(--secondary); font-variant-numeric: tabular-nums; }
.progress { height: 6px; border-radius: 980px; background: var(--fill); margin: 12px 0 8px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; border-radius: 980px; background: var(--blue); transition: width 0.35s ease; }
.index ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
.index a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 8px; margin: 0 -8px; border-radius: 14px; color: var(--text); }
.index a:hover { text-decoration: none; background: var(--fill); }
.index-icon {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  color: var(--secondary); background: var(--fill);
}
.index-icon svg { width: 19px; height: 19px; }
.index-name { font-weight: 500; line-height: 1.25; }
.index-name small { color: var(--tertiary); font-size: 0.82rem; font-weight: 600; margin-right: 8px; font-variant-numeric: tabular-nums; }
.index a.current .index-icon { color: #fff; background: var(--blue); }
.index a.current .index-name { font-weight: 600; }
.index a.done .index-icon { color: var(--green-text); background: color-mix(in srgb, var(--green) 18%, transparent); }
.index a.done .index-name { color: var(--secondary); }

/* Steps */
.step { padding-bottom: 18px; margin-bottom: 12px; scroll-margin-top: 92px; transition: box-shadow 0.25s; }
.step.current { box-shadow: var(--card-shadow), 0 0 0 2px color-mix(in srgb, var(--blue) 70%, transparent); }
.step-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.step-icon {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, transparent);
}
.step-icon svg { width: 26px; height: 26px; }
.step.done .step-icon { color: var(--green-text); background: color-mix(in srgb, var(--green) 18%, transparent); }
.step-meta { font-size: 0.78rem; font-weight: 600; color: var(--secondary); margin: 0 0 1px; font-variant-numeric: tabular-nums; }
.step-head h3 { font-size: 1.25rem; font-weight: 600; margin: 0; letter-spacing: -0.02em; line-height: 1.2; }
.step-goal { color: var(--secondary); margin: 0 0 14px; }
.tag { margin-left: auto; align-self: flex-start; font-size: 0.76rem; font-weight: 600; white-space: nowrap; padding: 2px 10px; border-radius: 980px; }
.tag.perf { color: var(--orange-text); background: color-mix(in srgb, var(--orange-text) 14%, transparent); }
.tag.sec { color: var(--green-text); background: color-mix(in srgb, var(--green) 16%, transparent); }
.tag.cost { color: var(--blue); background: color-mix(in srgb, var(--blue) 14%, transparent); }
.step ol.do { margin: 0 0 4px; padding-left: 24px; }
.step ol.do li { margin-bottom: 6px; padding-left: 2px; }
.step ol.do li::marker { color: var(--secondary); font-variant-numeric: tabular-nums; }

/* Prompt to copy */
.prompt {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--fill); border-radius: 16px; padding: 14px 14px 14px 16px; margin: 10px 0 12px;
}
.prompt p { margin: 0; flex: 1; }
.prompt .copy { flex: none; min-width: 84px; }
.copy.copied { background: var(--green); color: #fff; }

/* Fields, as an inset grouped list */
.fields { border-radius: 16px; background: var(--fill); margin: 14px 0 4px; overflow: hidden; }
.fields .row { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 6px 16px; }
.fields .row + .row { border-top: 1px solid var(--separator); }
.fields .row label { flex: 1; }
.fields .row .hint { display: block; font-size: 0.76rem; color: var(--secondary); }
.fields .row input[type="number"], .fields .row select {
  font: inherit; color: inherit; border: 0; background: transparent; text-align: right; font-size: 1.06rem;
  font-variant-numeric: tabular-nums; width: 9em; padding: 4px 0; outline: none;
}
.fields .row select { width: auto; cursor: pointer; text-align-last: right; -webkit-appearance: none; appearance: none; }
/* Every row ends in the same 3.4em column: a unit for numbers, a chevron for dropdowns, so values line up. */
.fields .row .unit.chev { text-align: center; color: var(--tertiary); pointer-events: none; }
.fields .row input:focus-visible, .fields .row select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent); border-radius: 8px;
}
.fields .row .unit { color: var(--secondary); width: 3.4em; font-size: 0.9rem; }
.fields .row input.invalid { color: var(--red); }
.step .field { margin-top: 10px; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 12px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); }

.step-foot { display: flex; justify-content: flex-end; margin-top: 14px; }

/* Meter */
.meter { display: flex; align-items: baseline; gap: 14px; margin: 18px 0 0; }
.meter-value { font-size: 3.5rem; font-weight: 700; line-height: 1; letter-spacing: -0.03em; color: var(--green-text); font-variant-numeric: tabular-nums; }
.meter-caption { color: var(--secondary); }

/* Send */
.review { margin: 14px 0 0; }
.review .row { min-height: 40px; font-size: 0.94rem; }
.review .row span:first-child { flex: 1; }
.review .row span:last-child { color: var(--secondary); font-variant-numeric: tabular-nums; text-align: right; }
button.send { width: 100%; margin-top: 18px; }
.send-status { font-size: 0.88rem; margin: 10px 0 0; color: var(--secondary); text-align: center; min-height: 1.4em; }
.send-status.ok { color: var(--green-text); font-weight: 600; }
.send-status.err { color: var(--red); }

footer.fine { max-width: 720px; margin: 0 auto; padding: 0 22px 48px; font-size: 0.76rem; color: var(--secondary); }

/* First-run scenario chooser */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.36);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.sheet { background: var(--surface); border-radius: 28px; padding: 28px 22px 22px; width: 100%; max-width: 440px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); }
.sheet h2 { font-size: 1.6rem; margin: 0 0 6px; letter-spacing: -0.025em; }
.sheet p { margin: 0 0 18px; color: var(--secondary); }
button.choice {
  display: flex; width: 100%; justify-content: flex-start; gap: 12px; text-align: left;
  border-radius: 18px; padding: 14px 18px; margin-bottom: 10px; min-height: 64px;
}
.choice strong { display: block; font-size: 1.06rem; font-weight: 600; }
.choice span { color: var(--secondary); font-size: 0.82rem; }
.choice::after { content: "›"; margin-left: auto; font-size: 1.4rem; color: var(--tertiary); }

@media (max-width: 640px) {
  .index ol { grid-template-columns: 1fr; }
  .nav-inner { padding-left: 14px; gap: 8px; }
  .nav .brand { display: none; }
  main { padding-top: 32px; }
  .tag { display: none; }
}

/* ---------- HIG: 44pt touch targets on touch devices ---------- */
@media (pointer: coarse) {
  button, button.small, .seg button { min-height: 44px; }
  .lang-toggle button { min-height: 38px; }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-transparency: reduce) {
  .glass, .seg, .nav-inner {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--surface);
  }
  button.primary::after, .nav-inner::after { display: none; }
  body::before { background: var(--bg); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  button, button:active { transition: none; transform: none; }
}
