/* ============================================================
   Alpine ProblemSolvr — "the digital job slip", v2
   Darker, premium, high-contrast. Bright white work surface on a
   deep-navy chrome. Flat and bordered; semantic color only for
   urgency/status; mono for anything data-like.

   navy #13203A | paper #EEF1F5 | card #FFFFFF | line #C9D2DF
   ink  #0F1B2D | muted #4E5E77 | accent #24449B
   urgent #A61B2E | high #8F4E00 | ok-green #146C3F

   Type: Sora = wordmark only (matches Smile Studio) ·
   Bricolage Grotesque = display · Schibsted Grotesk = UI/body ·
   IBM Plex Mono = data
   ============================================================ */
:root {
  --navy: #13203a;
  --navy-hover: #1b2c4f;
  --paper: #eef1f5;
  --card: #ffffff;
  --line: #c9d2df;
  --line-strong: #a6b3c6;
  --ink: #0f1b2d;
  --muted: #4e5e77;
  --accent: #24449b;
  --accent-tint: #e3eaf8;
  --red: #a61b2e;
  --red-tint: #f7e6e9;
  --amber: #8f4e00;
  --amber-tint: #f6eddd;
  --green: #146c3f;
  --green-tint: #e2f0e8;

  --font: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "Schibsted Grotesk", sans-serif;
  --font-brand: "Sora", "Schibsted Grotesk", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Consolas", monospace;

  --r: 6px; /* one radius, everywhere */
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
}
/* Page background: a quiet brushed-silver wash — light crown, cooler toward
   the base, a faint sheen at the bottom edge. Painted on a fixed layer that
   always spans the exact viewport, so it fills every resolution and survives
   iOS (which ignores background-attachment: fixed).
   IMPORTANT: only html carries a flat backstop — a background on body would
   paint OVER this negative-z layer wherever the content box reaches, leaving
   a mismatched band below short content (the "empty bar at the bottom"). */
html {
  background: var(--paper);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(168deg, #f8fafc 0%, #e6ebf1 32%, #cfd8e3 72%, #dde3ec 100%);
}

/* ---- top bar: deep navy chrome ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--navy);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
}
.brand-logo-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 4px;
  padding: 3px 4px;
}
.brand-logo {
  height: 24px;
  width: auto;
  display: block;
}
.brand-name {
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.03em;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.iconbtn {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: transparent;
  border-radius: var(--r);
  font-family: var(--font);
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.iconbtn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.45);
}
.userchip {
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  background: #fff;
  color: var(--navy);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.12s ease;
}
.userchip:hover {
  background: var(--accent-tint);
}

/* ---- layout ---- */
#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px calc(48px + env(safe-area-inset-bottom, 0px));
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 14px;
}
.page-head .page-title {
  margin: 0;
}
.page-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 6px 0 14px;
}
.page-sub {
  color: var(--muted);
  font-size: 14px;
  margin: -8px 0 16px;
}

/* ---- cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
}

/* ---- login ---- */
.login-wrap {
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}
.login-logo {
  height: 56px;
  display: block;
}
.login-title {
  font-family: var(--font-brand);
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
}
.login-title .grad {
  color: var(--accent);
}
/* Type-ahead sign-in: field + anchored dropdown. The dropdown floats over
   the page, so typing never reflows anything. */
.name-box {
  position: relative;
  width: min(480px, 92vw);
}
.name-input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 15px 24px;
  font-family: var(--font);
  font-size: 17px;
  text-align: center;
  color: var(--ink);
}
.name-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
.name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.name-drop {
  position: absolute;
  top: calc(100% + 8px);
  left: 12px;
  right: 12px;
  z-index: 20;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(15, 27, 45, 0.14);
  overflow: hidden auto;
  max-height: 302px;
  text-align: left;
}
.name-opt {
  display: block;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  padding: 12px 20px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid var(--paper);
}
.name-opt:last-child {
  border-bottom: none;
}
.name-opt:hover,
.name-opt.is-hot {
  background: var(--accent-tint);
}
.name-opt.is-empty {
  color: var(--muted);
  font-weight: 500;
  cursor: default;
}
.name-opt.is-empty:hover {
  background: none;
}


/* Big desktop monitors: the front door scales up — pills most, wordmark next. */
@media (min-width: 1200px) {
  .login-logo {
    height: 72px;
  }
  .login-title {
    font-size: 36px;
  }
  .login-wrap .page-sub {
    font-size: 15px;
  }
  .name-box {
    width: min(520px, 92vw);
  }
  .name-input {
    font-size: 19px;
    padding: 17px 28px;
  }
  .name-opt {
    font-size: 16px;
    padding: 13px 22px;
  }

  /* PIN pad grows into a proper desktop keypad. */
  .pin-dots {
    gap: 15px;
  }
  .pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
  }
  .pin-pad {
    grid-template-columns: repeat(3, 96px);
    gap: 12px;
  }
  .pin-key {
    height: 76px;
    font-size: 24px;
  }
  .pin-key.is-ghost {
    font-size: 16px;
  }
  .pin-error {
    font-size: 15px;
  }

  /* …and the signed-in app fills the screen instead of hugging a phone-width
     column: wider container, larger type, roomier cards. */
  .topbar-inner {
    max-width: 1160px;
    padding: 12px 24px;
  }
  .brand-name {
    font-size: 19px;
  }
  #app {
    max-width: 1160px;
    padding-left: 24px;
    padding-right: 24px;
  }
  .page-title {
    font-size: 30px;
  }
  .page-sub {
    font-size: 15px;
  }
  .seg-btn {
    font-size: 14.5px;
    padding: 11px 4px;
  }
  .tab {
    font-size: 15px;
    padding: 11px 18px 10px;
  }
  .chip {
    font-size: 14px;
    padding: 8px 15px;
  }
  .sort-toggle {
    font-size: 13px;
  }
  .ticket-card {
    padding: 16px 20px;
  }
  .ticket-no {
    top: 15px;
    right: 18px;
    font-size: 17px;
  }
  .ticket-title {
    font-size: 17px;
  }
  .ticket-meta {
    font-size: 12.5px;
  }
  .pill {
    font-size: 11.5px;
  }
  .pill-cat {
    font-size: 13px;
  }
  .card {
    padding: 22px;
  }
  .detail-title {
    font-size: 26px;
  }
  .detail-no {
    font-size: 15px;
  }
  .detail-body,
  .msg-body {
    font-size: 15.5px;
  }
  .btn-primary {
    font-size: 15.5px;
    padding: 13px 26px;
  }
  .cat-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }
  .cat-btn {
    font-size: 14.5px;
    padding: 15px 14px;
  }
  .urg-btn {
    font-size: 14px;
    padding: 12px 4px;
  }
}

/* PIN pad — mono digits, like a keypad on real hardware */
.pin-dots {
  display: flex;
  gap: 12px;
  justify-content: center;
  min-height: 14px;
}
.pin-dot {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1.5px solid var(--line-strong);
  transition: background 0.1s ease, border-color 0.1s ease;
}
.pin-dot.is-filled {
  background: var(--ink);
  border-color: var(--ink);
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 10px;
  justify-content: center;
}
.pin-key {
  height: 60px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--card);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.pin-key:hover {
  border-color: var(--line-strong);
}
.pin-key:active {
  background: var(--accent-tint);
  border-color: var(--accent);
}
.pin-key.is-ghost {
  background: transparent;
  border-color: transparent;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}
.pin-key.is-ghost:hover {
  color: var(--ink);
}
.pin-error {
  color: var(--red);
  font-weight: 600;
  font-size: 14px;
  min-height: 18px;
  margin: 0;
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---- tabs: underline, not pills ---- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.tab {
  border: none;
  background: none;
  padding: 10px 14px 9px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.tab:hover {
  color: var(--ink);
}
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--navy);
}

/* ---- segmented control: the office "windows" ---- */
.seg {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  overflow: hidden;
  margin-bottom: 12px;
}
.seg-btn {
  flex: 1;
  border: none;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 9px 4px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.seg-btn:last-child {
  border-right: none;
}
.seg-btn:hover {
  color: var(--ink);
  background: var(--paper);
}
.seg-btn.is-active {
  background: var(--navy);
  color: #fff;
}

/* ---- category filter ---- */
.filterbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
  scrollbar-width: none;
}
.filterbar::-webkit-scrollbar {
  display: none;
}
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--r);
  padding: 7px 12px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.chip:hover {
  border-color: var(--line-strong);
}
.chip.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.chip.is-active .cat-dot {
  outline: 1px solid rgba(255, 255, 255, 0.5);
}
.sortrow {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.sort-toggle {
  border: none;
  background: none;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}
.sort-toggle:hover {
  color: var(--ink);
}

/* Category filter by screen size: chips on desktop, one native picker on
   phones (the chip carousel was too much for a narrow screen). */
.cat-select {
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 12px;
}
@media (max-width: 759px) {
  .filterbar {
    display: none;
  }
}
@media (min-width: 760px) {
  .cat-select {
    display: none;
  }
}

/* Location labels: full names on desktop, "Lkwd" abbreviation on phones */
.loc-short {
  display: none;
}
@media (max-width: 759px) {
  .loc-full {
    display: none;
  }
  .loc-short {
    display: inline;
  }
}

/* category dot — the whole category system in 8px */
.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--cat, var(--muted));
  flex: 0 0 auto;
}

/* ---- ticket list ---- */
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ticket-card {
  position: relative;
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--r);
  padding: 13px 16px;
  transition: border-color 0.12s ease;
}
.ticket-card:hover {
  border-color: var(--line-strong);
}
.ticket-card.u-low { border-left-color: var(--line-strong); }
.ticket-card.u-normal { border-left-color: var(--accent); }
.ticket-card.u-high { border-left-color: var(--amber); }
.ticket-card.u-urgent { border-left-color: var(--red); }

/* the stamped job number — the one thing a ticket is known by */
.ticket-no {
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--line-strong);
}
.ticket-card:hover .ticket-no {
  color: var(--muted);
}

.ticket-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 7px;
  padding-right: 92px; /* clear the stamped "LKW #001" */
}
.ticket-title {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.ticket-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
}

/* tags: flat stamps, mono, tinted */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 3px;
  padding: 2.5px 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.pill-cat {
  font-family: var(--font);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  padding-left: 0;
  border: none;
}
.pill-low { background: var(--paper); color: var(--muted); border-color: var(--line); }
.pill-normal { background: var(--accent-tint); color: var(--accent); border-color: #bccbe8; }
.pill-high { background: var(--amber-tint); color: var(--amber); border-color: #e0c69a; }
.pill-urgent { background: var(--red-tint); color: var(--red); border-color: #e6b2ba; }
.pill-nudged { background: var(--navy); color: #fff; border-color: var(--navy); }
.pill-open { background: var(--green-tint); color: var(--green); border-color: #b2d5c0; }
.pill-progress { background: var(--amber-tint); color: var(--amber); border-color: #e0c69a; }
.pill-closed { background: var(--paper); color: var(--muted); border-color: var(--line); }

/* empty state: the practice's one bit of whimsy, drawn quietly */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 14px;
}
.empty-teeth {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 16px;
}
.empty-teeth .tooth {
  width: 16px;
  height: 13px;
  border-radius: 3px 3px 7px 7px;
  background: var(--card);
  border: 1px solid var(--line-strong);
}
.empty-teeth .tooth:nth-child(1), .empty-teeth .tooth:nth-child(6) { transform: translateY(0); }
.empty-teeth .tooth:nth-child(2), .empty-teeth .tooth:nth-child(5) { transform: translateY(4px); }
.empty-teeth .tooth:nth-child(3), .empty-teeth .tooth:nth-child(4) { transform: translateY(6px); }

/* ---- forms ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
}
.input,
.textarea,
.select {
  width: 100%;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--card);
  padding: 11px 12px;
  font-family: var(--font);
  font-size: 16px; /* ≥16px so iOS doesn't zoom on focus */
  color: var(--ink);
}
.textarea {
  resize: vertical;
  min-height: 96px;
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* Send To: the "also notify" adder + its chips */
.cc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.cc-row .select {
  width: auto;
  max-width: 220px;
  font-size: 14px;
  padding: 8px 10px;
}
.cc-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-tint);
  border: 1px solid #bccbe8;
  border-radius: var(--r);
  padding: 5px 6px 5px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.cc-x {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 3px;
}
.cc-x:hover {
  color: var(--red);
}

/* category picker grid */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}
.cat-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 13px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--card);
  font-family: var(--font);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.cat-btn:hover {
  border-color: var(--line-strong);
}
.cat-btn.is-selected {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.cat-btn.is-selected .cat-dot {
  outline: 1px solid rgba(255, 255, 255, 0.5);
}

/* urgency picker */
.urgency-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.urg-btn {
  padding: 10px 4px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--card);
  font-family: var(--font);
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.urg-btn:hover {
  border-color: var(--line-strong);
}
.urg-btn.is-selected.u-low { background: var(--paper); border-color: var(--line-strong); color: var(--ink); }
.urg-btn.is-selected.u-normal { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.urg-btn.is-selected.u-high { background: var(--amber-tint); border-color: var(--amber); color: var(--amber); }
.urg-btn.is-selected.u-urgent { background: var(--red-tint); border-color: var(--red); color: var(--red); }

/* ---- buttons ---- */
.btn {
  font-family: var(--font);
  border: 1px solid transparent;
  cursor: pointer;
  border-radius: var(--r);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 22px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--navy-hover);
}
.btn-quiet {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
}
.btn-quiet:hover {
  border-color: var(--line-strong);
  background: var(--paper);
}
.btn-danger {
  background: var(--card);
  border-color: #e6b2ba;
  color: var(--red);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
}
.btn-danger:hover {
  background: var(--red-tint);
}
.btn-block {
  width: 100%;
}
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- ticket detail ---- */
.detail-head {
  margin-bottom: 14px;
  position: relative;
}
.detail-no {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.detail-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 8px 0;
}
.detail-body {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
}
.backlink {
  display: inline-block;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}
.backlink:hover {
  color: var(--accent);
}
.close-note-box {
  margin-top: 12px;
  background: var(--green-tint);
  border: 1px solid #b2d5c0;
  border-radius: var(--r);
  padding: 11px 13px;
  font-size: 14px;
  color: var(--green);
  font-weight: 500;
}

/* thread */
.thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.msg {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 11px 13px;
}
.msg.is-mine {
  background: var(--accent-tint);
  border-color: #bccbe8;
}
.msg-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.msg-time {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 11px;
}
.msg-body {
  white-space: pre-wrap;
  font-size: 14.5px;
  line-height: 1.5;
}
.event-line {
  text-align: center;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  padding: 2px 0;
}
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.composer .textarea {
  min-height: 48px;
  flex: 1;
}

/* ---- admin ---- */
.admin-section {
  margin-bottom: 22px;
}
.admin-section h3 {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 700;
}
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.admin-row:last-child {
  border-bottom: none;
}
.admin-row .who {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14.5px;
}
.admin-row .sub {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  margin-top: 2px;
}
.admin-row .grow {
  flex: 1;
  min-width: 140px;
}
/* stacked category row: name line, then the routing grid */
.admin-row-stack {
  flex-direction: column;
  align-items: stretch;
}
.cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.route-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.route-cell .mini-select {
  max-width: none;
  width: 100%;
}
.route-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.mini-select {
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--card);
  font-family: var(--font);
  font-weight: 500;
  font-size: 13px;
  color: var(--ink);
  padding: 7px 8px;
  max-width: 180px;
}
.linkbtn {
  border: none;
  background: none;
  font-family: var(--font);
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 6px;
}
.linkbtn:hover {
  text-decoration: underline;
}
.linkbtn.danger {
  color: var(--red);
}
.badge-admin,
.badge-off {
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-admin {
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px solid #bccbe8;
}
.badge-off {
  background: var(--paper);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* Practice-code entry: mono + uppercase, like typing a serial number */
.enroll-input {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- filed: success check ---- */
.filed-check {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--green-tint);
  border: 2px solid var(--green);
  color: var(--green);
  font-size: 30px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  z-index: 60;
  background: var(--navy);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--r);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 88vw;
  text-align: center;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- misc ---- */
.spinner {
  width: 32px;
  height: 32px;
  margin: 40px auto;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--navy);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .pin-error,
  .spinner {
    animation: none;
  }
}
