html[data-theme="dark"] {
  color-scheme: dark;
  --white: #111b21;
  --soft: #17232a;
  --soft2: #1f2c34;
  --ink: #e9edef;
  --navy: #e9edef;
  --blue: #53bdeb;
  --cyan: #2cc4f3;
  --muted: #8696a0;
  --line: #273842;
  --green: #22c98b;
  --red: #ff6b78;
  --shadow: 0 18px 50px rgba(0,0,0,.24);
  background: #0b141a;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .app-stage { background: #0b141a; color: var(--ink); }
html[data-theme="dark"] .app-shell { background: #111b21; box-shadow: 0 25px 80px rgba(0,0,0,.5); }
html[data-theme="dark"] button,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select { color: var(--ink); }

html[data-theme="dark"] .app-header,
html[data-theme="dark"] .app-shell[data-screen="chat"] .app-header,
html[data-theme="dark"] .bottom-nav,
html[data-theme="dark"] .app-shell[data-screen="chat"] .bottom-nav,
html[data-theme="dark"] .chat-room-header,
html[data-theme="dark"] .message-composer,
html[data-theme="dark"] .modal { background: rgba(17,27,33,.98); border-color: var(--line); }

html[data-theme="dark"] .screen,
html[data-theme="dark"] .screens { background: #111b21; }

html[data-theme="dark"] .round-button,
html[data-theme="dark"] .network-pill,
html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .app-shell[data-screen="chat"] .network-pill,
html[data-theme="dark"] .app-shell[data-screen="chat"] .round-button,
html[data-theme="dark"] .chat-room-header > button { background: #202c33; border-color: #2c3b44; }

html[data-theme="dark"] .brand b,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] b,
html[data-theme="dark"] strong { color: var(--ink); }

html[data-theme="dark"] .search-field,
html[data-theme="dark"] .dapp-search,
html[data-theme="dark"] .contract-watch-form,
html[data-theme="dark"] .form-stack input,
html[data-theme="dark"] .form-stack textarea,
html[data-theme="dark"] .form-stack select,
html[data-theme="dark"] .message-composer textarea { background: #202c33; border-color: #2c3b44; color: #e9edef; }

html[data-theme="dark"] .search-field input::placeholder,
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] input::placeholder { color: #72828c; }

html[data-theme="dark"] .bottom-nav { border-color: #26353d; box-shadow: 0 -1px 0 #26353d; }
html[data-theme="dark"] .bottom-nav button { color: #80909a; }
html[data-theme="dark"] .bottom-nav button.active { color: #53bdeb; }

html[data-theme="dark"] .chat-filters button { background: #18242b; border-color: #2b3b44; color: #9aaab3; }
html[data-theme="dark"] .chat-filters button.active { background: #0b3a52; border-color: #15506c; color: #7bd4ff; }
html[data-theme="dark"] .chat-list,
html[data-theme="dark"] .contact-chat-list,
html[data-theme="dark"] .chat-row { background: transparent; border-color: #223139; }
html[data-theme="dark"] .chat-preview-check { color: #53bdeb; }
html[data-theme="dark"] .chat-row-meta em { background: #087bea; color: #fff; }
html[data-theme="dark"] .chat-zero > span { background: #202c33; }

html[data-theme="dark"] .chat-room { background: #0b141a; }
html[data-theme="dark"] .conversation-security-strip { background: #18242b; color: #88a0ac; border-color: #26363f; }
html[data-theme="dark"] .message-list {
  background-color: #0b141a;
  background-image: radial-gradient(circle at 10px 10px, rgba(83,189,235,.045) 1.1px, transparent 1.2px);
}
html[data-theme="dark"] .message-day span { background: #18262e; border-color: #2b3b44; color: #9babb4; }
html[data-theme="dark"] .message-bubble.incoming { background: linear-gradient(145deg,rgba(40,54,62,.92),rgba(30,43,50,.78)); border-color: rgba(255,255,255,.08); color: #e9edef; }
html[data-theme="dark"] .message-bubble.outgoing { background: linear-gradient(145deg,rgba(10,109,158,.88),rgba(4,74,111,.78)); border-color: rgba(123,212,255,.14); color: #f3f8fb; }
html[data-theme="dark"] .message-avatar { background: #202c33; border-color: #31424b; }
html[data-theme="dark"] .compact-chat-tools button { background: #18242b; box-shadow: inset 0 0 0 1px #26363f; }
html[data-theme="dark"] .compact-chat-tools button > span { background: #202f37; box-shadow: none; }
html[data-theme="dark"] .message-meta { color: #b4c0c7; }
html[data-theme="dark"] .message-check { color: #7bd4ff; }
html[data-theme="dark"] .message-reply-quote { background: rgba(0,0,0,.17); border-color: #53bdeb; }
html[data-theme="dark"] .message-reply-quote b { color: #7bd4ff; }
html[data-theme="dark"] .composer-reply { background: #1a2931; border-color: #53bdeb; }
html[data-theme="dark"] .composer-reply b { color: #7bd4ff; }
html[data-theme="dark"] .composer-reply small { color: #a8b6be; }

/* Dark liquid-glass uses its own optical values, not the light surface. */
html[data-theme="dark"] .message-list {
  background-color: #0a141a;
  background-image:
    radial-gradient(circle at 8% 10%, rgba(48,179,239,.13), transparent 29%),
    radial-gradient(circle at 92% 4%, rgba(66,145,187,.08), transparent 25%),
    radial-gradient(circle at 52% 86%, rgba(22,106,157,.08), transparent 32%),
    radial-gradient(circle at 10px 10px, rgba(111,209,249,.028) 1.1px, transparent 1.2px);
  background-size: auto, auto, auto, 22px 22px;
}

html[data-theme="dark"] .message-day span {
  border-color: rgba(180,224,244,.10);
  background: rgba(31,47,57,.43);
  color: #9eb0ba;
  box-shadow: 0 9px 24px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.09);
}

html[data-theme="dark"] .message-row .message-bubble {
  box-shadow:
    0 16px 38px rgba(0,0,0,.26),
    0 4px 10px rgba(0,0,0,.16),
    inset 0 1px 0 rgba(255,255,255,.12),
    inset 0 -1px 0 rgba(0,0,0,.10);
  -webkit-backdrop-filter: blur(30px) saturate(165%);
  backdrop-filter: blur(30px) saturate(165%);
}

html[data-theme="dark"] .message-row .message-bubble::before {
  background:
    linear-gradient(115deg, rgba(220,247,255,.14) 0%, rgba(141,220,250,.035) 38%, transparent 61%),
    radial-gradient(circle at 87% 3%, rgba(139,224,255,.16), transparent 28%);
  opacity: .84;
}

html[data-theme="dark"] .message-bubble.incoming {
  border-color: rgba(191,225,240,.12);
  background: linear-gradient(145deg, rgba(41,57,66,.57), rgba(23,36,44,.40));
  color: #eef7fa;
}

html[data-theme="dark"] .message-bubble.outgoing {
  border-color: rgba(121,214,255,.25);
  background:
    linear-gradient(145deg, rgba(32,149,211,.50), rgba(9,85,134,.34)),
    rgba(16,104,157,.22);
  color: #f4fbfe;
  box-shadow:
    0 16px 40px rgba(0,64,104,.30),
    0 4px 10px rgba(0,0,0,.18),
    inset 0 1px 0 rgba(192,239,255,.20),
    inset 0 -1px 0 rgba(0,22,39,.16);
}

html[data-theme="dark"] .message-avatar {
  border-color: rgba(174,221,241,.13);
  background: rgba(37,52,61,.48);
  box-shadow: 0 10px 24px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.10);
}

html[data-theme="dark"] .message-composer {
  border-top-color: rgba(159,214,237,.09);
  background: rgba(12,23,29,.72);
  box-shadow: 0 -16px 40px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.055);
}

html[data-theme="dark"] .message-composer textarea {
  border-color: rgba(174,222,241,.11);
  background: rgba(255,255,255,.065);
  color: #edf7fa;
  box-shadow: 0 9px 24px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.07);
}

html[data-theme="dark"] .message-composer textarea:focus {
  border-color: rgba(94,207,255,.34);
  background: rgba(255,255,255,.09);
  box-shadow: 0 0 0 4px rgba(52,183,239,.07), 0 10px 27px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.09);
}

html[data-theme="dark"] .message-composer .composer-tools,
html[data-theme="dark"] .message-composer .composer-send {
  border-color: rgba(167,222,244,.12);
  box-shadow: 0 10px 24px rgba(0,0,0,.23), inset 0 1px 0 rgba(255,255,255,.10);
}

html[data-theme="dark"] .message-composer .composer-tools { background: rgba(255,255,255,.075); }
html[data-theme="dark"] .message-composer .composer-send { background: linear-gradient(145deg, rgba(42,171,234,.90), rgba(23,101,215,.86)); }

html[data-theme="dark"] .section-block,
html[data-theme="dark"] .empty-wallet,
html[data-theme="dark"] .market-section,
html[data-theme="dark"] .appearance-card,
html[data-theme="dark"] .security-hero,
html[data-theme="dark"] .security-facts,
html[data-theme="dark"] .settings-list,
html[data-theme="dark"] .balance-card,
html[data-theme="dark"] .receive-page-card,
html[data-theme="dark"] .ucard-intro,
html[data-theme="dark"] .ucard-action-grid button,
html[data-theme="dark"] .ucard-deposit-row,
html[data-theme="dark"] .dapp-card,
html[data-theme="dark"] .activity-row { background: #17232a; border-color: #2a3a43; }

html[data-theme="dark"] .security-facts > div,
html[data-theme="dark"] .settings-list > button,
html[data-theme="dark"] .asset-row,
html[data-theme="dark"] .market-row { border-color: #25353e; background: transparent; }

html[data-theme="dark"] .market-row-main > em.up { background: #12392f; color: #52d5a2; }
html[data-theme="dark"] .market-row-main > em.down { background: #42242a; color: #ff8792; }
html[data-theme="dark"] .market-row-main > em.flat { background: #26333b; }
html[data-theme="dark"] .market-ticker { background: #111d24; border-color: #2a3a43; }
html[data-theme="dark"] .market-ticker-live { background: #17232a; border-color: #2a3a43; color: #52d5a2; }
html[data-theme="dark"] .common-market-card { background: #111d24; border-color: #2a3a43; color: var(--ink); }
html[data-theme="dark"] .common-market-card > em.up { background: #12392f; color: #52d5a2; }
html[data-theme="dark"] .common-market-card > em.down { background: #42242a; color: #ff8792; }
html[data-theme="dark"] .common-market-card > em.flat { background: #26333b; }
html[data-theme="dark"] .ticker-item em.up,
html[data-theme="dark"] .market-change-text.up { color: #52d5a2; }
html[data-theme="dark"] .ticker-item em.down,
html[data-theme="dark"] .market-change-text.down { color: #ff8792; }
html[data-theme="dark"] .market-token-icon,
html[data-theme="dark"] .appearance-copy > span,
html[data-theme="dark"] .chat-launch-grid button > span,
html[data-theme="dark"] .ucard-action-grid button > span { background: #202f38; }

html[data-theme="dark"] .appearance-segment { background: #0f191f; }
html[data-theme="dark"] .appearance-segment button { color: #91a0a9; }
html[data-theme="dark"] .appearance-segment button.active { background: #263640; color: #7bd4ff; box-shadow: none; }

html[data-theme="dark"] .modal-backdrop { background: rgba(0,0,0,.62); }
html[data-theme="dark"] .modal-header::before { background: #44545d; }
html[data-theme="dark"] .modal-close { background: #202f38; }
html[data-theme="dark"] .message-action-preview,
html[data-theme="dark"] .emoji-grid button,
html[data-theme="dark"] .message-action-grid button,
html[data-theme="dark"] .resource-links button,
html[data-theme="dark"] .contact-row,
html[data-theme="dark"] .token-manage-row,
html[data-theme="dark"] .profile-action-grid button,
html[data-theme="dark"] .chat-tool-grid button,
html[data-theme="dark"] .meeting-picker button,
html[data-theme="dark"] .group-member-choice { background: #18252d; border-color: #2b3b44; color: var(--ink); }
html[data-theme="dark"] .modal.chat-tools-modal { border-color: #2c3b44; }

html[data-theme="dark"] .message-action-grid .message-delete-action { color: #ff7b86; }
html[data-theme="dark"] .warning-card { background: #302b1d; border-color: #4b432a; }
html[data-theme="dark"] .warning-card small { color: #c2b68d; }
html[data-theme="dark"] .risk-banner { background: #302b1d; border-color: #4b432a; }
html[data-theme="dark"] .contact-intro,
html[data-theme="dark"] .identity-ready,
html[data-theme="dark"] .ucard-flow,
html[data-theme="dark"] .ucard-boundary,
html[data-theme="dark"] .ucard-detail-card { background: #172832; border-color: #29414e; }

html[data-theme="dark"] .identity-qr { background: #fff; }
html[data-theme="dark"] .danger-button,
html[data-theme="dark"] .mini-danger { background: #3c2228 !important; }
html[data-theme="dark"] .privacy-shield { background: #0b141a; }

html[data-theme="dark"] .theme-toggle-button img,
html[data-theme="dark"] #appearanceIcon { filter: none; }

@media (max-width: 520px) {
  html[data-theme="dark"],
  html[data-theme="dark"] body { background: #111b21; }
}
