:root {
  --bg-dark: #f0f2f5;
  --bg-panel: #ffffff;
  --bg-chat: #efeae2;
  --bg-bubble-out: #d9fdd3;
  --bg-bubble-in: #ffffff;
  --accent: #008069;
  --accent-dim: #006b58;
  --text-primary: #111b21;
  --text-secondary: #54656f;
  --text-muted: #8696a0;
  --text-meta: #667781;
  --border: #e9edef;
  --danger: #ea4335;
  --read-blue: #027eb5;
  --shadow: rgba(11, 20, 26, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg-panel);
  box-shadow: 0 0 24px var(--shadow);
}

.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  position: absolute;
  inset: 0;
  background: var(--bg-panel);
}

.screen.active { display: flex; }

/* Auth */
.auth-header {
  text-align: center;
  padding: calc(48px + var(--safe-top)) 24px 32px;
}

.logo {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 12px;
}

.auth-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

.auth-tabs {
  display: flex;
  margin: 0 24px 16px;
  background: var(--bg-dark);
  border-radius: 12px;
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 0 24px;
}

.auth-form.active { display: flex; }

.password-wrap {
  position: relative;
  width: 100%;
}

.password-wrap input {
  width: 100%;
  padding-right: 72px;
}

.toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 10px;
  cursor: pointer;
}

.auth-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: -4px;
  line-height: 1.4;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

input:focus { border-color: var(--accent); }

.btn-primary {
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

.btn-primary:active { background: var(--accent-dim); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
}

.btn-secondary:active {
  background: var(--bg-dark);
}

.btn-danger {
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid var(--danger);
  cursor: pointer;
  margin-top: 24px;
}

.error-msg {
  color: var(--danger);
  text-align: center;
  padding: 12px 24px;
  font-size: 0.85rem;
}

.btn-link {
  margin-top: 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

/* App lock overlay */
.app-lock {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-lock.hidden { display: none !important; }

.lock-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.lock-card .logo {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 8px;
}

.lock-card h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.lock-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.lock-user-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 16px;
}

.lock-pending {
  background: rgba(0, 128, 105, 0.12);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.lock-card .password-wrap {
  margin-bottom: 12px;
}

.lock-card .btn-primary {
  width: 100%;
}

.lock-logout-btn {
  width: 100%;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: transparent;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-biometric {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: rgba(0, 128, 105, 0.08);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-biometric:active {
  background: rgba(0, 128, 105, 0.16);
}

.lock-bio-divider {
  color: var(--text-meta);
  font-size: 0.78rem;
  margin: 4px 0 14px;
}

.hidden { display: none !important; }

/* Header */
.app-header, .chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}

.chat-header { gap: 12px; }

.header-left { display: flex; flex-direction: column; gap: 2px; }

.app-header h2, .chat-header h2 { font-size: 1.1rem; font-weight: 600; }

.user-id-badge {
  font-size: 0.75rem;
  color: var(--accent);
  font-family: monospace;
}

.logout-btn {
  padding: 6px 14px;
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-only-list {
  flex: 1;
  overflow-y: auto;
  max-height: none;
  border-bottom: none;
}

.chat-header {
  gap: 8px;
  align-items: flex-start;
}

.chat-header .chat-peer-info {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
  padding-right: 4px;
}

.chat-header .icon-btn,
.chat-header .chat-peer-avatar,
.chat-header .chat-end-session-btn {
  align-self: center;
}

.chat-end-session-btn {
  white-space: nowrap;
  margin-left: auto;
}

.peer-status {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: block;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.35;
  margin-top: 2px;
  word-break: break-word;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
}

/* Search */
.search-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-panel);
}

.search-bar input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 24px;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

.search-results {
  max-height: 200px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.search-result-item:active { background: var(--bg-dark); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-sm {
  width: 36px;
  height: 36px;
  font-size: 0.85rem;
}

.avatar-large {
  width: 96px;
  height: 96px;
  font-size: 2rem;
  margin: 0 auto 8px;
}

.avatar .avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-has-photo {
  background: var(--bg-dark);
  padding: 0;
}

.chat-peer-avatar {
  flex-shrink: 0;
}

.header-left-profile {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.my-profile-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  line-height: 0;
}

.profile-header-title {
  flex: 1;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
}

.header-spacer {
  width: 40px;
  flex-shrink: 0;
}

.result-info { flex: 1; min-width: 0; }
.result-name { font-weight: 500; font-size: 0.95rem; }
.result-id { font-size: 0.75rem; color: var(--text-secondary); font-family: monospace; }
.result-status { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.info-banner {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(0, 128, 105, 0.08);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.info-icon { color: var(--accent); flex-shrink: 0; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.section-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.users-list {
  max-height: 45vh;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
}

.user-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.user-list-item:active { background: var(--bg-dark); }

.user-list-meta { flex: 1; min-width: 0; }

.user-list-name {
  font-weight: 500;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-list-id {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 2px;
}

.presence-line {
  font-size: 0.78rem;
  margin-top: 3px;
}

.presence-line.online {
  color: #25d366;
  font-weight: 500;
}

.presence-line.offline {
  color: var(--text-secondary);
}

.user-status-msg {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding-bottom: var(--safe-bottom);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 24px;
  font-size: 0.9rem;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.chat-list-item:active { background: var(--bg-dark); }

.chat-list-meta { flex: 1; min-width: 0; }
.chat-list-name { font-weight: 500; }
.chat-list-sub { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }

.unread-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

/* Chat */
.chat-peer-info { flex: 1; min-width: 0; }

.peer-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#peer-name { font-weight: 600; font-size: 1rem; }

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #25d366;
  flex-shrink: 0;
}

.peer-status {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: block;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.35;
  margin-top: 2px;
  word-break: break-word;
}

.read-notice {
  padding: 8px 16px;
  background: rgba(2, 126, 181, 0.08);
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--read-blue);
  line-height: 1.4;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  background: var(--bg-chat);
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1c9bf' fill-opacity='0.35'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-date-separator {
  display: flex;
  justify-content: center;
  margin: 10px 0 6px;
}

.message-date-separator span {
  background: rgba(225, 245, 254, 0.95);
  color: var(--text-meta);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 1px var(--shadow);
}

.message-bubble {
  max-width: 82%;
  padding: 8px 10px 6px;
  border-radius: 8px;
  position: relative;
  animation: fadeIn 0.2s ease;
}

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

.message-bubble.outgoing {
  align-self: flex-end;
  background: var(--bg-bubble-out);
  border-top-right-radius: 0;
  box-shadow: 0 1px 2px var(--shadow);
}

.message-bubble.incoming {
  align-self: flex-start;
  background: var(--bg-bubble-in);
  border-top-left-radius: 0;
  box-shadow: 0 1px 2px var(--shadow);
}

.message-bubble.removing {
  animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
  to { opacity: 0; transform: scale(0.9); max-height: 0; padding: 0; margin: 0; }
}

.message-text { font-size: 0.92rem; line-height: 1.4; word-break: break-word; }
.message-text strong { font-weight: 700; }
.message-text em { font-style: italic; }

.message-image {
  max-width: 100%;
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  display: block;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.message-time { font-size: 0.68rem; color: var(--text-meta); }

.message-time.server-time { font-style: normal; }

.read-receipt {
  font-size: 0.68rem;
  color: var(--text-meta);
}

.read-receipt.seen { color: var(--read-blue); }

.read-receipt-detail {
  font-size: 0.65rem;
  color: var(--read-blue);
  margin-top: 2px;
  text-align: right;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  align-self: flex-start;
  background: var(--bg-bubble-in);
  border-radius: 8px;
  border-top-left-radius: 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}

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

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.read-status-bar {
  padding: 8px 16px;
  background: rgba(2, 126, 181, 0.1);
  border-top: 1px solid var(--border);
  text-align: center;
}

#read-status-text {
  font-size: 0.78rem;
  color: var(--read-blue);
  font-weight: 500;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}

.format-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.format-btn:active,
.format-btn:hover {
  background: var(--bg-dark);
}

.format-btn.active {
  background: var(--accent);
  color: #fff;
}

.format-btn.active strong,
.format-btn.active em {
  color: #fff;
}

.format-italic em {
  font-style: italic;
  font-weight: 600;
}

.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  max-height: 160px;
  overflow-y: auto;
}

.emoji-panel.hidden {
  display: none;
}

.emoji-item {
  border: none;
  background: transparent;
  font-size: 1.35rem;
  padding: 6px 2px;
  cursor: pointer;
  border-radius: 8px;
  line-height: 1.2;
}

.emoji-item:hover,
.emoji-item:active {
  background: var(--bg-dark);
}

.attach-wrap {
  position: relative;
}

.attach-btn {
  font-size: 1.3rem;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  border: none;
  background: transparent;
}

.attach-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 150px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px var(--shadow);
  padding: 6px;
  z-index: 20;
}

.attach-option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 8px;
  position: relative;
}

/* Android/iOS: file inputs must not use display:none or programmatic .click() fails */
.file-input-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.attach-option:hover,
.attach-option:active {
  background: var(--bg-dark);
}

.pending-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}

.pending-attachment-preview {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
}

#pending-attachment-name {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clear-attachment {
  border: none;
  background: var(--bg-dark);
  color: var(--text-meta);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
}

.message-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
  text-decoration: none;
  color: inherit;
}

.message-bubble.outgoing .message-file {
  background: rgba(255, 255, 255, 0.35);
}

.message-file-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.message-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.message-file-name {
  font-size: 0.88rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-file-action {
  font-size: 0.72rem;
  color: var(--text-meta);
}

#message-input {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 24px;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

.send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn:disabled {
  background: var(--border);
  cursor: default;
}

/* Profile */
.profile-card {
  padding: 24px 16px;
  overflow-y: auto;
  flex: 1;
}

.profile-avatar-section {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.profile-name {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.profile-user-id {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-bottom: 16px;
}

.profile-photo-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 260px;
  margin: 0 auto 12px;
}

.profile-photo-btn {
  width: 100%;
}

.profile-save-status {
  margin-top: 10px;
  width: 100%;
}

.profile-card h3 {
  text-align: center;
  margin-bottom: 24px;
}

.user-list-self {
  background: rgba(0, 128, 105, 0.06);
}

.self-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
}

.profile-field {
  margin-bottom: 20px;
}

.profile-field input {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: var(--bg-panel);
  color: var(--text-primary);
}

.profile-field .error-msg {
  margin-top: 8px;
  text-align: left;
}

.profile-field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.copy-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-dark);
  padding: 12px 16px;
  border-radius: 12px;
}

.copy-id-row code {
  flex: 1;
  font-size: 1rem;
  color: var(--accent);
}

.btn-small {
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

#status-input { margin-bottom: 10px; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #323739;
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 0.85rem;
  z-index: 1000;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast.show { display: block; animation: toastIn 0.3s ease; }

/* Incoming message alert flash (chat open) */
body.message-alert-flash #messages-container {
  animation: msgFlash 0.6s ease;
}

@keyframes msgFlash {
  0%, 100% { background-color: var(--bg-chat); }
  30% { background-color: rgba(0, 128, 105, 0.25); }
}

.message-alert-banner {
  position: fixed;
  top: calc(8px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 128, 105, 0.4);
  animation: bannerPop 0.35s ease;
  max-width: 90%;
  text-align: center;
}

@keyframes bannerPop {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal img {
  max-width: 95%;
  max-height: 85vh;
  object-fit: contain;
}

.modal-close {
  position: absolute;
  top: calc(16px + var(--safe-top));
  right: 16px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}
