:root {
  --wa-bg: #0b141a;
  --wa-panel: #111b21;
  --wa-header: #202c33;
  --wa-input: #2a3942;
  --wa-hover: #2a3942;
  --wa-border: #222d34;
  --wa-bubble-out: #005c4b;
  --wa-bubble-in: #202c33;
  --wa-accent: #00a884;
  --wa-accent-dark: #008f72;
  --wa-text: #e9edef;
  --wa-text-secondary: #8696a0;
  --wa-danger: #ea0038;
  --wa-danger-hover: #c40030;
  --radius: 8px;
  --radius-bubble: 7.5px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--wa-bg);
  color: var(--wa-text);
  min-height: 100%;
  min-height: 100dvh;
  line-height: 1.45;
  overflow: hidden;
}

#app-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  margin: 0;
  background: var(--wa-panel);
  position: relative;
}

.hidden {
  display: none !important;
}

.wa-header {
  background: var(--wa-header);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 60px;
  padding-top: max(0.6rem, env(safe-area-inset-top));
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.header-logo {
  height: 32px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.header-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--wa-text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.header-btn:hover {
  background: var(--wa-hover);
  color: var(--wa-text);
}

.header-btn svg {
  width: 22px;
  height: 22px;
}

.header-btn {
  position: relative;
}

.header-btn:active {
  background: var(--wa-hover);
  color: var(--wa-text);
}

.request-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--wa-accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.requests-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.requests-sheet-header h3 {
  margin-bottom: 0;
}

.requests-count {
  font-size: 0.75rem;
  color: var(--wa-text-secondary);
}

.requests-list {
  list-style: none;
  max-height: min(50vh, 360px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.requests-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--wa-text-secondary);
  margin-bottom: 1rem;
}

.requests-empty p {
  font-size: 0.95rem;
}

.request-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--wa-border);
}

.request-item-body {
  flex: 1;
  min-width: 0;
}

.request-item-name {
  display: block;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.9rem;
  color: var(--wa-text);
}

.request-item-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--wa-text-secondary);
  margin-top: 0.1rem;
}

.request-item-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-accept,
.btn-decline {
  border: none;
  border-radius: 20px;
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  min-width: 64px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-accept {
  background: var(--wa-accent);
  color: #fff;
}

.btn-accept:hover {
  background: var(--wa-accent-dark);
}

.btn-decline {
  background: var(--wa-input);
  color: var(--wa-text-secondary);
}

.btn-decline:hover {
  background: var(--wa-hover);
  color: var(--wa-text);
}

.sent-requests-strip {
  background: #1a2e38;
  color: var(--wa-accent);
  font-size: 0.78rem;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--wa-border);
  text-align: center;
}

.app-toast {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--wa-header);
  color: var(--wa-text);
  border: 1px solid var(--wa-border);
  padding: 0.75rem 1.25rem;
  border-radius: 24px;
  font-size: 0.9rem;
  z-index: 2900;
  box-shadow: var(--shadow);
  max-width: min(90vw, 400px);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.app-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.25rem;
  flex-shrink: 0;
}

.status-connected {
  background: var(--wa-accent);
  box-shadow: 0 0 6px var(--wa-accent);
}

.status-disconnected {
  background: #f59e0b;
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.avatar-wrap-sm .presence-dot {
  width: 10px;
  height: 10px;
  border-width: 2px;
}

.presence-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--wa-header);
  box-sizing: border-box;
}

.presence-dot.online {
  background: var(--wa-accent);
}

.presence-dot.offline {
  background: #8696a0;
}

.chat-subtitle.typing,
.chat-item-preview.typing {
  color: var(--wa-accent);
  font-style: italic;
}

.chat-subtitle.online {
  color: var(--wa-accent);
}

.chat-subtitle.offline {
  color: var(--wa-text-secondary);
}

#main-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.app-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--wa-panel);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  padding-top: max(0.85rem, env(safe-area-inset-top));
  background: var(--wa-header);
  border-bottom: 1px solid var(--wa-border);
  flex-shrink: 0;
}

.sidebar-brand-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.sidebar-brand-text h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.connection-label {
  font-size: 0.72rem;
  color: var(--wa-text-secondary);
  display: block;
}

.sidebar-toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  background: var(--wa-header);
  border-bottom: 1px solid var(--wa-border);
  flex-shrink: 0;
}

.toolbar-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.45rem 0.25rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--wa-text-secondary);
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toolbar-btn svg {
  width: 20px;
  height: 20px;
}

.toolbar-btn:hover {
  background: var(--wa-hover);
  color: var(--wa-text);
}

.toolbar-btn .request-badge {
  top: 2px;
  right: 8px;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--wa-border);
  background: var(--wa-header);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1px solid var(--wa-border);
  border-radius: var(--radius);
  background: var(--wa-input);
  color: var(--wa-text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-settings-btn svg {
  width: 18px;
  height: 18px;
  color: var(--wa-accent);
}

.sidebar-settings-btn:hover {
  background: var(--wa-hover);
  border-color: var(--wa-accent);
}

.sidebar-version {
  margin: 0;
  text-align: center;
  font-size: 0.7rem;
}

.mobile-only {
  display: none;
}

.desktop-only {
  display: flex;
}

.sidebar-brand-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.header-btn-danger:hover {
  color: var(--wa-danger);
  background: rgba(234, 0, 56, 0.12);
}

#chats-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.chat-pane {
  position: relative;
  min-height: 0;
}

.chat-placeholder {
  display: none;
}

.account-card {
  margin: 0.65rem 0.75rem 0;
  padding: 0.65rem 0.75rem;
  background: var(--wa-bg);
  border: 1px solid var(--wa-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.account-card-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account-card-private {
  opacity: 0.75;
}

.account-label {
  color: var(--wa-text-secondary);
  min-width: 82px;
  flex-shrink: 0;
}

.friend-code {
  font-family: "Cascadia Code", "Consolas", monospace;
  color: var(--wa-accent);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.account-id-private {
  font-family: "Cascadia Code", "Consolas", monospace;
  color: var(--wa-text-secondary);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  margin-left: auto;
  background: var(--wa-input);
  border: none;
  color: var(--wa-accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 32px;
}

.copy-btn:hover {
  background: var(--wa-hover);
}

.sheet-hint {
  color: var(--wa-text-secondary);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.search-bar {
  background: var(--wa-header);
  padding: 0.5rem 1rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.search-bar svg {
  width: 18px;
  height: 18px;
  color: var(--wa-text-secondary);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: var(--wa-input);
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  color: var(--wa-text);
  font-size: 0.9rem;
  min-height: 36px;
}

.search-bar input::placeholder {
  color: var(--wa-text-secondary);
}

.search-bar input:focus {
  outline: none;
}

.chat-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--wa-border);
  transition: background 0.12s;
  position: relative;
}

.chat-item-remove {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--wa-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.chat-item-remove svg {
  width: 16px;
  height: 16px;
}

.chat-item:hover .chat-item-remove,
.chat-item:focus-within .chat-item-remove {
  opacity: 1;
}

.chat-item-remove:hover {
  background: rgba(234, 0, 56, 0.15);
  color: var(--wa-danger);
}

.chat-item:hover,
.chat-item:active {
  background: var(--wa-hover);
}

.chat-item.active {
  background: var(--wa-hover);
}

.chat-item-body {
  flex: 1;
  min-width: 0;
}

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.chat-item-name {
  font-size: 1rem;
  font-weight: 400;
  color: var(--wa-text);
  font-family: "Cascadia Code", "Consolas", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 0.75rem;
  color: var(--wa-text-secondary);
  flex-shrink: 0;
}

.chat-item-preview {
  font-size: 0.85rem;
  color: var(--wa-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-preview.unread {
  color: var(--wa-text);
  font-weight: 500;
}

.avatar {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.avatar-sm {
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  color: var(--wa-text-secondary);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state p {
  font-size: 1.1rem;
  color: var(--wa-text);
  margin-bottom: 0.35rem;
}

.empty-state span {
  font-size: 0.85rem;
  max-width: 240px;
}

#chat-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--wa-bg);
  z-index: 20;
}

#chat-view:not(.hidden) {
  display: flex;
}

.chat-header-bar {
  flex-shrink: 0;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-info h2 {
  font-size: 1rem;
  font-weight: 500;
  font-family: "Cascadia Code", "Consolas", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-subtitle {
  font-size: 0.75rem;
  color: var(--wa-text-secondary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 2.5%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

.chat-wallpaper {
  background-color: #0b141a;
  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='%23182229' fill-opacity='0.6'%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");
}

.message-row {
  display: flex;
  margin-bottom: 2px;
}

.message-row.sent {
  justify-content: flex-end;
}

.message-row.received {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 88%;
  padding: 6px 8px 6px 10px;
  border-radius: var(--radius-bubble);
  font-size: 0.925rem;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.message-row.sent .message-bubble {
  background: var(--wa-bubble-out);
  border-top-right-radius: 0;
}

.message-row.received .message-bubble {
  background: var(--wa-bubble-in);
  border-top-left-radius: 0;
}

.message-text {
  display: block;
  padding-right: 4px;
  line-height: 1.4;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  float: right;
  margin-left: 8px;
  margin-top: 4px;
  position: relative;
  top: 4px;
}

.msg-time,
.msg-timer {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

.message-row.received .msg-time,
.message-row.received .msg-timer {
  color: var(--wa-text-secondary);
}

.chat-compose {
  background: var(--wa-header);
  padding: 0.5rem 1rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.compose-box {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  background: var(--wa-input);
  border-radius: 24px;
  padding: 0.35rem 0.35rem 0.35rem 0.5rem;
}

.compose-action-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--wa-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.compose-action-btn svg {
  width: 20px;
  height: 20px;
}

.compose-action-btn:hover {
  color: var(--wa-text);
  background: var(--wa-hover);
}

.compose-action-btn.recording {
  color: var(--wa-danger);
  background: rgba(234, 0, 56, 0.15);
}

.voice-recording-hint {
  font-size: 0.75rem;
  color: var(--wa-danger);
  text-align: center;
  margin-top: 0.4rem;
}

.message-image {
  display: block;
  max-width: min(280px, 72vw);
  border-radius: 6px;
  margin-bottom: 0.25rem;
}

.message-audio {
  width: min(260px, 70vw);
  height: 36px;
}

.account-invite-hint {
  flex: 1;
  font-size: 0.78rem;
  color: var(--wa-text-secondary);
}

.qr-actions-row {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.qr-actions-row .btn {
  flex: 1;
}

.compose-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--wa-text);
  font-size: 0.95rem;
  padding: 0.5rem 0;
  min-height: 24px;
  max-height: 100px;
}

.compose-box input::placeholder {
  color: var(--wa-text-secondary);
}

.compose-box input:focus {
  outline: none;
}

.send-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--wa-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.send-btn:hover {
  background: var(--wa-accent-dark);
}

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

.send-btn svg {
  width: 20px;
  height: 20px;
  margin-left: 2px;
}

.sheet {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-content {
  background: var(--wa-header);
  width: 100%;
  max-width: 100%;
  max-height: 85%;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 1.25rem 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  animation: slideUp 0.22s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-content h3 {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.sheet-content > p {
  color: var(--wa-text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.qr-friend-code-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--wa-bg);
  border-radius: var(--radius);
}

.qr-friend-code-row .friend-code {
  font-size: 1.1rem;
}

.scanner-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.scanner-actions .btn {
  flex: 1;
}

#qr-code {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: #fff;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

#qr-code img {
  display: block;
  max-width: 100%;
  height: auto;
}

.scanner-viewport {
  position: relative;
  width: 100%;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  overflow: hidden;
}

#qr-reader {
  width: 100%;
}

.scanner-flip-btn {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(11, 20, 26, 0.72);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  z-index: 2;
}

.scanner-flip-btn svg {
  width: 1.35rem;
  height: 1.35rem;
}

.scanner-flip-btn:hover {
  background: rgba(11, 20, 26, 0.88);
}

.app-version {
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: var(--wa-text-secondary);
  letter-spacing: 0.02em;
}

#settings-panel .app-version {
  margin-top: 0;
  margin-bottom: 1rem;
  text-align: center;
}

.request-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
  font-family: "Cascadia Code", "Consolas", monospace;
}

.settings-group {
  margin-bottom: 1.25rem;
}

.settings-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--wa-text-secondary);
  margin-bottom: 0.4rem;
}

.settings-group select {
  width: 100%;
  background: var(--wa-input);
  color: var(--wa-text);
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 0.85rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--wa-text-secondary);
  margin-bottom: 0.35rem;
}

.form-group input {
  width: 100%;
  background: var(--wa-input);
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  color: var(--wa-text);
  font-size: 0.9rem;
  font-family: "Cascadia Code", "Consolas", monospace;
}

.form-group input:focus {
  outline: 2px solid var(--wa-accent);
  outline-offset: -1px;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 1rem;
  border-radius: 24px;
}

.btn-block {
  width: 100%;
  margin-bottom: 0.5rem;
}

.btn-primary {
  background: var(--wa-accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--wa-accent-dark);
}

.btn-secondary {
  background: var(--wa-input);
  color: var(--wa-text);
}

.btn-secondary:hover {
  background: var(--wa-hover);
}

.btn-danger {
  background: var(--wa-danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--wa-danger-hover);
}

.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
  background: var(--wa-bg);
  text-align: center;
}

.welcome-brand {
  margin-bottom: 2.5rem;
}

.welcome-logo {
  width: min(320px, 88vw);
  height: auto;
  margin-bottom: 1.5rem;
  object-fit: contain;
}

.placeholder-logo {
  width: min(280px, 70vw);
  height: auto;
  margin-bottom: 2rem;
  object-fit: contain;
  opacity: 0.9;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.welcome-brand h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.welcome-tagline {
  color: var(--wa-text-secondary);
  font-size: 1rem;
}

.feature-list {
  list-style: none;
  text-align: left;
  max-width: min(420px, 92vw);
  margin: 0 auto 2.5rem;
}

.feature-list li {
  padding: 0.55rem 0;
  color: var(--wa-text-secondary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.feature-list svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--wa-accent);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--wa-header);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin-bottom: 0.75rem;
  color: var(--wa-danger);
  font-weight: 500;
}

.modal p {
  color: var(--wa-text-secondary);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.capture-shield {
  position: fixed;
  inset: 0;
  z-index: 2600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wa-bg);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s ease-out;
}

.capture-shield:not(.hidden) {
  opacity: 1;
}

.capture-shield-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--wa-text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.capture-warning {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--wa-danger);
  color: white;
  padding: 0.85rem 1.35rem;
  border-radius: var(--radius);
  z-index: 2700;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  max-width: min(92vw, 420px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.capture-warning:not(.hidden) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: capture-warning-pulse 1.6s ease-in-out 2;
}

.capture-warning-icon {
  flex-shrink: 0;
}

@keyframes capture-warning-pulse {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.35), var(--shadow); }
}

.antitamper-blur {
  filter: blur(24px) !important;
  transition: filter 0.08s;
}

@media (min-width: 900px) {
  .mobile-only {
    display: none !important;
  }

  .desktop-only {
    display: flex;
  }

  body {
    background: linear-gradient(145deg, #05080a 0%, #0d1519 50%, #060a0d 100%);
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 10px;
  }

  #app-shell {
    max-width: 100%;
    width: 100%;
    height: calc(100dvh - 20px);
    max-height: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
    margin: 0;
  }

  #app-shell:has(#welcome-view:not(.hidden)) {
    max-width: 100%;
    max-height: none;
    height: calc(100dvh - 20px);
    min-height: 0;
  }

  .welcome-screen {
    min-height: 580px;
    padding: 3rem 10%;
  }

  .welcome-brand h1 {
    font-size: 2.5rem;
  }

  .feature-list {
    max-width: 480px;
  }

  .app-layout {
    flex-direction: row;
    background: var(--wa-bg);
  }

  .sidebar {
    width: 420px;
    min-width: 360px;
    max-width: 38%;
    flex: 0 0 auto;
    border-right: 1px solid var(--wa-border);
  }

  .sidebar-toolbar {
    grid-template-columns: repeat(4, 1fr);
    padding: 0.5rem 0.65rem;
  }

  .toolbar-btn span {
    font-size: 0.68rem;
  }

  .search-bar {
    padding: 0.5rem 0.75rem 0.65rem;
    background: transparent;
  }

  .chat-list {
    padding: 0 0.35rem;
  }

  .chat-item {
    border-radius: var(--radius);
    border-bottom: none;
    margin-bottom: 2px;
  }

  .chat-item-remove {
    opacity: 1;
  }

  .chat-pane {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    pointer-events: auto;
    background: var(--wa-bg);
  }

  .chat-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    pointer-events: auto;
    background:
      radial-gradient(ellipse at 30% 20%, rgba(0, 168, 132, 0.06) 0%, transparent 50%),
      radial-gradient(ellipse at 70% 80%, rgba(0, 168, 132, 0.04) 0%, transparent 45%),
      var(--wa-bg);
  }

  .chat-placeholder-inner {
    text-align: center;
    max-width: 520px;
    width: 90%;
    padding: 2.5rem 2.5rem;
    border: 1px solid var(--wa-border);
    border-radius: 16px;
    background: rgba(17, 27, 33, 0.6);
  }

  .placeholder-logo {
    width: 120px;
    margin: 0 auto 1.5rem;
    opacity: 0.85;
  }

  .chat-placeholder h2 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--wa-text);
    margin-bottom: 0.75rem;
  }

  .chat-placeholder p {
    font-size: 0.92rem;
    color: var(--wa-text-secondary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
  }

  .placeholder-features {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  .placeholder-features li {
    font-size: 0.75rem;
    color: var(--wa-accent);
    background: rgba(0, 168, 132, 0.1);
    border: 1px solid rgba(0, 168, 132, 0.25);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
  }

  #chat-view {
    position: relative;
    inset: auto;
    flex: 1;
    min-height: 0;
    z-index: 1;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
  }

  .chat-header-bar {
    border-bottom: 1px solid var(--wa-border);
  }

  .back-btn {
    display: none;
  }

  .message-bubble {
    max-width: 72%;
  }

  .chat-messages {
    padding: 1.5rem 4%;
  }

  .chat-compose {
    padding: 0.85rem 4% 1.1rem;
    background: var(--wa-header);
    border-top: 1px solid var(--wa-border);
  }

  .compose-box {
    max-width: none;
    margin: 0;
    width: 100%;
  }

  .chat-item.active {
    background: rgba(0, 168, 132, 0.12);
    border-left: 3px solid var(--wa-accent);
    padding-left: calc(1rem - 3px);
  }

  .sheet {
    align-items: center;
    justify-content: center;
  }

  .sheet-content {
    width: 92%;
    max-width: 520px;
    border-radius: 14px;
    max-height: 80vh;
    animation: fadeIn 0.18s ease-out;
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
  }

  .modal {
    max-width: 520px;
  }
}

@media (max-width: 899px) {
  .mobile-only {
    display: inline-flex;
  }

  .desktop-only {
    display: none !important;
  }

  .chat-item-remove {
    opacity: 1;
  }

  .sidebar-toolbar {
    grid-template-columns: repeat(4, 1fr);
  }

  .toolbar-btn span {
    display: none;
  }

  .app-layout {
    flex: 1;
    position: relative;
  }

  .chat-pane {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
  }

  #chat-view:not(.hidden) {
    pointer-events: auto;
  }

  #app-shell.chat-open .sidebar {
    visibility: hidden;
    pointer-events: none;
  }
}

@media (display-mode: standalone) {
  .wa-header {
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }
}