/* PhantomThread — style.css */

:root {
  --page-bg: #e5e5ea;
  --phone-bg: #fff;
  --phone-border: #1a1a1a;
  --phone-border-outer: #333;
  --status-bar-bg: transparent;
  --nav-bg: transparent;
  --messages-bg: #fff;
  --input-bar-bg: rgba(255,255,255,0.95);
  --received-bubble: #e9e9eb;
  --received-text: #000;
  --sent-bubble: #007aff;
  --sent-text: #fff;
  --text-primary: #000;
  --text-secondary: #8e8e93;
  --border-color: rgba(0,0,0,0.15);
  --input-border: #d1d1d6;
  --input-bg: #fff;
  --action-btn-bg: #e9e9eb;
  --action-btn-color: #8e8e93;
  --link-color: #007aff;
  --typing-dot: #8e8e93;
  --flash-color: rgba(0, 122, 255, 0.15);
  --icon-fill: #000;
  --dynamic-island-bg: #1a1a1a;
  --nav-circle-bg: rgba(0,0,0,0.06);
  --bar-bg: rgba(255,255,255,0.82);
  --bar-border: rgba(0,0,0,0.08);
  --panel-bg: rgba(255,255,255,0.85);
}

[data-theme="dark"] {
  --page-bg: #000;
  --phone-bg: #1c1c1e;
  --phone-border: #2c2c2e;
  --phone-border-outer: #1a1a1a;
  --status-bar-bg: transparent;
  --nav-bg: transparent;
  --messages-bg: #000;
  --input-bar-bg: rgba(28,28,30,0.95);
  --received-bubble: #26262a;
  --received-text: #fff;
  --sent-bubble: #0b84fe;
  --sent-text: #fff;
  --text-primary: #fff;
  --text-secondary: #98989f;
  --border-color: rgba(255,255,255,0.1);
  --input-border: rgba(255,255,255,0.16);
  --input-bg: rgba(44,44,46,0.6);
  --action-btn-bg: #3a3a3c;
  --action-btn-color: #98989f;
  --link-color: #0a84ff;
  --typing-dot: #636366;
  --flash-color: rgba(11, 132, 254, 0.15);
  --icon-fill: #fff;
  --dynamic-island-bg: #000;
  --nav-circle-bg: rgba(255,255,255,0.12);
  --bar-bg: rgba(15,15,17,0.82);
  --bar-border: rgba(255,255,255,0.09);
  --panel-bg: rgba(24,24,27,0.85);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: var(--page-bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background 0.3s;
}

/* App bar */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--bar-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}

.brand-accent { color: #4A9EF7; }

.brand-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--bar-border);
  border-radius: 20px;
  padding: 3px 9px;
  margin-left: 4px;
}

.app-bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--nav-circle-bg);
  color: var(--text-primary);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Buy me a coffee — quiet pill, bottom-left; warms up on hover */
.coffee-link {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 20px;
  background: var(--panel-bg);
  border: 1px solid var(--bar-border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  text-decoration: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}

.coffee-link:hover {
  opacity: 1;
  color: var(--text-primary);
  border-color: rgba(255, 221, 0, 0.55);
}

.coffee-emoji { font-size: 13px; }

/* Main content */
.app-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* About / FAQ section below the app */
.info-section {
  max-width: 680px;
  margin: 8px auto 40px;
  padding: 0 24px;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.65;
}

.info-section h2 {
  color: var(--text-primary);
  font-size: 19px;
  letter-spacing: -0.3px;
  margin: 34px 0 12px;
}

.info-section p { margin: 0 0 12px; }

.info-section details {
  border-bottom: 1px solid var(--bar-border);
  padding: 2px 0;
}

.info-section summary {
  cursor: pointer;
  padding: 10px 0;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  list-style-position: outside;
}

.info-section summary:hover { color: #4A9EF7; }

.info-section details p { padding: 0 0 12px 2px; margin: 0; }

.site-footer {
  text-align: center;
  padding: 20px 24px 28px;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.75;
}

.site-footer a { color: inherit; }

/* Phone wrapper — positions the PNG frame over the content */
.phone-wrapper {
  position: relative;
  width: 450px;
  height: 920px;
}

.phone-frame-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  pointer-events: none;
}

.phone-frame {
  position: absolute;
  top: 22px;
  left: 22px;
  right: 22px;
  bottom: 22px;
  background: var(--messages-bg);
  border-radius: 40px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.3s;
}

/* Status bar — height must push nav bar below the PNG's dynamic island */
.status-bar {
  height: 66px;
  background: transparent;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 20px 4px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.status-time {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Location arrow indicator */
.status-location {
  color: var(--text-primary);
  flex-shrink: 0;
}

.status-icons { display: flex; gap: 5px; align-items: center; color: var(--text-primary); }
.status-icons svg { width: 16px; height: 16px; fill: var(--icon-fill); }

/* Real iOS 26 chrome overlay — actual screenshot pixels with the dynamic
   regions (time, avatar, name, input interior) cleared so live content
   renders through. Toggled via .overlay-on on .phone-frame. */
/* Strips scale with width at natural aspect (height:auto) and pin to the
   viewport top/bottom — mobile heights vary, widths set the scale */
.chrome-overlay {
  position: absolute;
  left: 0;
  width: 100%;
  height: auto;
  z-index: 60;
  pointer-events: none;
  display: none;
}

.co-top { top: 0; }
.co-bottom { bottom: 0; }

/* Chat overlay on the chat screen, home overlay on the conversation list */
.phone-frame.overlay-on .chrome-overlay-chat { display: block; }
.phone-frame.overlay-on .screens.show-list ~ .chrome-overlay-chat { display: none; }
.phone-frame.overlay-on .screens.show-list ~ .chrome-overlay-home { display: block; }

/* Hide our recreated chrome where the screenshot provides it (click targets stay) */
.overlay-on .status-icons { visibility: hidden; }
.overlay-on .back-btn,
.overlay-on .video-btn { background: transparent; backdrop-filter: none; }
.overlay-on .back-btn svg,
.overlay-on .back-badge,
.overlay-on .video-btn svg { visibility: hidden; }
.overlay-on .input-action-btn { visibility: hidden; }
/* the whole input pill is cleared from the screenshot — ours renders */

/* Messages home under the overlay: screenshot provides header + search +
   compose; our rows show through the transparent body */
.overlay-on .list-header {
  visibility: hidden;
  min-height: 0;
  height: 0;
  padding: 0;
}
.overlay-on .list-search { display: none; }
.overlay-on .convo-list { padding-top: 112px; padding-bottom: 84px; }
/* invisible click target over the screenshot's bottom-right compose pencil */
.overlay-on .compose-btn {
  visibility: visible;
  opacity: 0;
  position: absolute;
  right: 18px;
  bottom: 22px;
  width: 56px;
  height: 56px;
}

/* Align live elements into the screenshot's cleared regions */
.overlay-on .status-bar { align-items: flex-start; padding-top: 19px; padding-left: 42px; }
.overlay-on .input-field-wrap { margin-left: 14px; margin-right: 12px; }

/* Screens: conversation list <-> chat with iOS push/pop slide */
.screens {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--messages-bg);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0.34, 1), background 0.3s;
}

.screen-list { transform: translateX(-28%); }
.screen-chat { transform: translateX(0); z-index: 2; box-shadow: -6px 0 24px rgba(0,0,0,0.25); }

.screens.show-list .screen-list { transform: translateX(0); }
.screens.show-list .screen-chat { transform: translateX(103%); }

/* Conversation list (Messages home) */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 4px;
  flex-shrink: 0;
}

.list-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--text-primary);
}

.compose-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--nav-circle-bg);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.compose-btn:active { transform: scale(0.94); }

.list-search {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 8px 16px 6px;
  padding: 8px 12px;
  border-radius: 18px;
  background: var(--nav-circle-bg);
  color: var(--text-secondary);
  font-size: 14px;
  flex-shrink: 0;
}

.convo-list {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 24px;
}

.convo-list::-webkit-scrollbar { display: none; }

.convo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 8px;
  cursor: pointer;
}

.convo-row:active { background: var(--nav-circle-bg); }

.convo-unread {
  width: 12px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.convo-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #0a84ff;
}

.convo-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8e8e93, #48484a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  margin: 8px 0;
}

.convo-body {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border-color);
}

.convo-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.convo-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-meta {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}

.convo-chevron { font-size: 14px; }

.convo-preview {
  font-size: 13px;
  line-height: 1.32;
  color: var(--text-secondary);
  margin-top: 1px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Nav bar — iOS 26 Messages: pill controls, large avatar, name pill below */
.nav-bar {
  background: transparent;
  padding: 4px 14px 12px;
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
  position: relative;
  min-height: 96px;
}

.nav-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 20px;
  background: var(--nav-circle-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.back-btn {
  color: var(--text-primary);
  text-decoration: none;
  z-index: 1;
  margin-top: 6px;
}

.back-btn svg { stroke: var(--text-primary); }

.back-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--messages-bg);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.contact-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.contact-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  font-weight: 600;
  margin-bottom: -8px;
  z-index: 1;
}

.contact-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--nav-circle-bg);
  padding: 5px 12px 5px 14px;
  border-radius: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: 220px;
}

.contact-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-name-chevron {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}

.video-btn {
  margin-left: auto;
  z-index: 1;
  margin-top: 6px;
}

.video-btn svg { stroke: var(--text-primary); fill: none; }

/* Messages area */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--messages-bg);
  scroll-behavior: smooth;
  transition: background 0.3s;
}

.messages-area::-webkit-scrollbar { display: none; }

.date-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  margin: 8px 0;
  letter-spacing: 0.2px;
}

.date-divider b { font-weight: 700; }

.bubble-row {
  display: flex;
  flex-direction: column;
  animation: bubbleIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bubble-row.no-animate {
  animation: none;
}

@keyframes bubbleIn {
  from { opacity: 0; transform: scale(0.85) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.bubble-row.sent { align-items: flex-end; }
.bubble-row.received { align-items: flex-start; }

.bubble {
  max-width: 72%;
  padding: 9px 14px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.35;
  word-wrap: break-word;
}

.bubble.sent {
  background: var(--sent-bubble);
  color: var(--sent-text);
  border-bottom-right-radius: 4px;
}

.bubble.received {
  background: var(--received-bubble);
  color: var(--received-text);
  border-bottom-left-radius: 4px;
}

.bubble-time {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
  padding: 0 4px;
}

/* Input bar — iOS 26: floating glass pill, + outside, waveform/send inside */
.input-bar {
  background: transparent;
  padding: 8px 14px 30px;
  display: flex;
  align-items: flex-end;
  gap: 9px;
  flex-shrink: 0;
}

.input-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--action-btn-bg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 300;
  flex-shrink: 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.input-field-wrap {
  position: relative;
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 22px;
  padding: 10px 40px 10px 15px;
  min-height: 40px;
  display: flex;
  align-items: center;
  font-size: 16px;
  transition: background 0.3s, border-color 0.3s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#inputField {
  flex: 1;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
  min-height: 20px;
  word-break: break-word;
  font-family: inherit;
}

#inputField:empty::before {
  content: attr(data-placeholder);
  color: var(--text-secondary);
}

.waveform-icon {
  position: absolute;
  right: 14px;
  bottom: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.send-btn {
  position: absolute;
  right: 5px;
  bottom: 4px;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: var(--sent-bubble);
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}

.send-btn:active { transform: scale(0.92); }

.input-field-wrap.has-text .send-btn { display: flex; }
.input-field-wrap.has-text .waveform-icon { display: none; }

.send-btn:active { transform: scale(0.9); }

/* Flash effect */
.sent-flash {
  animation: sentFlash 0.3s ease-out;
}
@keyframes sentFlash {
  0% { background: var(--flash-color); }
  100% { background: var(--messages-bg); }
}

/* Typing indicator */
.typing-indicator {
  display: none;
  align-items: flex-start;
  padding: 2px 0;
}

.typing-indicator.visible { display: flex; }

.typing-bubble {
  background: var(--received-bubble);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--typing-dot);
  border-radius: 50%;
  animation: typingDot 1.2s infinite;
}

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

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1); }
}

/* Control panel */
.control-panel {
  position: fixed;
  bottom: 32px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  width: 184px;
  padding: 14px;
  border-radius: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--bar-border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.22);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-primary);
  z-index: 999;
}

.panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  padding: 0 2px 2px;
}

.big-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s, background 0.15s;
  letter-spacing: 0.2px;
  -webkit-tap-highlight-color: transparent;
}

.big-btn:hover { filter: brightness(1.08); }
.big-btn:active { transform: scale(0.97); }

.btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-send { background: #007aff; color: white; }
.btn-receive { background: rgba(0,0,0,0.06); color: #1c1c1e; }
.btn-notif { background: rgba(0,0,0,0.06); color: #1c1c1e; }

[data-theme="dark"] .btn-receive { background: rgba(255,255,255,0.12); color: white; }
[data-theme="dark"] .btn-notif { background: rgba(255,255,255,0.12); color: white; }

.chrome-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 2px 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-primary);
  cursor: pointer;
}

.chrome-toggle input {
  margin: 0;
  accent-color: #007aff;
  cursor: pointer;
}

.auto-mode {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 2px 0;
  margin-top: 2px;
  border-top: 1px solid var(--bar-border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.auto-mode-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auto-mode-name {
  flex: 1;
  text-align: right;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.auto-mode.active .auto-mode-name { color: #007aff; }

.auto-mode input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: #007aff;
  cursor: pointer;
}

.auto-mode-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 8.5px;
  font-weight: 500;
  opacity: 0.45;
}

[data-theme="dark"] .auto-mode.active .auto-mode-name { color: #0a84ff; }

.keyboard-hint {
  font-size: 10px;
  opacity: 0.5;
  font-weight: 500;
  background: rgba(0,0,0,0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  margin-left: auto;
}

.big-btn .keyboard-hint { margin-left: auto; }
.auto-mode .keyboard-hint { margin-left: 0; }

[data-theme="dark"] .keyboard-hint {
  background: rgba(255,255,255,0.15);
}

/* Settings overlay */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
}

.settings-overlay.visible {
  display: flex;
}

.settings-panel {
  background: #1c1c1e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 24px;
  width: 420px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  color: white;
  font-family: -apple-system, sans-serif;
  max-height: 88vh;
  overflow-y: auto;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.settings-title {
  font-size: 17px;
  font-weight: 700;
}

.settings-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2c2c2e;
  border: none;
  border-radius: 50%;
  color: #8e8e93;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.settings-close:hover { color: white; background: #3a3a3c; }

.settings-section-label {
  font-size: 12px;
  color: #8e8e93;
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.label-note {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: #636366;
}

.settings-hint {
  font-size: 11px;
  color: #636366;
  text-align: center;
  line-height: 1.5;
  margin-top: 14px;
}

.settings-hint code { color: #ffe58a; }

/* Segmented control (tabs + editor mode toggle) */
.segmented {
  display: flex;
  gap: 3px;
  background: #2c2c2e;
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}

.segment {
  flex: 1;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #8e8e93;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segment.active { background: #48484a; color: white; }

/* Shared buttons */
.btn-primary {
  background: #007aff;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { background: #0a84ff; }

.btn-ghost {
  background: #2c2c2e;
  color: #aeaeb2;
  border: 1px solid #3a3a3c;
  border-radius: 10px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-ghost:hover { color: white; border-color: #636366; }

.btn-danger {
  background: none;
  border: none;
  color: #ff453a;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 10px 4px;
}

.btn-danger:hover { text-decoration: underline; }

/* Persona list */
.persona-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.persona-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #2c2c2e;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.persona-row:hover { background: #333336; }

.persona-row.active {
  border-color: #007aff;
  background: rgba(0, 122, 255, 0.12);
}

.persona-chip {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #8e8e93, #48484a);
  flex-shrink: 0;
}

.persona-row-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.persona-row-badge {
  font-size: 10px;
  font-weight: 600;
  color: #8e8e93;
  background: #3a3a3c;
  padding: 2px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}

.persona-edit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #8e8e93;
  cursor: pointer;
  padding: 7px;
  border-radius: 8px;
  flex-shrink: 0;
}

.persona-edit-btn:hover { color: white; background: #3a3a3c; }

.persona-actions { display: flex; gap: 8px; }
.persona-actions .btn-primary,
.persona-actions .btn-ghost { flex: 1; }

/* Persona editor */
.editor-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.btn-back {
  background: none;
  border: none;
  color: #0a84ff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px 4px 0;
}

.mode-toggle {
  display: flex;
  gap: 2px;
  background: #2c2c2e;
  border-radius: 9px;
  padding: 2px;
}

.mode-toggle .segment { flex: none; padding: 5px 14px; font-size: 12px; }

.editor-note {
  font-size: 11.5px;
  color: #8e8e93;
  background: #2c2c2e;
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 14px;
  line-height: 1.45;
}

.editor-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.editor-avatar-preview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.editor-identity-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.text-field {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 10px;
  background: #2c2c2e;
  border: 1px solid #3a3a3c;
  color: white;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.text-field:focus { border-color: #007aff; }
.text-field::placeholder { color: #636366; }

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}

.swatch.selected {
  border-color: white;
  box-shadow: 0 0 0 2px #007aff;
}

#replyRows {
  max-height: 240px;
  overflow-y: auto;
}

.reply-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.reply-remove {
  background: none;
  border: none;
  color: #636366;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  flex-shrink: 0;
}

.reply-remove:hover { color: #ff453a; }

.add-reply {
  width: 100%;
  margin-top: 2px;
  padding: 8px;
  border-style: dashed;
}

.json-area {
  width: 100%;
  box-sizing: border-box;
  min-height: 280px;
  resize: vertical;
  background: #111113;
  color: #d4d4d8;
  border: 1px solid #3a3a3c;
  border-radius: 12px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  outline: none;
}

.json-area:focus { border-color: #007aff; }

.editor-error {
  color: #ff453a;
  font-size: 12px;
  min-height: 16px;
  margin-top: 8px;
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.editor-footer-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Sound rows */
.sound-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #2c2c2e;
  border: 1.5px dashed #3a3a3c;
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.sound-row:hover { border-color: #636366; }

.sound-row-name {
  font-size: 13px;
  font-weight: 500;
}

.sound-row-name .label-note { font-size: 11px; }

.sound-row-status {
  font-size: 11.5px;
  color: #636366;
  text-align: right;
  max-width: 55%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ── Mobile: ghost sticker + popup nav ──────────────────────────────────── */
.ghost-sticker,
.panel-extras { display: none; }

/* ── Mobile full-screen mode ────────────────────────────────────────────────
   On phones the frame fills the viewport so it reads as the real app; all
   PhantomThread chrome hides behind the ghost sticker's popup nav. */
@media (max-width: 700px) {
  .app-bar,
  .phone-frame-img,
  .control-panel,
  .coffee-link,
  .info-section,
  .site-footer,
  .status-bar { display: none; }

  body { min-height: 100dvh; }

  .app-main { padding: 0; }

  .phone-wrapper {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }

  .phone-frame {
    inset: 0;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* The real phone provides the status bar — ours stays hidden, and the
     strips shift up to crop their baked status-bar/island rows (offsets are
     the crop line as a fraction of the strip's source width) */
  .overlay-on .co-top { top: calc(100vw * -0.135); }  /* crop line sits in the
     empty band below the status row/island in all four top strips */

  .settings-panel {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  /* Subtle outline ghost inside the input pill, where the unused mic icon
     sits — thumb-reach on a phone; fills brand blue while its popup is open.
     Rides with the pill when the keyboard opens. */
  .waveform-icon { display: none; }

  .ghost-sticker {
    display: flex;
    position: absolute;
    right: 8px;
    bottom: 6px;
    z-index: 5;
    width: 28px;
    height: 28px;
    padding: 3px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0.55;
    transition: opacity 0.15s, transform 0.1s;
  }

  .ghost-sticker:active { transform: scale(0.88); }

  /* typing swaps in the send button, same as the mic icon did */
  .input-field-wrap.has-text .ghost-sticker { display: none; }

  .ghost-sticker svg { width: 100%; height: 100%; overflow: visible; }

  .ghost-sticker svg path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linejoin: round;
  }

  .ghost-sticker svg ellipse { fill: currentColor; }

  body.mobile-nav-open .ghost-sticker {
    opacity: 1;
    color: #4A9EF7;
  }

  body.mobile-nav-open .ghost-sticker svg path {
    fill: #4A9EF7;
    stroke: none;
  }

  body.mobile-nav-open .ghost-sticker svg ellipse { fill: #fff; }

  /* The ghost sticker's popup IS the Simulator panel — same markup and
     styling as desktop, repositioned under the sticker */
  body.mobile-nav-open .control-panel {
    display: flex;
    position: fixed;
    top: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 232px;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 130px);
    overflow-y: auto;
    z-index: 1190;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  }

  /* keyboard hints and the desktop-only chrome toggle don't apply on touch */
  .control-panel .keyboard-hint,
  .control-panel .chrome-toggle { display: none; }

  .panel-extras {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--bar-border);
    padding-top: 10px;
    margin-top: 2px;
  }
}

.btn-extra {
  background: rgba(0,0,0,0.06);
  color: #1c1c1e;
  text-decoration: none;
}

[data-theme="dark"] .btn-extra { background: rgba(255,255,255,0.12); color: white; }

.btn-icon-emoji { width: 16px; text-align: center; font-size: 14px; }

/* ── Tapback reactions ──────────────────────────────────────────────────── */
.bubble { position: relative; }

.tapback {
  position: absolute;
  top: -13px;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  border: 2px solid var(--messages-bg);
  animation: tapbackIn 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.4);
}

@keyframes tapbackIn {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* your reaction on their bubble = blue badge, top-right */
.bubble.received .tapback { right: -8px; background: var(--sent-bubble); }
/* reaction on your own bubble = gray badge, top-left */
.bubble.sent .tapback { left: -8px; background: var(--received-bubble); }

/* rows need breathing room so badges don't clip against the row above */
.bubble-row:has(.tapback) { margin-top: 10px; }

#tapbackPicker {
  display: none;
  position: fixed;
  z-index: 1300;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 22px;
  background: var(--panel-bg);
  border: 1px solid var(--bar-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

#tapbackPicker.open {
  display: flex;
  animation: tapbackIn 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.3);
}

.tapback-option {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: none;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}

.tapback-option:hover {
  transform: scale(1.25);
  background: var(--nav-circle-bg);
}

/* ── Read receipts ──────────────────────────────────────────────────────── */
.receipt {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
  padding: 0 4px;
}

/* ── Platform skin: WhatsApp ────────────────────────────────────────────────
   data-platform="whatsapp" on <html> reskins the phone via variable
   overrides + structural tweaks. iMessage styles are the default. */
[data-platform="whatsapp"] {
  --messages-bg: #efeae2;
  --sent-bubble: #d9fdd3;
  --sent-text: #111b21;
  --received-bubble: #ffffff;
  --received-text: #111b21;
  --link-color: #00a884;
  --flash-color: rgba(0, 168, 132, 0.12);
  --typing-dot: #8696a0;
  --wa-header: #f0f2f5;
  --wa-accent: #00a884;
  --wa-ticks: #53bdeb;
  --input-bg: #ffffff;
  --input-border: transparent;
}

[data-theme="dark"][data-platform="whatsapp"] {
  --messages-bg: #0b141a;
  --sent-bubble: #005c4b;
  --sent-text: #e9edef;
  --received-bubble: #202c33;
  --received-text: #e9edef;
  --wa-header: #202c33;
  --input-bg: #2a3942;
  --input-border: transparent;
}

/* Chat header: horizontal WhatsApp layout instead of centered iOS stack */
[data-platform="whatsapp"] .nav-bar {
  background: var(--wa-header);
  min-height: 0;
  padding: 8px 12px;
  align-items: center;
  gap: 2px;
}

[data-platform="whatsapp"] .contact-info {
  position: static;
  transform: none;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

[data-platform="whatsapp"] .contact-avatar {
  width: 38px;
  height: 38px;
  font-size: 16px;
  margin-bottom: 0;
}

[data-platform="whatsapp"] .contact-name {
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
  border-radius: 0;
  font-size: 16px;
  font-weight: 600;
}

[data-platform="whatsapp"] .contact-name-chevron { display: none; }

[data-platform="whatsapp"] .nav-pill {
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

[data-platform="whatsapp"] .video-btn { color: var(--wa-accent); }

/* Bubbles: small radius, flat tail corner, soft shadow, inline ticks */
[data-platform="whatsapp"] .bubble {
  border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  font-size: 14.5px;
}

[data-platform="whatsapp"] .bubble.sent { border-top-right-radius: 0; }
[data-platform="whatsapp"] .bubble.received { border-top-left-radius: 0; }

[data-platform="whatsapp"] .bubble.sent::after {
  content: '✓✓';
  font-size: 10px;
  letter-spacing: -2px;
  color: var(--wa-ticks);
  margin-left: 7px;
  vertical-align: bottom;
}

/* iMessage-only affordances off */
[data-platform="whatsapp"] .receipt { display: none; }
[data-platform="whatsapp"] .chrome-overlay { display: none !important; }
[data-platform="whatsapp"] .lg-row { display: none; }

/* Date divider becomes a floating chip */
[data-platform="whatsapp"] .date-divider {
  align-self: center;
  background: var(--received-bubble);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* Input bar */
[data-platform="whatsapp"] .input-field-wrap {
  border-radius: 24px;
  border: none;
}

[data-platform="whatsapp"] .waveform-icon { display: none; }

[data-platform="whatsapp"] .send-btn { background: var(--wa-accent); }

/* Conversation list accents */
[data-platform="whatsapp"] .convo-dot { background: var(--wa-accent); }

/* Simulator panel platform toggle — theme-aware (base .segmented is tuned
   for the dark settings panel) */
.platform-toggle {
  margin-bottom: 10px;
  background: var(--nav-circle-bg);
}

.platform-toggle .segment { color: var(--text-secondary); font-size: 12px; padding: 6px 8px; }

.platform-toggle .segment.active {
  background: var(--panel-bg);
  color: var(--text-primary);
}

.btn-export { background: rgba(0,0,0,0.06); color: #1c1c1e; }
[data-theme="dark"] .btn-export { background: rgba(255,255,255,0.12); color: white; }

/* iOS Safari auto-zooms any focused text control under 16px — keep every
   focusable at 16px on touch devices (applies beyond the mobile breakpoint
   too: iPads and landscape phones get the desktop layout) */
@media (pointer: coarse) {
  #inputField,
  .text-field,
  .reply-input,
  .json-area { font-size: 16px; }
}

/* Ghost sticker lives on the chat thread only — hide it on the
   conversation-list screen (JS also closes the popup) */
body.on-list .ghost-sticker { display: none; }



/* Edit button in the list header — opens the persona list in settings */
.list-edit-btn {
  border: none;
  background: var(--nav-circle-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 18px;
  cursor: pointer;
}

/* under the overlay: invisible click target over the screenshot's Edit pill */
.overlay-on .list-edit-btn {
  visibility: visible;
  opacity: 0;
  position: absolute;
  left: 12px;
  top: 0;
  width: 72px;
  height: 42px;
  padding: 0;
}

.time-toggle { margin-bottom: 0; width: 190px; }
.time-toggle .segment { padding: 5px 8px; font-size: 12px; }

/* Display tab — iOS-style setting rows */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border-radius: 12px;
  background: #2c2c2e;
  margin-bottom: 8px;
}

.setting-row-title {
  font-size: 13.5px;
  font-weight: 600;
  color: white;
}

.setting-row-sub {
  font-size: 11.5px;
  color: #8e8e93;
  margin-top: 2px;
}

/* iOS-style switch */
.ios-switch {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}

.ios-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ios-switch-track {
  display: block;
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: #39393d;
  position: relative;
  transition: background 0.2s;
}

.ios-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: left 0.2s;
}

.ios-switch input:checked + .ios-switch-track { background: #34c759; }
.ios-switch input:checked + .ios-switch-track::after { left: 20px; }

.time-toggle { margin-bottom: 0; width: 176px; flex-shrink: 0; }

