* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0f1120;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.phone-frame {
  width: 375px;
  height: 812px;
  background: #f8f9fb;
  border-radius: 44px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
  position: relative;
  overflow: hidden;
}

.notch {
  width: 150px;
  height: 30px;
  background: #0f1120;
  border-radius: 0 0 20px 20px;
  margin: 0 auto;
  position: relative;
  z-index: 10;
}

/* SMS-style header */
.sms-header {
  background: #1a1d2e;
  color: white;
  padding: 8px 12px 10px;
  margin-top: -5px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.sms-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  opacity: 0.7;
  flex-shrink: 0;
}

.sms-contact {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.sms-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #528DFF;
  color: white;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sms-contact-info {
  min-width: 0;
}

.sms-contact-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.sms-contact-subtitle {
  font-size: 11px;
  opacity: 0.5;
  line-height: 1.2;
}

.chat-area {
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.chat-area > * + * {
  margin-top: 8px;
}

.message {
  display: block;
  max-width: 85%;
  clear: both;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.message.user {
  margin-left: auto;
  margin-right: 0;
}

.message.assistant {
  margin-left: 0;
  margin-right: auto;
}

.bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.message.user .bubble {
  background: #528DFF;
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  background: #e8eaef;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
  white-space: normal;
}
.message.assistant .bubble a { color: #2563eb; text-decoration: underline; }
.message.assistant .bubble table { border-collapse: collapse; margin: 8px 0; font-size: 13px; width: 100%; }
.message.assistant .bubble th, .message.assistant .bubble td { border: 1px solid #ccc; padding: 4px 8px; text-align: left; }
.message.assistant .bubble th { background: #d5dde8; font-weight: 600; }
.message.assistant .bubble code { background: #d5dde8; padding: 1px 4px; border-radius: 3px; font-size: 13px; }
.message.assistant .bubble pre { background: #d5dde8; padding: 8px; border-radius: 6px; overflow-x: auto; }
.message.assistant .bubble h1, .message.assistant .bubble h2, .message.assistant .bubble h3 { margin: 12px 0 6px; }
.message.assistant .bubble h1 { font-size: 16px; } .message.assistant .bubble h2 { font-size: 15px; } .message.assistant .bubble h3 { font-size: 14px; }
.message.assistant .bubble p { margin: 6px 0; }
.message.assistant .bubble ul, .message.assistant .bubble ol { margin: 6px 0; padding-left: 20px; }
.message.assistant .bubble blockquote { border-left: 3px solid #528DFF; margin: 8px 0; padding: 4px 12px; background: rgba(82,141,255,0.08); }

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.progress-indicator .progress-bubble {
  font-size: 13px;
  color: #666;
  font-style: italic;
  animation: pulse-opacity 2s ease-in-out infinite;
}

@keyframes pulse-opacity {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.plan-card {
  background: white;
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  border-left: 3px solid #528DFF;
  max-width: 85%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.plan-card .plan-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: #528DFF;
}

.plan-card .plan-step {
  padding: 3px 0;
  color: #555;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.plan-card .plan-step.active {
  color: #528DFF;
  font-weight: 500;
}

.plan-card .plan-step.done {
  color: #22c55e;
}

.plan-card .plan-step.done::before {
  content: "\2713 ";
}

.plan-card .plan-step.paused {
  color: #999;
  font-style: italic;
}

.plan-card .plan-step.paused::before {
  content: "\23F8 ";
}

.file-link {
  display: block;
  background: white;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: #528DFF;
  text-decoration: none;
  transition: background 0.2s;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 85%;
}

.file-link:hover {
  background: #eef3ff;
}

.file-link::before {
  content: "\1F4CE ";
}

.disambiguation-container {
  max-width: 85%;
}

.disambiguation-container > * + * {
  margin-top: 6px;
}

.disambiguation-btn {
  display: block;
  width: 100%;
  background: white;
  border: 1.5px solid #528DFF;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  color: #528DFF;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.disambiguation-btn:hover {
  background: #528DFF;
  color: white;
}

.input-bar {
  display: flex;
  padding: 10px 12px;
  gap: 8px;
  background: white;
  border-top: 1px solid #e5e5ea;
  align-items: center;
}

/* I-2 (2026-05-31): the prompt box is a <textarea id="messageInput"> (was a
   single-line <input type="text">) so long messages WRAP. Selector retargeted to
   the #messageInput id because the prior input[type="text"] attribute selector no
   longer matches a textarea. The added props are textarea-specific:
   - font-family:inherit — a bare textarea defaults to monospace; match the UI font.
   - resize:none — hide the manual drag-resize handle.
   - field-sizing:content — CSS-only auto-grow to fit wrapped lines (Chrome/Edge
     123+, Safari 17.4+). CONTRACT/FAILURE-MODE: on browsers without it the box
     stays one row and still wraps + scrolls vertically (never worse than the old
     non-wrapping input). max-height+overflow cap the growth then scroll. */
.input-bar #messageInput {
  flex: 1;
  min-width: 0;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  line-height: 1.3;
  resize: none;
  field-sizing: content;
  max-height: 96px;
  overflow-y: auto;
}

.input-bar #messageInput:focus {
  border-color: #528DFF;
}

.input-bar button#sendBtn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #528DFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.input-bar button#sendBtn:hover {
  background: #3d73e6;
}

.input-bar button#sendBtn:disabled {
  background: #999;
  cursor: not-allowed;
}

.input-bar .icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.input-bar .icon-btn:hover {
  background: #f0f0f0;
}

.upload-status {
  font-size: 12px;
  color: #666;
  padding: 4px 16px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.upload-status.success {
  color: #22c55e;
}

.upload-status.error {
  color: #ef4444;
}

/* Response groups — keep bubble + files + feedback together */
.response-group {
  display: block;
  max-width: 85%;
}

.response-group > * + * {
  margin-top: 6px;
}

.response-group .file-link {
  margin-left: 4px;
}

/* Feedback widget */
.feedback-widget {
  position: relative;
}

.feedback-toggle {
  background: none;
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.2s;
  padding: 0;
}

.feedback-toggle:hover {
  opacity: 1;
  background: #f0f0f0;
}

.feedback-panel {
  display: none;
  background: white;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 4px;
  font-size: 13px;
}

.feedback-panel.open {
  display: block;
}

.skill-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}

.skill-label {
  flex: 1;
  color: #555;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  opacity: 0.5;
  transition: opacity 0.2s, border-color 0.2s;
}

.thumb-btn:hover {
  opacity: 1;
}

.thumb-btn.selected {
  opacity: 1;
  border-color: #528DFF;
  background: #eef3ff;
}

/* Login overlay */
.login-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1d2e;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 44px;
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  width: 280px;
  text-align: center;
}

.login-title {
  font-size: 18px;
  font-weight: 600;
  color: white;
  margin-bottom: 24px;
}

.login-card input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: white;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
  transition: border-color 0.2s;
}

.login-card input::placeholder {
  color: rgba(255,255,255,0.4);
}

.login-card input:focus {
  border-color: #528DFF;
}

.login-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: #528DFF;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

.login-btn:hover {
  background: #3d73e6;
}

.login-error {
  color: #ef4444;
  font-size: 13px;
  margin-bottom: 10px;
  min-height: 18px;
}

.login-toggle {
  margin-top: 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}

.login-toggle a {
  color: #528DFF;
  text-decoration: none;
  margin-left: 4px;
}

.login-toggle a:hover {
  text-decoration: underline;
}

/* Suggestion buttons (onboarding + workflow) */
.suggestion-container {
  max-width: 92%;
  margin-top: 8px;
}

.suggestion-container > * + * {
  margin-top: 6px;
}

.suggestion-btn {
  display: block;
  width: 100%;
  background: white;
  border: 1.5px solid #528DFF;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 13px;
  color: #528DFF;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.suggestion-btn:hover {
  background: #528DFF;
  color: white;
}

.suggestion-desc {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

.suggestion-skip {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  color: #999;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s;
}

.suggestion-skip:hover {
  color: #666;
}

/* Workflow suggestion grid */
.workflow-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 92%;
  margin-top: 8px;
}

.workflow-btn {
  background: white;
  border: 1.5px solid #528DFF;
  border-radius: 14px;
  padding: 12px 10px;
  font-size: 12px;
  color: #528DFF;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-btn:hover {
  background: #528DFF;
  color: white;
}

/* Attachment indicator */
.attachment-indicator {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px;
  background: #f0f0f0;
  border-top: 1px solid #e5e5ea;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #528DFF;
  color: white;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-dismiss {
  background: none;
  border: none;
  color: white;
  font-size: 14px;
  cursor: pointer;
  padding: 0 0 0 2px;
  line-height: 1;
  opacity: 0.7;
}

.attachment-dismiss:hover {
  opacity: 1;
}

/* Plan confirmation buttons */
.plan-confirm-container {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  justify-content: center;
}
.plan-confirm-btn {
  padding: 8px 20px;
  border-radius: 18px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s;
}
.plan-confirm-btn:hover {
  opacity: 0.85;
}
.plan-confirm-btn.confirm {
  background: #007aff;
  color: white;
}
.plan-confirm-btn.cancel {
  background: #e5e5ea;
  color: #333;
}

/* C2 Authorization gate card — visually distinct from normal assistant messages */
.auth-gate-card {
  border: 2px solid #f59e0b;  /* Amber — signals irreversible action */
  background: #fffbeb;
  padding: 12px 14px;
}
.auth-gate-question {
  margin-bottom: 12px;
  font-size: 14px;
  color: #1c1c1e;
}
.auth-gate-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.auth-gate-approve {
  padding: 8px 18px;
  border-radius: 16px;
  border: none;
  background: #007aff;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.auth-gate-approve:hover:not(:disabled) { opacity: 0.85; }
.auth-gate-approve:disabled { opacity: 0.5; cursor: default; }
.auth-gate-deny {
  padding: 8px 18px;
  border-radius: 16px;
  border: none;
  background: #e5e5ea;
  color: #333;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}
.auth-gate-deny:hover:not(:disabled) { opacity: 0.85; }
.auth-gate-deny:disabled { opacity: 0.5; cursor: default; }

/* Step result expand/collapse */
.expand-result-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: #007aff;
  background: none;
  border: 1px solid #007aff;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.expand-result-btn:hover {
  background: rgba(0,122,255,0.08);
}
.full-result-text {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.04);
  border-left: 3px solid #007aff;
  border-radius: 4px;
  font-size: 13px;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.full-result-text.hidden {
  display: none;
}

/* Responsive: on mobile, fill screen */
@media (max-width: 420px) {
  .phone-frame {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
  .notch {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   Contacts screen (UI 2026-06-02)
   A mobile Messages-style contact list shown between login and the chat.
   Mirrors .login-overlay's absolute-fill + .hidden pattern (z-index 29 keeps
   it above the chat/header at z-index 10 but below the login overlay at 30, so
   if both were ever shown, login wins). Only the #contactShouldrs row is
   interactive (app.js openShouldrsChat); .is-disabled rows are non-tappable.
   --------------------------------------------------------------------------- */
.contacts-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #f8f9fb;            /* matches the chat-area light background */
  z-index: 29;
  border-radius: 44px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.contacts-overlay.hidden { display: none; }

.contacts-titlebar {
  background: #1a1d2e;            /* matches .sms-header dark bar */
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  padding: 46px 20px 14px;       /* top padding clears the notch */
  flex-shrink: 0;
}

.contacts-list {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid #ececec;
  cursor: pointer;                /* interactive (Shouldrs) row */
}
/* Non-interactive contacts: no pointer, slightly muted, no hover/active state */
.contact-row.is-disabled {
  cursor: default;
  opacity: 0.55;
}
.contact-row:not(.is-disabled):active {
  background: #eef3ff;            /* tap feedback, same accent tint as menu items */
}

.contact-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #528DFF;            /* accent blue — same as .sms-avatar */
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.contact-avatar-muted { background: #8e8e93; }  /* grey for non-interactive contacts */

.contact-meta { min-width: 0; }   /* allow the preview to ellipsize */
.contact-name {
  font-size: 16px;
  font-weight: 600;
  color: #111;
}
.contact-preview {
  font-size: 13px;
  color: #8a8a8e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
  margin-top: 1px;
}
