:root {
  --pine: #12613b;
  --pine-dark: #0a3e27;
  --soft: #f4f8f5;
  --line: #d9e5de;
  --ink: #17231c;
  --muted: #5f6f66;
  --warning: #9b1c12;
  font-size: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

input[type="submit"],
button,
.call-link,
.secondary-button {
  min-height: 3.4rem;
  border: 0;
  border-radius: 0.9rem;
  padding: 0.9rem 1.25rem;
  background: var(--pine);
  color: white;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

input[type="submit"]:hover,
button:hover,
.call-link:hover {
  background: var(--pine-dark);
}

input,
textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 0.9rem;
  padding: 1rem;
  background: white;
  color: var(--ink);
}

input:focus,
textarea:focus,
button:focus,
a:focus {
  outline: 4px solid #f4c430;
  outline-offset: 3px;
}

.flash {
  width: min(980px, calc(100% - 2rem));
  margin: 1rem auto 0;
  border-radius: 0.9rem;
  padding: 1rem;
  font-weight: 800;
}

.flash.notice {
  background: #dff1e6;
  color: var(--pine-dark);
}

.flash.alert {
  background: #ffe8e4;
  color: var(--warning);
}

.page-shell {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0;
}

.home-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  gap: 1.5rem;
  align-items: center;
  min-height: 100vh;
}

.hero,
.dashboard-header {
  display: grid;
  gap: 1rem;
}

.hero h1,
.dashboard-header h1 {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 4rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.hero p,
.login-card p,
.dashboard-header p {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.5;
}

.badge,
.eyebrow,
.live-pill {
  margin: 0;
  color: var(--pine);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.4rem;
}

.brand-mark {
  width: 3.4rem;
  height: auto;
  display: block;
  flex: none;
}

.brand-name {
  color: var(--pine-dark);
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand--sm .brand-mark {
  width: 2.4rem;
}

.brand--sm .brand-name {
  font-size: 1.3rem;
}

.promise-list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 800;
}

.dev-hint {
  background: #fff4e0;
  color: #8a5a00;
  border-radius: 0.6rem;
  padding: 0.5rem 0.75rem;
  font-weight: 700;
}

.login-fallback {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #e2e8e4);
}

.login-fallback p {
  margin: 0 0 0.5rem;
  color: var(--muted);
}

.login-alt {
  margin: 0.5rem 0 0;
}

.login-alt a {
  color: var(--pine);
  font-weight: 800;
}

.promise-list li {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.promise-list li::before {
  content: "✓";
  display: inline-grid;
  width: 1.6rem;
  height: 1.6rem;
  place-items: center;
  border-radius: 999px;
  background: #dff1e6;
  color: var(--pine);
}

.card {
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: clamp(1.25rem, 4vw, 1.75rem);
  background: white;
  box-shadow: 0 12px 32px rgb(10 62 39 / 0.08);
}

.login-card,
.chat-card,
.stacked-form,
.chat-form {
  display: grid;
  gap: 1rem;
}

.login-card h2,
.chat-card h2 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.stacked-form label,
.chat-form label {
  font-weight: 900;
}

.code-form {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.dashboard-shell {
  display: grid;
  gap: 1rem;
}

.dashboard-header {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.secondary-button {
  background: white;
  color: var(--pine);
  border: 2px solid var(--pine);
}

.onboarding-shell {
  display: grid;
  gap: 1.5rem;
  align-content: start;
}

.onboarding-intro {
  display: grid;
  gap: 0.6rem;
  text-align: center;
  justify-items: center;
}

.onboarding-intro h1 {
  margin: 0;
}

.onboarding-intro p {
  max-width: 40rem;
  color: var(--muted);
}

.name-card {
  max-width: 40rem;
  width: 100%;
  margin: 0 auto;
}

.name-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.name-fields label {
  display: block;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

/* Single-plan onboarding: one centered card rather than a row. */
.plan-grid--single {
  grid-template-columns: minmax(0, 460px);
  justify-content: center;
}

.plan-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
}

.plan-card--featured {
  border: 2px solid var(--pine);
}

.plan-flag {
  position: absolute;
  top: -0.85rem;
  right: 1.25rem;
  margin: 0;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--pine);
  color: white;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.plan-card h2 {
  margin: 0;
}

.plan-price {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.plan-amount {
  color: var(--ink);
  font-size: 2rem;
  font-weight: 900;
}

.plan-tagline {
  margin: 0;
  color: var(--muted);
}

.plan-features {
  display: grid;
  gap: 0.5rem;
  margin: 0.25rem 0 0.5rem;
  padding: 0;
  list-style: none;
  font-weight: 700;
}

.plan-features li {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.plan-features li::before {
  content: "✓";
  color: var(--pine);
  font-weight: 900;
}

.plan-card button {
  width: 100%;
  margin-top: auto;
}

.plan-foot {
  margin: 0.75rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.onboarding-foot {
  text-align: center;
  color: var(--muted);
}

.chat-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.live-pill {
  border-radius: 999px;
  background: #dff1e6;
  padding: 0.4rem 0.75rem;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.quick-actions form,
.header-actions form {
  margin: 0;
}

.quick-actions input[type="submit"] {
  width: 100%;
  background: #eef6f1;
  color: var(--pine-dark);
  border: 1px solid var(--line);
}

.chat-window {
  display: grid;
  gap: 0.75rem;
  max-height: 28rem;
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #fbfdfc;
}

.chat-bubble {
  max-width: 78%;
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  line-height: 1.45;
}

.chat-bubble p {
  margin: 0.35rem 0 0;
  white-space: pre-wrap;
}

.chat-bubble.assistant {
  background: white;
  border: 1px solid var(--line);
}

.chat-bubble.user {
  justify-self: end;
  background: var(--pine);
  color: white;
}

/* Live-streamed reply: preserve line breaks, show a pulsing indicator while
   waiting for the first token, and a blinking caret as text arrives. */
.chat-bubble .message-content {
  white-space: pre-wrap;
}

.message-content.streaming {
  margin-top: 0.35rem;
}

.slot-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0 0.2rem;
}

.slot-button {
  width: auto;
  min-height: 2.8rem;
  padding: 0.55rem 1rem;
  background: white;
  color: var(--pine);
  border: 2px solid var(--pine);
  border-radius: 0.8rem;
  font-weight: 800;
}

.slot-button:hover {
  background: var(--pine);
  color: white;
}

.slot-button:disabled {
  opacity: 0.5;
}

.message-content.streaming::after {
  content: "▋";
  margin-left: 1px;
  color: var(--muted);
  animation: pinepulse 1s steps(2, start) infinite;
}

.message-content.typing {
  color: var(--muted);
  font-style: italic;
  animation: pinepulse 1.4s ease-in-out infinite;
}

/* while showing the "… is typing" label, hide the streaming caret */
.message-content.typing::after { content: none; }

@keyframes pinepulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

/* Attachments: photo/video preview and document chips in the conversation. */
.chat-media {
  display: block;
  max-width: min(100%, 22rem);
  max-height: 18rem;
  border-radius: 0.75rem;
  margin: 0.4rem 0;
}

.chat-file {
  display: inline-block;
  margin: 0.4rem 0;
  padding: 0.6rem 0.85rem;
  border-radius: 0.75rem;
  background: #eef6f1;
  color: var(--pine-dark);
  font-weight: 700;
  word-break: break-all;
}

a.chat-file {
  text-decoration: none;
}

/* Attach + microphone tools under the message box. */
.chat-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.6rem 0;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.8rem;
  padding: 0.5rem 0.95rem;
  border-radius: 0.9rem;
  border: 2px solid var(--line);
  background: white;
  color: var(--pine-dark);
  font-weight: 800;
  cursor: pointer;
}

.tool-button:hover {
  border-color: var(--pine);
}

.mic-button.listening {
  background: var(--pine);
  color: white;
  border-color: var(--pine);
  animation: pinepulse 1.2s ease-in-out infinite;
}

.attachment-name {
  color: var(--muted);
  font-weight: 700;
  word-break: break-all;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* "Your devices" panel: read-only view of the customer's own Level devices. */
.device-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.device {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--soft);
}

.device-dot {
  flex: none;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--muted);
}

.device-dot.is-online {
  background: #1f9d57;
  box-shadow: 0 0 0 3px rgba(31, 157, 87, 0.18);
}

.device-dot.is-offline {
  background: #c2ccc6;
}

.device-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1 1 auto;
  min-width: 0;
}

.device-name {
  font-weight: 800;
}

.device-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.device-status {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  text-align: right;
}

.device-restart {
  min-height: 2.4rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.95rem;
  flex: none;
}

/* Billing view */
.billing-shell {
  display: grid;
  gap: 1.5rem;
  align-content: start;
}

.billing-card {
  display: grid;
  gap: 0.5rem;
}

.billing-facts {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.billing-facts li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.billing-facts li:last-child {
  border-bottom: 0;
}

.billing-facts span {
  color: var(--muted);
  font-weight: 700;
}

.billing-status.status-active,
.billing-status.status-trialing {
  color: #1f9d57;
}

.billing-status.status-past_due,
.billing-status.status-canceled {
  color: var(--warning);
}

.billing-manage {
  margin-top: 0.75rem;
  width: 100%;
}

.billing-foot {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.charge-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.charge {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.charge:last-child {
  border-bottom: 0;
}

.charge-date {
  font-weight: 800;
  min-width: 8rem;
}

.charge-amount {
  font-weight: 800;
}

.charge-status {
  color: var(--muted);
  font-weight: 700;
}

.charge-link {
  margin-left: auto;
  color: var(--pine);
  font-weight: 800;
}

.cancel-button,
.cancel-button:hover {
  width: auto;
  min-height: auto;
  margin-top: 0.75rem;
  padding: 0.4rem 0;
  background: transparent;
  color: var(--warning);
  border: 0;
  font-weight: 800;
  text-decoration: underline;
}

.cancel-requested {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-weight: 700;
}

/* ---- Staff portal ---- */
.staff-topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--pine-dark);
  color: white;
}

.staff-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 800;
}

.staff-brand .brand-mark {
  width: 2rem;
}

.staff-nav {
  display: flex;
  gap: 1rem;
}

.staff-nav a {
  color: #cfe6d8;
  font-weight: 800;
  text-decoration: none;
}

.staff-nav a:hover {
  color: white;
}

.nav-badge {
  display: inline-block;
  background: var(--warning);
  color: white;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 900;
}

.staff-account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
}

.staff-signout {
  min-height: auto;
  padding: 0.4rem 0.8rem;
  background: transparent;
  border: 1px solid #3f6b54;
  border-radius: 0.6rem;
  width: auto;
}

.staff-main {
  width: min(960px, calc(100% - 2rem));
  margin: 1.5rem auto;
}

.staff-page {
  display: grid;
  gap: 1.25rem;
}

.staff-card h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
}

.staff-card .count {
  background: var(--pine);
  color: white;
  border-radius: 999px;
  font-size: 0.8rem;
  padding: 0.1rem 0.55rem;
}

.staff-attention {
  border: 2px solid var(--warning);
}

.staff-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.staff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  text-decoration: none;
  color: var(--ink);
}

a.staff-row:hover {
  border-color: var(--pine);
  background: var(--soft);
}

.staff-row--static {
  flex-wrap: wrap;
}

.staff-row-main {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.staff-row-name {
  font-weight: 800;
}

.staff-row-snippet {
  color: var(--muted);
}

.staff-row-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.staff-row-buttons {
  flex-wrap: wrap;
}

.status-badge {
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-ai { background: #eef2f0; color: var(--muted); }
.status-escalated { background: #fdecea; color: var(--warning); }
.status-human { background: #e3f3ea; color: var(--pine); }
.channel-sms { background: #e7eefc; color: #2b59c3; }
.channel-email { background: #efeafc; color: #6a40c3; }

/* Public monthly check-in play page */
.public-body { background: #f3f7f4; }
.public-header { padding: 1.5rem; text-align: center; }
.public-logo { height: 40px; }
.checkin-page { max-width: 640px; margin: 1rem auto 4rem; padding: 0 1.25rem; }
.checkin-card {
  background: #fff;
  border: 1px solid #e2e8e4;
  border-radius: 18px;
  padding: 2.25rem 2rem;
  box-shadow: 0 6px 24px rgba(31, 107, 67, 0.06);
}
.checkin-eyebrow { color: var(--muted); margin: 0 0 0.25rem; font-size: 1.05rem; }
.checkin-card h1 { margin: 0 0 0.25rem; font-size: 1.9rem; }
.checkin-from { color: var(--muted); margin: 0 0 1.5rem; font-size: 1.1rem; }
.checkin-player { margin: 1rem 0 1.75rem; }
.checkin-player audio { width: 100%; height: 48px; }
.checkin-transcript {
  font-size: 1.2rem;
  line-height: 1.7;
  color: #2a352f;
  background: #f7faf8;
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
}
.checkin-note { font-size: 1.1rem; color: var(--muted); }
.checkin-help { margin-top: 1.75rem; color: var(--muted); font-size: 1.05rem; }

.tier-badge {
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tier-safe { background: #eef2f0; color: var(--muted); }
.tier-standard { background: #e3f3ea; color: var(--pine); }
.tier-sensitive { background: #fdecea; color: var(--warning); }

.status-badge.run-pending { background: #fff4e0; color: #8a5a00; }
.status-badge.run-running { background: #e3f3ea; color: var(--pine); }
.status-badge.run-done { background: #e3f3ea; color: #1f9d57; }
.status-badge.run-failed { background: #fdecea; color: var(--warning); }
.status-badge.run-rejected { background: #eef2f0; color: var(--muted); }

.staff-empty {
  color: var(--muted);
}

.device-log {
  border: 1px solid var(--border, #e2e8e4);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  background: #fbfdfc;
}
.device-log > summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
}
.device-log > summary::-webkit-details-marker { display: none; }
.device-log > summary::before { content: "▸ "; color: var(--muted); }
.device-log[open] > summary::before { content: "▾ "; }
.device-log-meta { color: var(--muted); }
.device-log-body {
  margin: 0.6rem 0 0.2rem;
  padding: 0.75rem;
  background: #0f1f17;
  color: #d7e4dc;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.staff-conversation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.staff-back {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--pine);
  font-weight: 800;
  text-decoration: none;
}

.staff-sub {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.staff-link {
  color: var(--pine);
  font-weight: 800;
}

.staff-login {
  max-width: 28rem;
  margin: 3rem auto;
  display: grid;
  gap: 0.5rem;
}

.staff-actions {
  margin-top: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
}

.stat-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--pine-dark);
  line-height: 1.1;
}

.stat-note {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

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

.report-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.range-picker {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  overflow: hidden;
}

.range-option {
  padding: 0.45rem 0.8rem;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  border-left: 1px solid var(--line);
}

.range-option:first-child {
  border-left: 0;
}

.range-option.is-active {
  background: var(--pine);
  color: white;
}

.csv-button {
  width: auto;
  min-height: auto;
  padding: 0.5rem 0.9rem;
}

.trend-chart {
  width: 100%;
  height: 150px;
  display: block;
}

.trend-axis {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 0.3rem;
}

.trend-peak {
  color: var(--pine);
}

.report-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 820px) {
  .report-columns {
    grid-template-columns: 1fr;
  }
}

.restart-form {
  margin: 0;
}

.device-foot {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 820px) {
  .home-shell,
  .dashboard-header,
  .quick-actions,
  .plan-grid,
  .name-fields {
    grid-template-columns: 1fr;
  }

  .home-shell {
    min-height: auto;
  }

  .header-actions,
  .chat-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-bubble {
    max-width: 100%;
  }
}

.site-footer {
  margin: 0;
  padding: 2rem 1.5rem 2.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer a {
  color: var(--pine);
  font-weight: 800;
}

/* ============================================================
   Customer portal app shell (dashboard): sidebar + chat stage
   ============================================================ */
.app-shell {
  display: flex;
  height: 100vh;
  background: var(--soft);
}

/* The marketing footer is noise inside the app. */
body:has(.app-shell) .site-footer { display: none; }

.app-sidebar {
  width: 268px;
  flex: none;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem 1rem;
  background: #fff;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.app-brand { margin: 0 0.25rem; }

.side-nav { display: grid; gap: 0.25rem; }

.side-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.7rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.side-link:hover { background: var(--soft); }
.side-link.is-active { background: #e3f3ea; color: var(--pine-dark); }

.side-section { display: grid; gap: 0.45rem; }

.side-heading {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.side-devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }

.side-device {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
}

.side-device-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.side-device-name { font-weight: 800; font-size: 0.9rem; }
.side-device-meta { color: var(--muted); font-size: 0.78rem; }

.side-restart {
  width: auto; min-height: auto;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  background: #fff; color: var(--pine);
  border: 1px solid var(--pine); border-radius: 0.5rem;
}

.side-note { margin: 0; color: var(--muted); font-size: 0.78rem; }

.side-footer { margin-top: auto; display: grid; gap: 0.5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.side-account { margin: 0; display: grid; }
.side-account strong { font-weight: 900; }
.side-account span { color: var(--muted); font-size: 0.85rem; }
.side-signout { width: 100%; background: #fff; color: var(--pine); border: 2px solid var(--line); }
.side-signout:hover { border-color: var(--pine); background: #fff; }

.app-main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
}

.app-main .chat-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.app-main .chat-topbar h1 { margin: 0.1rem 0 0; font-size: 1.7rem; }

.app-main .quick-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.app-main .quick-button {
  width: auto; min-height: auto;
  padding: 0.5rem 0.95rem; font-size: 0.9rem;
  background: #eef6f1; color: var(--pine-dark);
  border: 1px solid var(--line); border-radius: 999px; font-weight: 800;
}
.app-main .quick-button:hover { background: #e3f3ea; }

.app-main .chat-window {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  scroll-behavior: smooth;
}

.app-main .chat-bubble { max-width: 80%; animation: bubble-in 0.18s ease-out; }
.app-main .chat-bubble.assistant { align-self: flex-start; }
.app-main .chat-bubble.user { align-self: flex-end; }
.bubble-head { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.3rem; }
.bubble-head strong { font-size: 0.78rem; opacity: 0.7; font-weight: 800; }
.avatar {
  width: 1.7rem; height: 1.7rem; flex: none;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  color: #fff; font-size: 0.78rem; font-weight: 900; line-height: 1;
}
.avatar-img { object-fit: cover; background: none; }
.chat-bubble.user .bubble-head { flex-direction: row-reverse; }
.chat-bubble.user .bubble-head strong { opacity: 0.85; }

.bubble-time {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.68rem;
  color: var(--muted);
  opacity: 0.8;
}
.chat-bubble.user .bubble-time { text-align: right; color: rgba(255, 255, 255, 0.75); }

.phone-field { margin-top: 1rem; }
.phone-field label { display: block; font-weight: 800; margin-bottom: 0.4rem; }

.verify-banner {
  background: #fff8e6;
  border: 1px solid #f0d98a;
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  display: grid;
  gap: 0.5rem;
}
.verify-banner p { margin: 0; }
.verify-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.verify-actions form { margin: 0; }
.verify-code-form { display: flex; gap: 0.5rem; }
.verify-code-form input[type="text"] { width: 9rem; min-height: 2.6rem; padding: 0.4rem 0.7rem; }
.verify-code-form input[type="submit"] { width: auto; min-height: 2.6rem; padding: 0.5rem 1rem; }
.verify-actions .secondary-button { min-height: 2.6rem; padding: 0.5rem 1rem; }

.day-sep {
  align-self: center;
  margin: 0.4rem 0;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: #eef2f0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@keyframes bubble-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* Composer */
.composer {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
}

.composer-input {
  width: 100%;
  border: 0;
  resize: none;
  min-height: 2.8rem;
  max-height: 10rem;
  padding: 0.5rem 0.35rem;
  font: inherit;
  background: transparent;
}
.composer-input:focus { outline: none; }

.composer-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.composer .chat-tools { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; flex: 1; margin: 0; }
.app-main .tool-button { min-height: 2.2rem; padding: 0.35rem 0.65rem; font-size: 0.82rem; border-radius: 0.6rem; }
.composer-send { width: auto; min-height: 2.6rem; padding: 0.5rem 1.5rem; margin-left: auto; }

@media (max-width: 820px) {
  .app-shell { flex-direction: column; height: auto; }
  .app-sidebar {
    width: auto; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.75rem;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .app-brand { margin-right: auto; }
  .side-nav { display: flex; }
  .side-section, .side-account { display: none; }
  .side-footer { margin: 0; border-top: 0; padding: 0; }
  .side-signout { width: auto; }
  .app-main { height: auto; min-height: 78vh; padding: 1rem; }
  .app-main .chat-window { min-height: 52vh; }
}
