:root {
  color-scheme: light;
  font-family: Arial, "Noto Sans Hebrew", system-ui, sans-serif;
  color: #1f1f1f;
  background: #f8fafd;
  --primary: #1a73e8;
  --primary-container: #e8f0fe;
  --on-primary: #ffffff;
  --surface: #ffffff;
  --surface-low: #f1f3f4;
  --surface-high: #e8eaed;
  --outline: #747a83;
  --outline-soft: #c5cad2;
  --muted: #5f6368;
  --error: #ba1a1a;
  --shadow: 0 10px 30px rgba(26, 49, 94, 0.11);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f8fafd; }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

/* Public pairing screen */
.pair-page { min-height: 100vh; }
.public-header { height: 76px; display: flex; align-items: center; justify-content: space-between; max-width: 1180px; margin: 0 auto; padding: 0 28px; }
.wordmark { display: inline-flex; align-items: center; gap: 11px; color: #1f1f1f; text-decoration: none; font-size: 20px; font-weight: 700; }
.wordmark-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; color: var(--on-primary); background: var(--primary); font-weight: 800; }
.public-actions { display: flex; align-items: center; gap: 24px; }
.public-actions a { color: var(--primary); text-decoration: none; font-size: 14px; font-weight: 700; }
.public-actions .download-link { padding: 10px 16px; border-radius: 999px; color: #fff; background: var(--primary); }
.pair-main { min-height: calc(100vh - 76px); display: grid; place-items: center; align-content: center; gap: 22px; padding: 42px 20px 64px; }
.pair-card { width: min(920px, 100%); display: grid; grid-template-columns: 1fr 330px; align-items: center; gap: 54px; padding: 48px; border: 1px solid #e0e5e2; border-radius: 30px; background: var(--surface); box-shadow: var(--shadow); }
.pair-copy { text-align: right; }
.pair-code-column { text-align: center; }
.step-label { display: inline-flex; padding: 7px 13px; border-radius: 999px; color: var(--primary); background: #e8f0fe; font-size: 14px; font-weight: 700; }
.pair-card h1 { margin: 22px 0 12px; font-size: clamp(34px, 4vw, 48px); line-height: 1.08; letter-spacing: -1px; }
.pair-intro { max-width: 460px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.65; }
.pair-steps { display: grid; gap: 18px; margin: 30px 0 0; padding: 0; list-style: none; }
.pair-steps li { display: flex; align-items: flex-start; gap: 13px; }
.pair-steps li > span { flex: 0 0 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; color: var(--primary); background: #e8f0fe; font-size: 13px; font-weight: 800; }
.pair-steps p { display: grid; gap: 4px; margin: 0; }
.pair-steps b { font-size: 15px; }
.pair-steps small { color: var(--muted); font-size: 13px; line-height: 1.45; }
.qr-shell { position: relative; width: 252px; height: 252px; margin: 0 auto 22px; padding: 14px; border: 1px solid var(--outline-soft); border-radius: 24px; background: #fff; }
.qr-shell img { width: 100%; height: 100%; display: block; }
.qr-placeholder { position: absolute; inset: 14px; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--muted); background: #fff; font-size: 14px; }
.progress-ring { width: 32px; height: 32px; border: 3px solid #d6dfda; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-row { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 28px; color: var(--primary); font-weight: 700; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #2e7d32; box-shadow: 0 0 0 5px rgba(46, 125, 50, 0.12); }
.status-row.error { color: var(--error); }
.status-row.error .status-dot { background: var(--error); box-shadow: 0 0 0 5px rgba(186, 26, 26, 0.12); }
.text-button { margin-top: 10px; padding: 10px 18px; border: 0; border-radius: 999px; color: var(--primary); background: transparent; cursor: pointer; font-weight: 700; }
.text-button:hover { background: #e8f0fe; }
.privacy-note { width: min(920px, 100%); display: flex; align-items: flex-start; justify-content: center; gap: 14px; padding: 0 10px; color: var(--muted); }
.privacy-note svg { flex: 0 0 24px; width: 24px; fill: var(--primary); }
.privacy-note div { display: grid; gap: 3px; line-height: 1.45; }
.privacy-note strong { color: #313834; }

/* Connected chat application */
.app-shell { height: 100vh; display: grid; grid-template-columns: 360px minmax(0, 1fr); direction: ltr; background: #f8fafd; }
.sidebar, .conversation { direction: rtl; }
.sidebar { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid #dfe5e1; background: var(--surface); }
.sidebar-header, .conversation-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid #dfe5e1; background: var(--surface); }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 14px; color: var(--primary); background: var(--primary-container); cursor: pointer; }
.icon-button:hover { filter: brightness(0.97); }
.icon-button svg, .send-button svg, .search-field svg { width: 24px; height: 24px; fill: currentColor; }
.search-field { margin: 14px 16px 8px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 18px; color: var(--muted); background: var(--surface-low); }
.search-field input { width: 100%; padding: 13px 0; border: 0; outline: 0; color: #1f1f1f; background: transparent; }
.chat-list { flex: 1; overflow: auto; padding: 6px 8px; }
.chat-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px; border: 0; border-radius: 16px; color: inherit; background: transparent; text-align: right; cursor: pointer; }
.chat-row:hover { background: var(--surface-low); }
.chat-row.active { background: #e8f0fe; }
.avatar { flex: 0 0 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; color: #fff; background: #5b76a7; font-weight: 700; }
.chat-copy { min-width: 0; flex: 1; }
.chat-top { display: flex; justify-content: space-between; gap: 12px; }
.chat-title { overflow: hidden; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.chat-time { direction: ltr; color: var(--muted); font-size: 12px; }
.chat-preview { display: block; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.connection-footer { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-top: 1px solid #dfe5e1; color: var(--muted); font-size: 13px; }
.conversation { min-width: 0; display: flex; flex-direction: column; background: #f5f7fb; }
.conversation-header h2 { margin: 0 0 4px; font-size: 19px; }
.conversation-header span { color: var(--muted); font-size: 13px; }
.generation-state { color: var(--primary) !important; font-weight: 600; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 12px; overflow: auto; padding: 30px clamp(24px, 7vw, 110px); }
.bubble { max-width: min(700px, 78%); padding: 12px 15px; border-radius: 18px; background: var(--surface); box-shadow: 0 2px 8px rgba(25, 49, 92, 0.07); line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.user { align-self: flex-start; border-bottom-left-radius: 6px; color: #174ea6; background: #dbe9ff; }
.bubble.assistant { align-self: flex-end; border-bottom-right-radius: 6px; }
.bubble time { display: block; margin-top: 5px; direction: ltr; color: var(--muted); font-size: 10px; text-align: left; }
.empty-state { margin: auto; padding: 28px; color: var(--muted); text-align: center; }
.empty-state h3 { margin: 0 0 8px; color: #2d3431; font-size: 22px; }
.empty-state p { margin: 0; }
.composer { display: flex; align-items: flex-end; gap: 12px; padding: 16px 22px; border-top: 1px solid #dfe5e1; background: var(--surface); }
.composer textarea { flex: 1; max-height: 132px; resize: none; padding: 14px 17px; border: 1px solid var(--outline-soft); border-radius: 20px; outline: 0; color: #1f1f1f; background: #f8fafd; }
.composer textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.send-button { flex: 0 0 50px; height: 50px; display: grid; place-items: center; border: 0; border-radius: 17px; color: var(--on-primary); background: var(--primary); cursor: pointer; transform: scaleX(-1); }
.send-button:disabled { cursor: default; opacity: 0.38; }
.status-dot.offline { background: var(--error); box-shadow: 0 0 0 5px rgba(186, 26, 26, 0.12); }
.status-dot.relay { background: #aa6b00; box-shadow: 0 0 0 5px rgba(170, 107, 0, 0.13); }

@media (max-width: 760px) {
  .public-header { padding: 0 18px; }
  .public-actions > a:first-child { display: none; }
  .public-actions .download-link { padding: 9px 12px; font-size: 12px; }
  .pair-card { grid-template-columns: 1fr; gap: 34px; padding: 30px 22px; border-radius: 24px; }
  .pair-copy { text-align: center; }
  .pair-intro { margin-inline: auto; }
  .pair-steps { max-width: 410px; margin-inline: auto; text-align: right; }
  .app-shell { grid-template-columns: 110px minmax(0, 1fr); }
  .sidebar-header { justify-content: center; gap: 8px; padding: 0 8px; }
  .sidebar-header .wordmark span:last-child, .search-field, .chat-copy, .connection-footer { display: none; }
  .chat-row { justify-content: center; }
  .messages { padding: 20px 14px; }
  .bubble { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; }
}
