:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --paper: #f7f4ef;
  --paws: url("/assets/paws.svg");
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e2e8f0;
  --ok: #059669;
  --err: #be123c;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --chat-vv-height: 100dvh;
  --chat-vv-offset-top: 0px;
  /* Single-line composer control (padding + type + 1.5px border). */
  --composer-control-height: calc(0.58rem * 2 + 0.86rem * 1.15 + 3px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Invariant: [hidden] must win over display:flex field/overlay rules. */
[hidden] {
  display: none !important;
}

html {
  font-size: 18px;
}

/* Lock the document: html/body must not be a second scroller iOS can pan. */
html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--paws);
  background-repeat: repeat;
  background-size: 7.25rem;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
}

.layer-shell {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--chat-vv-offset-top);
  height: var(--chat-vv-height);
  width: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  background-image: var(--paws);
  background-repeat: repeat;
  background-size: 7.25rem;
  color: var(--ink);
}

.layer-shell__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: max(0.55rem, env(safe-area-inset-top)) 0.8rem 0.5rem 1rem;
  z-index: 6;
}

.layer-shell__title-stack {
  min-width: 0;
  flex: 1 1 auto;
}

.layer-shell__title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.layer-shell__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.live-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--ok);
  flex-shrink: 0;
}

.layer-shell__subtitle {
  margin: 0.12rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.2;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-shell__trailing {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.walk-abort {
  box-sizing: border-box;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink, #0f172a);
  font: 650 1.35rem/1 inherit;
  cursor: pointer;
}

.layer-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0.15rem;
  border-radius: 999px;
  background: #e8eef5;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.04);
  flex-shrink: 0;
}

.layer-switch button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--muted);
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 1.9rem;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.layer-switch button[aria-pressed="true"] {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.layer-switch button[aria-pressed="false"]:hover {
  color: var(--ink);
}

.layer-switch button:focus-visible {
  outline: 2px solid var(--ok);
  outline-offset: 1px;
}

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
}

.pane--chat,
.page-body {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  background-color: var(--paper);
  background-image: var(--paws);
  background-repeat: repeat;
  background-size: 7.25rem;
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.38s ease;
}

.layer-shell[data-layer="chat"] .page-body {
  transform: translateY(10%);
  opacity: 0;
  pointer-events: none;
}

.layer-shell[data-layer="story"] .pane--chat {
  transform: translateY(-8%);
  opacity: 0;
  pointer-events: none;
}

.pane--chat {
  padding: 0 1rem;
  overflow: hidden;
}

.pane--story {
  --perch-w: 4.4rem;
  --perch-h: 6rem;
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 0;
  top: auto;
  z-index: 8;
  display: flex;
  width: min(44rem, 100%);
  min-width: 0;
  height: auto;
  min-height: var(--perch-h);
  transform: translateX(-50%);
  flex: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 0;
  overflow: visible;
  padding: 0 1rem 0.4rem;
  background: transparent;
  pointer-events: none;
}

.agent-notice__bubble {
  position: relative;
  display: block;
  padding: 0.68rem 0.9rem 0.72rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 5px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.07);
}

.agent-notice__bubble::after {
  content: "";
  position: absolute;
  left: 1rem;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
  border-bottom-right-radius: 2px;
}

.bubble--agent.is-typing::after {
  content: "";
  display: inline-block;
  width: 0.08rem;
  height: 0.85em;
  margin-left: 0.12rem;
  background: currentColor;
  vertical-align: -0.08em;
}

.perch {
  display: block;
  position: absolute;
  left: -0.5rem;
  bottom: 0;
  z-index: 3;
  width: var(--perch-w);
  height: var(--perch-h);
  margin: 0;
  object-fit: contain;
  pointer-events: none;
  background-color: transparent;
  background-image: url("/assets/owl-perch.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: left bottom;
}

.perch[data-owl="rive"] {
  background-image: none;
}

.layer-shell[data-layer="story"] .pane--story > .perch {
  pointer-events: auto;
  cursor: pointer;
}

.page-body {
  /* Perch (~6rem) plus the dismissible hint sit in this band.
     Too small and Sida primary hides under #owl-notice. */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-top: 1rem;
  padding-bottom: 8.35rem;
}

.layer-shell[data-layer="story"] .page-body {
  padding-bottom: 10.2rem;
}

.page-place {
  display: block;
  flex-shrink: 0;
  width: 100%;
  max-width: 44rem;
  margin-inline: auto;
  padding: 0 1.15rem 0.35rem;
}

.layer-shell[data-place-kind="collect"] .page-place {
  display: none;
}

.page-place__kicker {
  margin: 0 0 0.28rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.owl-notice {
  display: none;
  position: absolute;
  left: 1.05rem;
  bottom: calc(var(--perch-h, 6rem) - 0.6rem);
  z-index: 9;
  max-width: min(17.5rem, calc(100% - 1.6rem));
  pointer-events: none;
}

.layer-shell[data-layer="story"] .owl-notice:not([hidden]) {
  display: block;
  pointer-events: auto;
}

.owl-notice__bubble {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.3rem;
  padding: 0.55rem 0.4rem 0.6rem 0.75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.owl-notice__text {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font: 500 0.82rem/1.35 var(--font);
  color: var(--ink);
}

.owl-notice__dismiss {
  appearance: none;
  flex: 0 0 auto;
  width: 1.55rem;
  height: 1.55rem;
  margin: -0.12rem 0 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 650 1.15rem/1 inherit;
  cursor: pointer;
}

.owl-notice__bubble::after {
  content: "";
  position: absolute;
  left: 1.45rem;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}

.talk {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 44rem;
  margin-inline: auto;
  padding: 0 0 6.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  overflow-anchor: none;
}

/* #model-miss is the first child and is usually hidden. */
.talk::before {
  content: "";
  flex: 1 0 0px;
}

.talk .agent-notice__bubble {
  align-self: stretch;
  max-width: none;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.talk .agent-notice__bubble:has(.symptom-report) {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.talk .agent-notice__bubble::after {
  content: none;
}

.talk .agent-notice__reading {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.talk .agent-notice__reading h1 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.talk .agent-notice__reading h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.talk .agent-notice__reading p,
.talk .agent-notice__reading .say,
.talk .agent-notice__reading .lede,
.talk .agent-notice__reading .hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  font-weight: 500;
}

.talk .agent-notice__reading .ref-label {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--ink);
}

.talk .agent-notice__reading .url-box {
  margin: 0;
}

.talk .agent-notice__reading .symptom-report {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0.85rem 0.95rem 0.1rem;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.talk .agent-notice__reading .symptom-report > h2 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.talk .agent-notice__reading .symptom-report .report-chief {
  margin: 0.1rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
}

.talk .agent-notice__reading .symptom-report .report-chief:empty {
  display: none;
}

.talk .agent-notice__reading .symptom-report .report-status {
  margin: 0 0 0.65rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: #f8fafc;
}

.talk .agent-notice__reading .symptom-report .report-status:has([data-urgency="Akut"]:not([hidden])) {
  background: #fff1f2;
}

.talk .agent-notice__reading .symptom-report .report-status:has([data-urgency="Kan vänta"]:not([hidden])) {
  background: #ecfdf5;
}

.talk .agent-notice__reading .symptom-report .report-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.talk .agent-notice__reading .symptom-report .report-status:has([data-urgency="Akut"]:not([hidden])) .report-kicker {
  color: var(--err);
}

.talk .agent-notice__reading .symptom-report .report-status:has([data-urgency="Kan vänta"]:not([hidden])) .report-kicker {
  color: var(--ok);
}

.talk .agent-notice__reading .symptom-report .report-status p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);
  font-weight: 500;
}

.talk .agent-notice__reading .symptom-report .report-block {
  padding: 0.6rem 0 0.65rem;
  border-top: 1px solid var(--border);
}

.talk .agent-notice__reading .symptom-report .report-block h3 {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}

.talk .agent-notice__reading .symptom-report .report-block p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  font-weight: 500;
}

.beat-host {
  min-width: 0;
}

.beat-host .field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0;
  border: 0;
}

.beat-host .field > label,
.beat-host .field > .label {
  display: block;
  font-size: 0.88rem;
  font-weight: 650;
  margin: 0;
}

.beat-host .field-row {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  min-width: 0;
}

.beat-host .field-row > input,
.beat-host .field-row > textarea {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.beat-host .field-row.field-write {
  display: block;
  position: relative;
}

.beat-host .field-row.field-write > textarea {
  width: 100%;
  flex: none;
  padding-right: 3.5rem;
}

.beat-host .field-row.field-write > .field-commit {
  position: absolute;
  right: 0.45rem;
  bottom: 0.45rem;
}

.beat-host .field > .field-commit {
  align-self: flex-end;
}

.beat-host .field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.beat-host .field-head > .label {
  min-width: 0;
}

.beat-host .field-commit {
  appearance: none;
  flex: 0 0 var(--composer-control-height);
  width: var(--composer-control-height);
  min-height: var(--composer-control-height);
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}

.beat-host .field-commit svg {
  display: block;
}

.beat-host .field input,
.beat-host .field textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.82rem 0.9rem;
  font: inherit;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
}

.beat-host .field textarea {
  min-height: 4.6rem;
  resize: none;
}

.beat-host .field input:focus-visible,
.beat-host .field textarea:focus-visible {
  border-color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.12);
}

.beat-host .field-error {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--err);
  line-height: 1.35;
}

.beat-host .field:has(.field-error:not([hidden])) input,
.beat-host .field:has(.field-error:not([hidden])) textarea {
  border-color: var(--err);
  background: #fff7f8;
}

.beat-host fieldset.chips,
.beat-host fieldset.kind {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

.beat-host .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.beat-host .chips.kind,
.beat-host .kind {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
}

.beat-host .chips.kind .chip,
.beat-host .kind .chip {
  flex: 1;
  text-align: center;
  border-radius: 14px;
  padding: 0.72rem 0.5rem;
}

.beat-host .chips.row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.beat-host .chips.row .chip {
  width: 100%;
  min-width: 0;
  justify-content: center;
  text-align: center;
  border-radius: 14px;
  padding: 0.55rem 0.3rem;
}

.beat-host .chips.row label.chip:has(.chip-caption) {
  align-items: center;
}

.beat-host .chips.row .chip {
  white-space: normal;
  line-height: 1.25;
}

.beat-host .chips.stack {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
}

.beat-host .chips.stack .chip,
.beat-host .chips.stack label.chip {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-radius: 14px;
  padding: 0.78rem 0.95rem;
}

.beat-host .chip {
  position: relative;
  appearance: none;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.beat-host label.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.beat-host label.chip:has(.chip-caption) {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  border-radius: 14px;
  padding: 0.45rem 0.8rem;
}

.beat-host .chip-caption {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
}

.beat-host label.chip:has(:checked) .chip-caption {
  color: #fff;
}

.beat-host .chip input[type="radio"],
.beat-host .chip input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.beat-host label.chip:has(:checked),
.beat-host .chip[data-on="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.beat-host .actions {
  margin-top: 0;
  padding-top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.beat-host .effect-status {
  margin: 0;
  color: var(--err);
  font-size: 0.86rem;
  line-height: 1.35;
}

.beat-host .actions-row {
  display: flex;
  justify-content: stretch;
  gap: 0.3rem;
}

.beat-host button.primary,
.beat-host button.ghost {
  appearance: none;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 14px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
}

.beat-host button.primary {
  color: #fff;
  background: var(--ink);
}

.beat-host button.ghost {
  color: var(--muted);
  background: transparent;
}

.bubble {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble--agent {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.bubble--user {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble--error {
  align-self: stretch;
  max-width: 100%;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: var(--err);
  border-radius: 12px;
  font-size: 0.85rem;
}

/* L3 model park / quiet system line — non-fatal, composer stays on. */
.bubble--system {
  align-self: center;
  max-width: 96%;
  background: #f7f7f7;
  border: 1px dashed var(--border);
  color: var(--muted);
  border-radius: 12px;
  font-size: 0.82rem;
  text-align: center;
}

/* Rails and receipts stretch; bubbles stay max-width 88%. */
.place-rail {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  padding: 0.45rem 0.1rem;
}

.place-rail__line {
  flex: 1 1 auto;
  height: 1px;
  background: #d5dde7;
}

.place-rail__label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1;
}

/* Receipt, not a card. Tick encodes by; no Du/Assistent badge; talk wins the column. */
.form-event {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  margin-block: -0.12rem;
  background: transparent;
  border: 0;
  border-left: 2px solid var(--ink);
}

.form-event.is-in {
  animation: form-event-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes form-event-in {
  from {
    opacity: 0;
    transform: translateX(-0.7rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.form-event[data-by="agent"] {
  border-left-color: var(--muted);
}

.form-event__hit {
  appearance: none;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  width: 100%;
  margin: 0;
  padding: 0.28rem 0.2rem 0.28rem 0.5rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.form-event__field {
  /* nowrap: wrapping the label collides with the value on the single-line row. */
  flex: 0 0 auto;
  min-width: 0;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.25;
}

.form-event__value {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 550;
  color: var(--ink);
  line-height: 1.3;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-event[data-by="agent"] .form-event__value {
  color: var(--muted);
}

.form-event__go {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  opacity: 0.4;
  padding: 0;
}

.form-event[data-by="agent"] .form-event__go {
  color: var(--muted);
}

.form-event[data-wrap] .form-event__hit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 0.4rem;
  row-gap: 0.12rem;
}

.form-event[data-wrap] .form-event__field {
  grid-column: 1;
  grid-row: 1;
}

.form-event[data-wrap] .form-event__go {
  grid-column: 2;
  grid-row: 1;
}

.form-event[data-wrap] .form-event__value {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-left: 0;
  text-align: left;
  font-weight: 500;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-overflow: unset;
}

.form-event[data-wrap]:not([data-open="true"]) .form-event__value {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  white-space: normal;
}

.form-event__more {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.08rem 0.2rem 0.28rem 0.5rem;
  border: 0;
  background: transparent;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

/* Composer is one compact row on the owl card. Refuse: display:contents on
   the form (that makes the textarea grow the pane and drops the send circle). */
.composer {
  position: relative;
  z-index: 2;
  display: block;
  flex: 0 0 auto;
  flex-shrink: 0;
  margin: 0;
  padding: 0 0 0.5rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  pointer-events: auto;
}

.composer-main {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--composer-control-height);
  grid-template-rows: auto;
  align-items: end;
  column-gap: 0.4rem;
  row-gap: 0.4rem;
  min-width: 0;
}

.dock-close {
  appearance: none;
  display: none;
  position: absolute;
  top: 0.28rem;
  right: 0.28rem;
  z-index: 2;
  width: 1.85rem;
  height: 1.85rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 650 1.35rem/1 inherit;
  cursor: pointer;
}

.dock-chip {
  appearance: none;
  flex: 0 0 auto;
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 650 0.75rem/1.2 var(--font);
  cursor: pointer;
}

.dock-chip__face {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 11rem;
  min-height: 1.85rem;
  padding: 0.22rem 0.45rem 0.22rem 0.6rem;
  border-radius: 999px;
  background: #e8eef5;
  color: var(--ink);
}

.dock-chip__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dock-chip__chev {
  flex: 0 0 auto;
  color: var(--muted);
  display: block;
}

/* The message field stays in layout. The beat sheet covers it. */
.layer-shell[data-layer="chat"] .composer-main {
  background: transparent;
  border: 0;
  min-height: 0;
  padding: 0 0.7rem 1rem 3.85rem;
}

.beat-sheet {
  /* Containing block is the composer padding box so the sheet is full
     clip width; the owl overlays the left. */
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 4.8rem;
  padding: 0.65rem 0.7rem 0.75rem 2.5rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
  pointer-events: auto;
}

.layer-shell[data-layer="chat"][data-dock="chat"] .beat-sheet,
.layer-shell.is-await-card .beat-sheet {
  display: none;
}

.layer-shell[data-layer="chat"][data-dock="ask"] .dock-close:not([hidden]) {
  display: grid;
  place-items: center;
  position: absolute;
  top: 0.28rem;
  right: 0.28rem;
  z-index: 3;
  width: 1.85rem;
  height: 1.85rem;
}

.composer textarea {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  width: 100%;
  resize: none;
  min-height: var(--composer-control-height);
  max-height: 7rem;
  margin: 0;
  border: 1.5px solid #d5dde7;
  border-radius: 999px;
  padding: 0.58rem 0.85rem;
  font: 500 16px/1.25 var(--font);
  color: var(--ink);
  background: #fff;
}

.composer textarea:focus {
  outline: none;
  border-color: #334155;
  box-shadow: 0 0 0 3px rgba(51, 65, 85, 0.12);
}

.composer textarea:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.composer textarea::placeholder {
  color: var(--faint);
  opacity: 1;
}

.composer #ask-beat textarea {
  border-radius: 12px;
  min-height: 4.6rem;
  padding: 0.7rem 0.85rem;
  resize: none;
}

.composer .composer__send {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  justify-self: end;
}

.layer-shell[data-layer="chat"] .dock-chip:not([hidden]) {
  position: absolute;
  left: 3.85rem;
  bottom: calc(100% + 0.35rem);
  z-index: 1;
  display: flex;
}

.layer-shell[data-layer="chat"][data-dock="ask"] #composer-input {
  display: block;
  pointer-events: none;
}

.layer-shell[data-layer="chat"][data-dock="ask"] .composer .composer__send {
  display: grid;
  pointer-events: none;
}

.layer-shell[data-layer="chat"][data-dock="ask"] #ask-beat {
  position: relative;
  z-index: 2;
  min-width: 0;
  min-height: 4.8rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.layer-shell[data-layer="chat"] .beat-sheet.is-sending {
  animation: beat-card-send 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

@keyframes beat-card-send {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(-1.75rem);
  }
}

.layer-shell[data-layer="chat"] .beat-sheet.is-building {
  animation: beat-card-build 0.46s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes beat-card-build {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.composer__send {
  appearance: none;
  flex: 0 0 var(--composer-control-height);
  width: var(--composer-control-height);
  min-height: var(--composer-control-height);
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.composer__send svg {
  display: block;
}

.composer__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.layer-shell[data-attach="true"] .composer-clip,
.layer-shell[data-attach="true"] .page-place,
.layer-shell[data-attach="true"] .perch,
.layer-shell[data-surface="static"] .layer-switch {
  display: none;
}
.layer-shell[data-surface="static"] .workspace {
  display: none;
}

.layer-shell[data-surface="static"] .overlay--place {
  position: relative;
  inset: auto;
  flex: 1 1 auto;
  min-height: 0;
  z-index: 5;
}

/* Iframe stays in #glass-host inside this clip; clip is content-sized. */
.form-clip {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  width: 100%;
  max-width: 44rem;
  margin-inline: auto;
  padding: 0 1.15rem 1.25rem;
  overflow: visible;
  opacity: 1;
  visibility: visible;
}

.composer-clip {
  display: block;
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  pointer-events: auto;
}

.composer-clip > * {
  min-height: 0;
  overflow: visible;
}

.layer-shell[data-layer="story"] .composer-clip {
  display: none;
}

.composer__send:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ── Story layer ── */
.story-slot {
  flex: 0 0 auto;
  min-height: 0;
  height: auto;
  overflow: visible;
}

/* In-flow form card. Never display:none (height 0 on Chat). */
.glass-host {
  position: relative;
  z-index: 3;
  width: 100%;
  overflow: hidden;
}

.layer-shell[data-layer="chat"] .glass-host {
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.layer-shell[data-layer="story"] .glass-host {
  overflow: visible;
}

.glass-stack {
  height: auto;
  width: 100%;
  overflow: visible;
  touch-action: pan-y;
}

.glass-stack__inner {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 0;
}

.story-panel__frame {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  min-height: 0;
}

/* Glass: iframe paints only. Hits go to .story-panel__hit (iOS sandbox). */
.story-panel__frame[data-glass="on"] {
  pointer-events: none;
  overflow: hidden;
  background: transparent;
}

.story-panel__hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  /* pan-y: overlay maps taps; #story-body is the Sida scroller. */
  touch-action: pan-y;
}

/* Snapshot toasts stick on the Sida panel, above #story-slot. */
.story-panel__notices {
  position: sticky;
  top: 0;
  z-index: 4;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: calc(100% - 1.5rem);
  max-width: 22.5rem;
  margin: 0.55rem auto 0;
  pointer-events: none;
}

.story-panel__notices .notice {
  pointer-events: auto;
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.58rem 0.3rem 0.58rem 0.8rem;
  border-radius: 14px;
  background: #fff;
  border: 1.5px solid var(--border);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}

.story-panel__notices .notice::before {
  content: "";
  flex: 0 0 0.28rem;
  border-radius: 999px;
  background: var(--ink);
}

.story-panel__notices .notice[data-tone="ok"]::before {
  background: var(--ok);
}

.story-panel__notices .notice[data-tone="err"]::before {
  background: var(--err);
}

.story-panel__notices .notice-copy {
  flex: 1 1 auto;
  margin: 0;
  min-width: 0;
}

.story-panel__notices .notice-close {
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  background: transparent;
  width: 2.1rem;
  height: 2.1rem;
  margin: -0.25rem 0;
  padding: 0;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.page-body[data-glass-pending="true"] {
  cursor: progress;
}

.glass-type {
  position: absolute;
  z-index: 5;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  min-height: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--ink);
  font-size: 16px;
  resize: none;
  overflow: hidden;
  outline: none;
  box-shadow: none;
}

/* ── Overlays: gate / login / fatal (slate chrome) ── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: max(1.25rem, env(safe-area-inset-top, 0px)) 1.1rem
    max(1.25rem, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}

.overlay--land {
  padding: max(2.1rem, env(safe-area-inset-top, 0px)) 1.25rem
    max(1.5rem, env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  min-height: 0;
}

.overlay--land h1,
.overlay--land .land__kicker,
.overlay--land .land__lede {
  flex-shrink: 0;
}

.overlay--land h1 {
  margin: 0.45rem 0 0;
  font-size: 1.85rem;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.035em;
}

.land__kicker {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.land__lede {
  margin: 0.7rem 0 0;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--muted);
  max-width: 22rem;
}

.land__body {
  margin-top: 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.land__figure {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.85rem 0;
}

.land__figure img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
}

.land__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-top: auto;
}

.sent-to {
  margin: 0.55rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.sent-to strong {
  color: var(--ink);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.sent-to .link {
  margin-left: 0.35rem;
}

.overlay__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.overlay__card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 650;
}

.overlay__card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.overlay__actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1rem;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 0.95rem 1.05rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--ink);
  color: #fff;
}

.btn--wide {
  width: 100%;
}

.btn--cta {
  min-width: 15.5rem;
}

.btn--secondary,
.btn--ghost {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--border);
}

.link {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.2rem 0;
  text-align: center;
  cursor: pointer;
}

.link:disabled,
.link[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.link--ink {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.phone-row {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.phone-cc {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 0.85rem;
  border-right: 1px solid var(--border);
  background: #f1f5f9;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.phone-num {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.88rem 0.9rem;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 550;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--ink);
}

.phone-num::placeholder {
  color: var(--faint);
  font-weight: 500;
}

.phone-num:focus {
  outline: none;
}

.otp {
  position: relative;
  display: flex;
  gap: 0.4rem;
  min-height: 3.6rem;
}

.otp__boxes {
  display: flex;
  gap: 0.4rem;
  width: 100%;
  pointer-events: none;
}

.otp__boxes span {
  flex: 1 1 0;
  aspect-ratio: 0.78;
  max-height: 3.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font-size: 1.35rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.otp__boxes span[data-on="true"] {
  border-color: var(--ink);
}

.otp__native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
  font: inherit;
  letter-spacing: 0;
}

.otp__native:focus {
  outline: none;
}

.overlay__error {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--err);
  line-height: 1.4;
  min-height: 1.2em;
}

.overlay__error:empty {
  display: none;
}

.overlay__hint {
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.85rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.4;
}

.overlay__hint:empty {
  display: none;
}

.overlay__hint p {
  margin: 0;
}

.overlay__hint p + p {
  margin-top: 0.45rem;
}

.overlay__hint .link {
  display: inline;
  padding: 0;
  font-size: inherit;
  font-weight: 650;
  text-align: inherit;
}

.chat-panel__body .overlay__hint {
  margin-top: 0;
}

.place-kicker {
  margin: 0 0 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.url-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.85rem 0 0;
}

.url-box {
  display: block;
  margin: 0;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink);
  overflow-wrap: anywhere;
  text-decoration: none;
}
a.url-box:hover {
  border-color: var(--ink);
}

.anon-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.anon-msg {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  padding: 0 0.15rem;
  text-align: center;
}

.composer-clip .composer {
  padding: 0 0 max(0.5rem, env(safe-area-inset-bottom, 0px));
}

html[data-still] .form-event.is-in,
html[data-still] .beat-sheet.is-sending,
html[data-still] .beat-sheet.is-building {
  animation: none;
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .pane--chat,
  .pane--story,
  .page-body,
  .form-clip {
    transition: none;
  }

  .form-event.is-in {
    animation: none;
  }

  .layer-shell[data-layer="chat"] .beat-sheet.is-sending,
  .layer-shell[data-layer="chat"] .beat-sheet.is-building {
    animation: none;
  }
}

