:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-elev: #1a1a1a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --text: #f5f5f0;
  --text-muted: rgba(245, 245, 240, 0.6);
  --text-faint: rgba(245, 245, 240, 0.35);
  --gold: #d4af37;
  --gold-soft: rgba(212, 175, 55, 0.14);
  --border: rgba(255, 255, 255, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

body { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ============== Login screen ============== */
.login {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.5rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.brand { text-align: center; margin-bottom: 1rem; }
.brand-mark {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 4.5rem;
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0;
  display: inline-block;
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 0.12em;
  height: 2px;
  background: var(--gold);
}
.brand-sub {
  margin: 0.85rem 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-muted);
}

label {
  display: block;
  font-size: 0.8rem;
  margin: 1.25rem 0 0.5rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

input[type=email], input[type=text] {
  width: 100%;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 1rem;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, background 0.15s;
}
input:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.06);
}

button {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}
button:active { transform: scale(0.98); }
button.primary { background: var(--text); color: var(--bg); margin-top: 1.25rem; }
button.secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
button:disabled { opacity: 0.4; cursor: not-allowed; }

.pill {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 500;
}
.pill-center { display: block; text-align: center; max-width: max-content; margin: 0 auto 1.25rem; }

.helper {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.8rem;
  margin-top: 1rem;
}

/* ============== Install onboarding modal ============== */
.install-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 8, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  padding-top: calc(var(--safe-top) + 1rem);
  padding-bottom: calc(var(--safe-bottom) + 1.25rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.install-header { text-align: center; margin-bottom: 1.5rem; }
.install-header .pill { margin-bottom: 0.75rem; }
.install-header h2 {
  margin: 0.5rem 0 0.5rem;
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}
.install-header p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.install-step {
  margin: 1rem 0;
  padding: 1.25rem;
  background: var(--bg-card);
  border-radius: 18px;
  border: 1px solid var(--border);
}
.install-step-head { display: flex; align-items: center; gap: 0.75rem; }
.install-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.install-step-title { font-weight: 500; font-size: 1.05rem; }
.install-step-detail {
  margin: 0.6rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.install-mock {
  margin: 0.85rem 0 0;
  background: #181818;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.install-mock svg { max-width: 100%; height: auto; }

.install-actions { margin-top: 1rem; }
.install-actions button + button { margin-top: 0.75rem; }

.install-tip {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.5;
}
.install-tip strong { color: var(--gold); font-weight: 600; }

/* ============== Auth flow extras ============== */
.screen-h2 {
  margin: 1.5rem 0 0.75rem;
  font-weight: 400;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}
.screen-p {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.error-msg {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(220, 60, 60, 0.12);
  border: 1px solid rgba(220, 60, 60, 0.3);
  border-radius: 12px;
  color: #ff9a9a;
  font-size: 0.9rem;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85em;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

.step-banner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 14px;
  margin: 1rem 0;
}
.check {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}
.check-large { width: 56px; height: 56px; font-size: 1.8rem; margin: 0 auto 1.25rem; }
.step-title { font-weight: 500; }
.step-sub { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.1rem; }

.warning-banner {
  padding: 1rem 1.15rem;
  background: rgba(220, 60, 60, 0.1);
  border: 1px solid rgba(220, 60, 60, 0.35);
  border-radius: 14px;
  margin: 1rem 0;
  color: var(--text);
  line-height: 1.5;
  font-size: 0.9rem;
}
.warning-banner strong { color: #ffb6b6; letter-spacing: 0.02em; }

.recovery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 1rem 0 1.25rem;
}
.recovery-code {
  position: relative;
  padding: 0.65rem 0.85rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-align: center;
}
.recovery-idx {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.65rem;
  color: var(--text-faint);
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
@media (max-width: 380px) {
  .recovery-grid { grid-template-columns: 1fr; }
}

.welcome-card {
  text-align: center;
  margin: 2rem 0;
  padding: 2rem 1rem;
}

/* ============== Chat ============== */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  padding-top: calc(var(--safe-top) + 0.85rem);
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.chat-brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-mark-sm {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  position: relative;
}
.brand-mark-sm::after {
  content: '';
  position: absolute;
  left: 8%; right: 8%; bottom: 0.05em;
  height: 1.5px;
  background: var(--gold);
}
.chat-tag {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}
.iconbtn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(212, 175, 55, 0.3);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.iconbtn:hover {
  color: #e8c659;
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.08);
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.25rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-stream::-webkit-scrollbar { width: 6px; }
.chat-stream::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.chat-empty {
  margin: auto;
  text-align: center;
  padding: 1rem;
  max-width: 420px;
}
.chat-empty-h {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 300;
  font-size: 2rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}
.chat-empty-p {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.bubble {
  display: flex;
  max-width: 100%;
}
.bubble-body {
  padding: 0.7rem 1rem;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  max-width: min(85%, 580px);
}
.bubble-user {
  justify-content: flex-end;
}
.bubble-user .bubble-body {
  background: var(--text);
  color: var(--bg);
  border-bottom-right-radius: 6px;
}
.bubble-assistant {
  justify-content: flex-start;
}
.bubble-assistant .bubble-body {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.bubble-error .bubble-body {
  background: rgba(220, 60, 60, 0.12);
  border: 1px solid rgba(220, 60, 60, 0.3);
  color: #ff9a9a;
  font-size: 0.85rem;
}

/* Markdown links + auto-linked URLs in chat bubbles. Subtle gold; underline
   on hover only, so dense paragraphs don't look cluttered. */
.bubble-body a {
  color: var(--gold, #d4af37);
  text-decoration: none;
  border-bottom: 1px dotted rgba(212, 175, 55, 0.4);
  word-break: break-word;
}
.bubble-body a:hover {
  color: #e8c659;
  border-bottom-color: var(--gold, #d4af37);
}
.bubble-body code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.86em;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.typing .bubble-body {
  padding: 0.85rem 1.1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.dot {
  width: 7px; height: 7px;
  background: var(--text-faint);
  border-radius: 50%;
  display: inline-block;
  animation: typing-bounce 1.4s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  padding-bottom: calc(var(--safe-bottom) + 0.75rem);
  border-top: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.chat-composer textarea {
  flex: 1;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 0.7rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  line-height: 1.4;
  -webkit-appearance: none;
  max-height: 220px;
  min-height: 44px;
}
.chat-composer textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.06);
}
.composer-send {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  border: none;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.composer-send:active { transform: scale(0.93); }
.composer-send:disabled { opacity: 0.35; cursor: not-allowed; }

.chat-actions { display: flex; align-items: center; gap: 0.6rem; }
.google-status {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile (portrait phones): stack the header into two rows so all 4 action
   buttons (+ ✓ ⚙ ⏻) fit without horizontal overflow. Row 1 is brand +
   tenant tag; row 2 is the action menu bar. The google-status badge sits
   on the action row, anchored left, with the buttons aligned right. */
@media (max-width: 600px) {
  .chat-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.75rem 1rem;
    padding-top: calc(var(--safe-top) + 0.75rem);
  }
  .chat-brand {
    justify-content: flex-start;
  }
  .chat-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 0.5rem;
  }
  .google-status {
    margin-right: auto;
    max-width: 50%;
  }
  /* Tighten the chat-tag if the tenant name is long so the brand row stays
     on one line. */
  .chat-tag {
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.connect-block {
  margin: 0.5rem auto 1.5rem;
  padding: 1.25rem 1.25rem 1.35rem;
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 16px;
  max-width: 580px;
  width: 100%;
}
.connect-h {
  font-weight: 500;
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
  color: var(--text);
}
.connect-p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 1rem;
}
.connect-block .primary {
  margin-top: 0;
  background: var(--gold);
  color: var(--bg);
}
.connect-fine {
  color: var(--text-faint);
  font-size: 0.75rem;
  margin: 0.75rem 0 0;
  line-height: 1.4;
}

/* ============== Attachments ============== */
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.composer-attach {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.composer-attach:active { transform: scale(0.93); }
.composer-attach:hover { color: var(--text); border-color: var(--text-muted); }

.staged-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0 0 0.55rem;
}
.staged-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem 0.4rem 0.7rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  max-width: 240px;
}
.staged-icon { font-size: 0.9rem; line-height: 1; }
.staged-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}
.staged-status { color: var(--text-muted); font-size: 0.7rem; }
.staged-status.err { color: #ff9a9a; }
.staged-x {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.staged-x:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.bubble-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  font-size: 0.8rem;
  max-width: 220px;
}
.bubble-user .att-chip {
  background: rgba(0,0,0,0.12);
  color: var(--bg);
}
.att-chip { cursor: pointer; }
.att-chip:hover { background: rgba(255,255,255,0.12); }

/* In-app attachment viewer modal. Full-screen on small screens, large
   centered card on desktop. Provides the close button + download link
   the chromeless PWA webview doesn't. */
.att-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}
.att-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  background: rgba(0, 0, 0, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: max(0.6rem, env(safe-area-inset-top));
}
.att-viewer-title {
  color: var(--text, #f5f5f0);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  max-width: 60vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.att-viewer-actions { display: flex; gap: 0.4rem; }
/* Strip iOS Safari's native button styling so width/height/border-radius
   are honored consistently. Without -webkit-appearance:none, iOS imposes
   its own minimum touch-target padding which makes one button rectangular
   and the other circular. box-sizing:border-box keeps the border inside
   the declared dimensions. */
.att-viewer-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  max-width: 40px;
  min-height: 40px;
  max-height: 40px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: var(--text, #f5f5f0);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 40px;
  line-height: 1;
}
.att-viewer-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}
.att-viewer-btn:hover { background: rgba(255, 255, 255, 0.16); }
.att-viewer-download { color: var(--gold, #d4af37); }
.att-viewer-download:hover { background: rgba(212, 175, 55, 0.16); }
.att-viewer-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.att-viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.att-viewer-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
}
.att-viewer-fallback {
  color: var(--text-muted, rgba(245,245,240,0.62));
  text-align: center;
  padding: 2rem 1.5rem;
}
.att-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}
.att-size { opacity: 0.6; font-size: 0.72rem; }

.chat-stream.dragover {
  background: rgba(212, 175, 55, 0.06);
  outline: 2px dashed rgba(212, 175, 55, 0.5);
  outline-offset: -8px;
}

/* ============== Settings view ============== */
.settings-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}
.settings-body {
  padding: 1.25rem 1.25rem calc(var(--safe-bottom) + 2rem);
  overflow-y: auto;
}
.settings-section {
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.settings-body label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 1rem 0 0.4rem;
  display: block;
}
.settings-body input[type=text],
.settings-body input[type=email],
.settings-body select,
.settings-body textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
}
.settings-body select { background-image: none; padding-right: 1rem; }
.settings-body input:focus, .settings-body textarea:focus, .settings-body select:focus {
  outline: none; border-color: var(--gold);
}
.settings-body input:disabled, .settings-body textarea:disabled, .settings-body select:disabled {
  opacity: 0.6; cursor: not-allowed;
}
.helper-small {
  color: var(--text-faint);
  font-size: 0.78rem;
  margin: 0.4rem 0 0;
  line-height: 1.4;
}
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 1rem;
  margin-top: 0.5rem;
}
.alias-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.alias-row input { flex: 1; min-width: 0; }
.alias-row button { white-space: nowrap; }

.push-status {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.92rem;
  margin: 0.5rem 0 0.4rem;
  line-height: 1.5;
}
.push-status-ok    { background: var(--gold-soft, rgba(212,175,55,0.14)); border: 1px solid rgba(212,175,55,0.3); }
.push-status-info  { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); }
.push-status-warn  { background: rgba(220,80,80,0.10); border: 1px solid rgba(220,80,80,0.30); }
.push-status-detail { color: var(--text-dim, rgba(245,245,240,0.62)); font-size: 0.86rem; margin-top: 0.2rem; }
@media (max-width: 480px) { .check-grid { grid-template-columns: 1fr; } }
.check-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0.5rem 0.7rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.check-cell input[type=checkbox] {
  accent-color: var(--gold);
  width: 16px; height: 16px;
}
#f-save { margin-top: 2rem; }
.settings-status {
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
}
.settings-status.ok { background: var(--gold-soft); color: var(--text); border: 1px solid rgba(212,175,55,0.3); }
.settings-status.err { background: rgba(220,60,60,0.12); color: #ff9a9a; border: 1px solid rgba(220,60,60,0.3); }

/* ============== Approval cards (trust framework) ============== */

.approval-card {
  margin-top: 0.85rem;
  padding: 0.8rem 0.95rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.025);
  font-size: 0.92rem;
}
.approval-card.tier-yellow { border-color: rgba(212,175,55,0.45); background: rgba(212,175,55,0.06); }
.approval-card.tier-red    { border-color: rgba(220,80,80,0.55); background: rgba(220,80,80,0.06); }
.approval-card.tier-green  { border-color: rgba(80,200,120,0.45); background: rgba(80,200,120,0.05); }

.approval-loading { color: var(--text-dim, #888); font-style: italic; }

.approval-header {
  display: flex; justify-content: space-between; gap: 0.5rem;
  font-size: 0.78rem; opacity: 0.85; margin-bottom: 0.4rem;
}
.approval-tier-pill {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.approval-byline {
  font-size: 0.82rem;
  font-style: italic;
  opacity: 0.62;
  margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
}
.approval-summary { margin-bottom: 0.15rem; }
.approval-recipient { font-size: 0.86rem; opacity: 0.75; margin-bottom: 0.5rem; }
.approval-from {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 0.5rem;
  padding: 0.5rem 0.7rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  font-size: 0.86rem;
}
.approval-from-text { opacity: 0.85; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.84rem; }
.approval-from-mode { opacity: 0.55; font-style: italic; font-family: inherit; }
.appr-from-toggle {
  background: transparent;
  border: 1px solid var(--gold, #d4af37);
  color: var(--gold, #d4af37);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.appr-from-toggle:hover { background: rgba(212,175,55,0.1); }
.appr-from-toggle:disabled { opacity: 0.5; cursor: not-allowed; }

.approval-body, .approval-reasoning {
  margin: 0.35rem 0;
  font-size: 0.85rem;
}
.approval-body pre, .approval-reasoning pre {
  margin: 0.4rem 0 0;
  padding: 0.55rem 0.7rem;
  background: rgba(0,0,0,0.25);
  border-radius: 7px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  line-height: 1.4;
}
.approval-body summary, .approval-reasoning summary {
  cursor: pointer;
  opacity: 0.8;
  user-select: none;
}

.approval-state {
  margin-top: 0.55rem;
  padding: 0.4rem 0.6rem;
  border-radius: 7px;
  font-size: 0.86rem;
}
.approval-state-done     { background: rgba(80,200,120,0.12); color: #a8e8b8; }
.approval-state-rejected { background: rgba(220,80,80,0.12);  color: #f5a8a8; }

.approval-buttons {
  margin-top: 0.7rem;
  display: flex; flex-wrap: wrap; gap: 0.45rem;
}
.appr-btn {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text, #eee);
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  font-size: 0.86rem;
  cursor: pointer;
}
.appr-btn:hover:not(:disabled) { background: rgba(255,255,255,0.08); }
.appr-btn:disabled { opacity: 0.55; cursor: default; }
.appr-approve { background: rgba(80,200,120,0.15); border-color: rgba(80,200,120,0.4); }
.appr-reject  { background: rgba(220,80,80,0.12);  border-color: rgba(220,80,80,0.35); }
.appr-pattern { font-size: 0.82rem; opacity: 0.92; }

.approval-reject-panel {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px dashed rgba(255,255,255,0.1);
}
.approval-reject-label { font-size: 0.82rem; opacity: 0.75; margin-bottom: 0.4rem; }
.approval-reject-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }
.reject-chip {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  color: var(--text, #eee);
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}
.reject-chip.selected { background: rgba(212,175,55,0.18); border-color: rgba(212,175,55,0.45); }
.approval-reject-note {
  display: block;
  width: 100%;
  margin: 0.4rem 0 0.55rem;
  padding: 0.4rem 0.55rem;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 2.2em;
}
.approval-reject-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }

.approval-error {
  color: #f5a8a8;
  font-size: 0.85rem;
}

/* ============== Auto-execute modal ============== */

.auto-exec-modal {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.auto-exec-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
}
.auto-exec-panel {
  position: relative;
  max-width: 640px;
  width: calc(100% - 2rem);
  max-height: 80vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg, #111);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 1rem 1.1rem;
}
.auto-exec-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.7rem;
}
.auto-exec-head h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.auto-exec-list { overflow-y: auto; padding-right: 0.2rem; }
.auto-exec-empty { opacity: 0.6; padding: 1rem 0.5rem; text-align: center; }
.auto-exec-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 0.8rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed rgba(255,255,255,0.07);
}
.auto-exec-when { grid-column: 1 / 3; font-size: 0.78rem; opacity: 0.55; }
.auto-exec-summary { font-size: 0.92rem; }
.auto-exec-icon { margin-right: 0.4rem; opacity: 0.85; }
.auto-exec-contact { opacity: 0.7; margin-left: 0.3rem; }
.auto-exec-actions { display: flex; align-items: center; }
.auto-exec-revert {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 7px;
  border: 1px solid rgba(220,80,80,0.4);
  background: rgba(220,80,80,0.1);
  color: var(--text);
  cursor: pointer;
}
.auto-exec-revert:hover:not(:disabled) { background: rgba(220,80,80,0.2); }
.auto-exec-revert.reverted { opacity: 0.5; cursor: default; }
.auto-exec-reverted { font-size: 0.8rem; opacity: 0.6; }
.auto-exec-note { font-size: 0.78rem; opacity: 0.7; margin-top: 0.3rem; }

/* Edit & approve panel — moat for diff capture */
.approval-edit-panel {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px dashed rgba(255,255,255,0.1);
}
.approval-edit-label {
  font-size: 0.82rem;
  opacity: 0.75;
  margin-bottom: 0.55rem;
}
.approval-edit-field {
  display: block;
  margin-bottom: 0.55rem;
}
.approval-edit-field span {
  display: block;
  font-size: 0.78rem;
  opacity: 0.75;
  margin-bottom: 0.25rem;
}
.approval-edit-field input,
.approval-edit-field textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  resize: vertical;
}
.approval-edit-field textarea {
  min-height: 6rem;
  line-height: 1.45;
}
.approval-edit-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}
.appr-edit-confirm { background: rgba(212,175,55,0.22); border-color: rgba(212,175,55,0.5); }

/* ============== Brand lockup (login / empty state) ============== */
.brand-lockup {
  display: block;
  margin: 0 auto;
  max-width: 420px;
  width: 85%;
  height: auto;
}
.chat-empty-lockup {
  display: block;
  margin: 0 auto 1.2rem;
  max-width: 220px;
  width: 55%;
  height: auto;
  opacity: 0.95;
}

/* ============== Static legal footer ============== */
/* Lives outside #app — always rendered, always visible to crawlers.
   Positioned fixed at the bottom so it doesn't fight with the auth/chat
   layout. Low-contrast so it doesn't pull focus from product chrome. */
.legal-footer {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--safe-bottom, 0px) + 0.5rem);
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: rgba(245, 245, 240, 0.32);
  pointer-events: none;
  z-index: 1;
}
.legal-footer a {
  color: rgba(245, 245, 240, 0.55);
  text-decoration: none;
  pointer-events: auto;
  padding: 0.25rem 0.4rem;
}
.legal-footer a:hover { color: var(--gold); }
.legal-footer span { padding: 0 0.15rem; }

/* Hide the footer once the user is inside the chat workspace — it'd compete
   with the composer. Privacy is still accessible via direct URL. */
body:has(.chat-shell) .legal-footer,
body:has(.install-modal:not([hidden])) .legal-footer { display: none; }

/* ============== Connected accounts (settings) ============== */
.conn-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 0.5rem;
}
.conn-info { flex: 1; min-width: 0; }
.conn-provider {
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}
.conn-gold { color: var(--gold); }
.conn-detail {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}
.conn-row button {
  width: auto;
  padding: 0.55rem 1rem;
  margin: 0;
  font-size: 0.88rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.conn-row button.secondary.danger {
  color: #f5a8a8;
  border-color: rgba(220, 80, 80, 0.35);
  background: rgba(220, 80, 80, 0.06);
}
.conn-row button.secondary.danger:hover:not(:disabled) {
  background: rgba(220, 80, 80, 0.15);
  border-color: rgba(220, 80, 80, 0.55);
}
@media (max-width: 540px) {
  .conn-row { flex-direction: column; align-items: stretch; gap: 0.7rem; }
  .conn-row button { width: 100%; }
}

/* ============== Multi-account connected list ============== */
.conn-row { margin-bottom: 0.55rem; }
.conn-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  align-items: center;
}
.conn-primary-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.12rem 0.5rem;
  background: var(--gold-soft);
  color: var(--gold);
  border-radius: 999px;
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  font-weight: 600;
  vertical-align: middle;
}
.conn-set-primary {
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem;
}
.conn-add {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
}
.conn-add:hover { color: var(--text); border-color: var(--text-muted); }
@media (max-width: 540px) {
  .conn-actions { width: 100%; }
  .conn-actions button { flex: 1; }
}

/* Provider section label for multi-provider connected accounts */
.conn-provider-section { margin-bottom: 1.25rem; }
.conn-provider-label {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 0.4rem;
}
