/* Generated styles for the "public" portal. Theme tokens come from the IR.
   Mobile-first: what stands outside a media query is the phone layout, and the
   two breakpoints (640px and 1024px) add room. The responsive rules of each
   built-in block are that block's own Block CSS, appended further down. */
:root {
  --primary: #0972d3;
  --bg: #ffffff;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ink: #16191f;
  --muted: #5f6b7a;
  --border: #d5dbdb;
  --card: #ffffff;
  --rule: #e9ebed;
  --touch: 44px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.5; overflow-wrap: break-word; }
a { color: var(--primary); text-decoration: none; }
img, video { max-width: 100%; height: auto; }
.page { max-width: 960px; margin: 0 auto; padding: 16px 12px; }

/* Controls. Anything a finger presses is at least --touch tall; the rule that
   closes this base stylesheet (before the built-in Block CSS) lets controls
   shrink again on a wide screen with a mouse. A checkbox, radio or slider is
   sized by its row, not by itself. */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--touch); background: var(--primary); color: #fff; padding: 10px 20px; border: none; border-radius: 8px; font-size: 15px; text-align: center; cursor: pointer; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.danger { background: #d13212; }
input, select, textarea { min-height: var(--touch); max-width: 100%; }
input[type=checkbox], input[type=radio], input[type=range] { min-height: 0; }

.error { color: #d13212; margin: 0; font-size: 14px; }
.ok { color: #037f0c; margin: 0; font-size: 14px; }
.muted { color: var(--muted); margin: 8px 0; font-size: 14px; }
.unknown { color: #d13212; padding: 12px; border: 1px dashed #d13212; border-radius: 8px; }

/* Developer mode overlay (append ?dev=1 to the URL). */
.cshells-dev .obs { position: relative; outline: 1px dashed rgba(9, 114, 211, .5); }
.cshells-dev .obs::after {
  content: attr(data-type) " · " attr(id);
  position: absolute; top: 0; left: 0;
  font: 10px/1.4 monospace; background: var(--primary); color: #fff;
  padding: 1px 5px; border-radius: 0 0 4px 0; opacity: .85; pointer-events: none; z-index: 9999;
}
/* In the editor's Launch Demo a label is a link to its block in the builder. */
.cshells-demo.cshells-dev .obs::after { pointer-events: auto; cursor: pointer; }

/* ---- Built-in blocks: how each looks on a phone ---- */
.navbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 12px; padding: 6px 12px; background: var(--card); border-bottom: 1px solid var(--border); }
.navbar .brand { font-weight: 700; font-size: 18px; }
.nav-links { display: flex; gap: 18px; list-style: none; margin: 0; padding: 0; }
.navbar .session { display: flex; gap: 10px; align-items: center; }
.navbar .session .who { color: var(--muted); font-size: 14px; }

.hero { text-align: center; padding: 40px 4px; }
.hero-title { font-size: 28px; line-height: 1.25; margin: 0 0 12px; }
.hero-sub { font-size: 16px; color: var(--muted); margin: 0 0 24px; }

.page-heading { margin: 22px 0 8px; }
.page-heading h2 { margin: 0 0 4px; font-size: 20px; }
.page-heading p { margin: 0; color: var(--muted); }

.auth-form, .settings-form { max-width: 380px; margin: 24px auto; display: flex; flex-direction: column; gap: 14px; background: var(--card); padding: 20px 16px; border: 1px solid var(--border); border-radius: 12px; }
.auth-form h2, .settings-form h2 { margin: 0 0 8px; }
.auth-form label, .settings-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.auth-form input, .settings-form input { padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; color: var(--ink); }
.auth-form .switch { margin: 0; text-align: center; font-size: 14px; }
.auth-form small.error { font-size: 12px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { min-width: 0; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.tile-count { font-size: 26px; font-weight: 700; color: var(--primary); }
.tile-label { color: var(--muted); text-transform: capitalize; }

.data-table .table-wrap { overflow-x: auto; }
.data-table table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--rule); }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: #f2f7ff; }
.data-table td.empty { color: #8a94a0; }
.data-table .scroller { max-height: 440px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.data-table tbody tr { height: 40px; }
.data-table tr.spacer { height: auto; }
.data-table tr.spacer td { padding: 0; border: 0; }
.data-table td.actions { white-space: nowrap; text-align: right; }
.data-table td.actions .btn + .btn { margin-left: 6px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 14px; color: var(--muted); }

.record-form { max-width: 560px; margin: 16px 0; display: flex; flex-direction: column; gap: 14px; background: var(--card); padding: 16px; border: 1px solid var(--border); border-radius: 12px; }
.record-form .field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); text-transform: capitalize; }
.record-form .field-boolean { flex-direction: row; align-items: center; gap: 10px; }
.record-form input:not([type=checkbox]), .record-form textarea, .record-form select { padding: 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 16px; color: var(--ink); text-transform: none; }
.record-form textarea { resize: vertical; }
.record-form small { text-transform: none; }

.sequence { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; outline: none; max-width: 720px; }
.sequence:focus-visible { box-shadow: 0 0 0 2px var(--primary); }
.seq-stage { min-height: 160px; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.seq-text { font-size: 18px; line-height: 1.7; white-space: pre-wrap; margin: 0; }
.seq-img { max-width: 100%; border-radius: 8px; }
.seq-bar { height: 4px; background: var(--rule); border-radius: 2px; margin: 16px 0 12px; overflow: hidden; }
.seq-fill { height: 100%; background: var(--primary); transition: width .2s ease; }
.seq-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seq-count { margin-left: auto; color: var(--muted); font-size: 14px; }
.seq-pick { margin: 12px 0 0; padding-left: 20px; max-height: 220px; overflow: auto; }
.seq-pick li.on a { font-weight: 700; }

.acl { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; max-width: 560px; }
.acl h3 { margin: 0 0 10px; }
.acl-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.acl-list li { display: flex; gap: 10px; align-items: center; }
.acl-list .who { min-width: 0; overflow-wrap: anywhere; }
.acl-list .lvl { color: var(--muted); font-size: 13px; }
.acl-list .btn { margin-left: auto; }
.acl-add { display: flex; gap: 8px; flex-wrap: wrap; }
.acl-add input, .acl-add select { padding: 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.acl-add input { flex: 1; min-width: 180px; }

/* ---- 640px and up: room for the page's own margins ---- */
@media (min-width: 640px) {
  .page { padding: 24px 16px; }
}

/* ---- 1024px and up, with a mouse: controls return to their compact size ---- */
@media (min-width: 1024px) and (pointer: fine) {
  .btn, input, select, textarea { min-height: 0; }
}

/* Breakpoint tokens (ADR-0016). CSS cannot read a variable inside a media
   query, so rules use the literal 640px and 1024px; the tokens are there for
   scripts and for reference. */
:root { --bp-sm: 640px; --bp-lg: 1024px; }

/* ---- Block CSS: auth_form (built-in) ---- */
:where([data-type="auth_form"]) .switch a { display: inline-flex; align-items: center; min-height: var(--touch); }
@media (min-width: 640px) {
  :where([data-type="auth_form"]).auth-form { margin: 48px auto; padding: 28px; }
  :where([data-type="auth_form"]).auth-form input { font-size: 15px; }
}
@media (min-width: 1024px) and (pointer: fine) {
  :where([data-type="auth_form"]) .switch a { min-height: 0; }
}

/* ---- Block CSS: hero (built-in) ---- */
@media (min-width: 640px) {
  :where([data-type="hero"]).hero { padding: 64px 16px; }
  :where([data-type="hero"]) .hero-title { font-size: 40px; line-height: 1.5; }
  :where([data-type="hero"]) .hero-sub { font-size: 18px; margin-bottom: 28px; }
}

/* ---- Block CSS: navbar (built-in) ---- */
:where([data-type="navbar"]) .brand { display: inline-flex; align-items: center; min-height: var(--touch); }
:where([data-type="navbar"]) .nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: var(--touch); height: var(--touch); margin-right: -10px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; }
:where([data-type="navbar"]) .nav-toggle-bars { display: block; width: 20px; height: 2px; border-radius: 1px; background: currentColor; box-shadow: 0 6px 0 currentColor, 0 -6px 0 currentColor; }
:where([data-type="navbar"]):where(.has-menu) .nav-links { display: none; flex: 0 0 100%; flex-direction: column; gap: 0; padding-bottom: 6px; }
:where([data-type="navbar"]):where(.has-menu).open .nav-links { display: flex; }
:where([data-type="navbar"]) .nav-links a { display: flex; align-items: center; min-height: var(--touch); }
:where([data-type="navbar"]):where(.has-menu) .session { flex-wrap: wrap; border-top: 1px solid var(--border); }
@media (min-width: 640px) {
  :where([data-type="navbar"]).navbar { padding: 6px 16px; }
  :where([data-type="navbar"]) .nav-toggle { display: none; }
  :where([data-type="navbar"]):where(.has-menu) .nav-links { display: flex; flex: 0 1 auto; flex-direction: row; flex-wrap: wrap; gap: 0 18px; padding-bottom: 0; }
  :where([data-type="navbar"]):where(.has-menu) .session { border-top: 0; }
}
@media (min-width: 1024px) and (pointer: fine) {
  :where([data-type="navbar"]).navbar { padding: 14px 16px; }
  :where([data-type="navbar"]) .brand, :where([data-type="navbar"]) .nav-links a { min-height: 0; }
}
