html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --blue: #77adff;
  --deep: #f1f7ff;
  --cyan: #67d7f0;
  --mint: #64e2b7;
  --ink: #edf5ff;
  --muted: #b7c6d8;
  --line: rgba(164, 190, 220, .28);
  --soft: #172538;
  --card: #1d2d42;
  --shadow: 0 18px 44px rgba(0, 0, 0, .32);
  background: #111b2b;
  color: var(--ink);
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background: #111b2b;
  color: var(--ink);
}

html[data-theme="dark"] .page,
html[data-theme="dark"] .app {
  background:
    radial-gradient(circle at 82% 0%, rgba(103, 215, 240, .16), transparent 150px),
    linear-gradient(180deg, #152235 0%, #111b2b 52%, #162235 100%);
}

html[data-theme="dark"] .article-panel,
html[data-theme="dark"] .comments-panel,
html[data-theme="dark"] .section-card,
html[data-theme="dark"] .account-hero,
html[data-theme="dark"] .contact,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .contact-card,
html[data-theme="dark"] .settings-modal-card,
html[data-theme="dark"] .auth-gate-panel,
html[data-theme="dark"] .auth-panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .content-card,
html[data-theme="dark"] .search-results {
  border-color: var(--line);
  background: rgba(29, 45, 66, .96);
  color: var(--ink);
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .article-panel h2,
html[data-theme="dark"] .article-section h3,
html[data-theme="dark"] .comments-head h2,
html[data-theme="dark"] .comment-item strong,
html[data-theme="dark"] .section-head h2,
html[data-theme="dark"] .settings-top h1,
html[data-theme="dark"] .list-main strong,
html[data-theme="dark"] .settings-row span,
html[data-theme="dark"] .settings-action span,
html[data-theme="dark"] .switch-row strong,
html[data-theme="dark"] .user-name strong,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .content-title {
  color: #f4f9ff;
}

html[data-theme="dark"] .article-panel p,
html[data-theme="dark"] .article-panel li,
html[data-theme="dark"] .comment-item p,
html[data-theme="dark"] .comment-empty,
html[data-theme="dark"] .muted-desc,
html[data-theme="dark"] .settings-top p,
html[data-theme="dark"] .settings-profile span,
html[data-theme="dark"] .list-main span,
html[data-theme="dark"] .switch-row em,
html[data-theme="dark"] .empty-state p,
html[data-theme="dark"] .comment-actions span {
  color: #b7c6d8;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .comment-form,
html[data-theme="dark"] .comment-empty,
html[data-theme="dark"] .comment-item,
html[data-theme="dark"] .comment-reply-state,
html[data-theme="dark"] .search-box,
html[data-theme="dark"] .tool-btn,
html[data-theme="dark"] .back,
html[data-theme="dark"] .back-btn,
html[data-theme="dark"] .settings-login,
html[data-theme="dark"] .auth-code-btn,
html[data-theme="dark"] .auth-gate-code-btn {
  border-color: rgba(164, 190, 220, .28);
  background: #152337;
  color: #edf5ff;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #8395aa;
}

html[data-theme="dark"] .comment-reply-label,
html[data-theme="dark"] .comment-reply-state button,
html[data-theme="dark"] .settings-login,
html[data-theme="dark"] .auth-gate-link,
html[data-theme="dark"] .auth-link-btn {
  color: #8bbcff;
}

html[data-theme="dark"] .article-meta span,
html[data-theme="dark"] .status,
html[data-theme="dark"] .entry-icon {
  background: rgba(119, 173, 255, .16);
  color: #a7caff;
}

html[data-theme="dark"] .bottom-nav {
  border-color: rgba(164, 190, 220, .22);
  background: rgba(21, 33, 51, .96);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .28);
}

html[data-theme="dark"] .nav-item {
  color: #b7c6d8;
}

html[data-theme="dark"] .nav-item.active {
  color: #8bbcff;
}

html[data-theme="dark"] .settings-row,
html[data-theme="dark"] .settings-action,
html[data-theme="dark"] .switch-row,
html[data-theme="dark"] .profile-form,
html[data-theme="dark"] .password-form {
  border-color: var(--line);
}

html[data-theme="dark"] .modal,
html[data-theme="dark"] .contact-modal,
html[data-theme="dark"] .settings-modal,
html[data-theme="dark"] .auth-gate-modal,
html[data-theme="dark"] .auth-modal {
  background: rgba(4, 10, 20, .68);
}

html[data-theme="dark"] .hero::after {
  background: linear-gradient(90deg, rgba(5, 18, 42, .86), rgba(15, 56, 112, .58), rgba(10, 86, 145, .18));
}

html[data-theme="dark"] .topbar-title,
html[data-theme="dark"] .back svg,
html[data-theme="dark"] .back-btn svg {
  color: #f4f9ff;
  text-shadow: none;
}

/* Dark mode is intentionally closer to the settings page: calm surfaces,
   readable text, and only small blue highlights. */
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .section-head h2,
html[data-theme="dark"] .contact-panel h2,
html[data-theme="dark"] .search-results-head strong,
html[data-theme="dark"] .search-empty strong,
html[data-theme="dark"] .empty-state strong,
html[data-theme="dark"] .empty-state-card strong,
html[data-theme="dark"] .contact-copy strong,
html[data-theme="dark"] .record-main,
html[data-theme="dark"] .progress-copy strong,
html[data-theme="dark"] .entry-item span,
html[data-theme="dark"] .order-item span,
html[data-theme="dark"] .summary-item strong {
  color: #f4f9ff !important;
  text-shadow: none;
}

html[data-theme="dark"] .section-head .more,
html[data-theme="dark"] .more,
html[data-theme="dark"] .search-results-head span,
html[data-theme="dark"] .search-empty span,
html[data-theme="dark"] .empty-state p,
html[data-theme="dark"] .empty-state-card span,
html[data-theme="dark"] .contact-copy span,
html[data-theme="dark"] .contact-panel p,
html[data-theme="dark"] .footer-links,
html[data-theme="dark"] footer,
html[data-theme="dark"] .summary-item span,
html[data-theme="dark"] .record-time,
html[data-theme="dark"] .progress-copy span,
html[data-theme="dark"] .user-name span {
  color: #b7c6d8 !important;
  text-shadow: none;
}

html[data-theme="dark"] .contact-band,
html[data-theme="dark"] .contact-panel,
html[data-theme="dark"] .empty-state-card,
html[data-theme="dark"] .search-result-card,
html[data-theme="dark"] .search-empty,
html[data-theme="dark"] .summary-item,
html[data-theme="dark"] .progress-row.is-primary,
html[data-theme="dark"] .record-row,
html[data-theme="dark"] .entry-item,
html[data-theme="dark"] .order-item,
html[data-theme="dark"] .list-row {
  border-color: rgba(164, 190, 220, .24) !important;
  background: rgba(29, 45, 66, .94) !important;
  color: #edf5ff !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .24);
}

html[data-theme="dark"] .section-card,
html[data-theme="dark"] .empty-card,
html[data-theme="dark"] .account-hero {
  border-color: rgba(164, 190, 220, .24) !important;
  background:
    radial-gradient(circle at 88% 0%, rgba(103, 215, 240, .08), transparent 120px),
    rgba(29, 45, 66, .94) !important;
}

html[data-theme="dark"] .content-card {
  border-color: rgba(164, 190, 220, .24) !important;
  background: #1d2d42 !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .26) !important;
}

html[data-theme="dark"] .card-body {
  background: linear-gradient(180deg, rgba(29, 45, 66, .98), rgba(24, 38, 57, .98)) !important;
}

html[data-theme="dark"] .card-title,
html[data-theme="dark"] .search-result-card h3,
html[data-theme="dark"] .content-card p {
  color: #f4f9ff !important;
}

html[data-theme="dark"] .card-meta,
html[data-theme="dark"] .search-result-card p,
html[data-theme="dark"] .result-meta {
  color: #b7c6d8 !important;
}

html[data-theme="dark"] .category-item {
  color: #dcecff !important;
}

html[data-theme="dark"] .category-icon {
  border-color: rgba(164, 190, 220, .2) !important;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .22), transparent 24px),
    linear-gradient(145deg, rgba(232, 245, 255, .18), rgba(103, 215, 240, .08)) !important;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .24) !important;
}

html[data-theme="dark"] .search {
  border-color: rgba(164, 190, 220, .24) !important;
  background: rgba(29, 45, 66, .94) !important;
  box-shadow: 0 12px 26px rgba(0, 0, 0, .2) !important;
}

html[data-theme="dark"] .search svg {
  color: #93a9c1 !important;
}

html[data-theme="dark"] .search input {
  background: transparent !important;
  color: #f4f9ff !important;
}

html[data-theme="dark"] .search input::placeholder {
  color: #a8bad0 !important;
}

html[data-theme="dark"] .search-feedback {
  color: #a8bad0 !important;
}

html[data-theme="dark"] .search-suggestions button,
html[data-theme="dark"] .search-suggestions a,
html[data-theme="dark"] .empty-actions a,
html[data-theme="dark"] .empty-actions button,
html[data-theme="dark"] .tab,
html[data-theme="dark"] .status-pill,
html[data-theme="dark"] .record-tag {
  background: rgba(119, 173, 255, .14) !important;
  color: #a7caff !important;
}

html[data-theme="dark"] .tab.active,
html[data-theme="dark"] .empty-actions .primary,
html[data-theme="dark"] .mini-action {
  background: linear-gradient(135deg, #2d7dff, #1b58df) !important;
  color: #fff !important;
}

html[data-theme="dark"] .badge,
html[data-theme="dark"] .tag {
  background: rgba(231, 240, 255, .14) !important;
  color: #bcd6ff !important;
}

html[data-theme="dark"] .empty-illus {
  background:
    radial-gradient(circle at 35% 20%, rgba(255, 255, 255, .16), transparent 32px),
    linear-gradient(145deg, rgba(150, 184, 210, .38), rgba(61, 82, 108, .58)) !important;
}

html[data-theme="dark"] .empty-illus::before {
  background: rgba(238, 245, 255, .92) !important;
}

html[data-theme="dark"] .empty-illus::after {
  background: #dcecff !important;
  box-shadow: -14px 0 0 #dcecff, 14px 0 0 #dcecff !important;
}

html[data-theme="dark"] .contact-panel img,
html[data-theme="dark"] .contact-modal img {
  background: #f8fbff;
}

html[data-theme="dark"] footer {
  border-color: rgba(164, 190, 220, .18) !important;
}

/* Strong dark pass for pasted article content and category empty states. */
html[data-theme="dark"] .page,
html[data-theme="dark"] .app,
html[data-theme="dark"] .phone-shell {
  background:
    radial-gradient(circle at 78% 0%, rgba(57, 119, 204, .14), transparent 138px),
    linear-gradient(180deg, #111b2b 0%, #0f1724 46%, #101826 100%) !important;
}

html[data-theme="dark"] .phone-shell::before {
  background:
    radial-gradient(circle at 88% 4%, rgba(103, 215, 240, .08), transparent 160px),
    linear-gradient(180deg, rgba(119, 173, 255, .06), transparent 240px) !important;
}

html[data-theme="dark"] .article-panel {
  border-color: rgba(125, 158, 194, .32) !important;
  background: #101826 !important;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .36) !important;
}

html[data-theme="dark"] .article-panel h1,
html[data-theme="dark"] .article-panel h2,
html[data-theme="dark"] .article-panel h3,
html[data-theme="dark"] .article-panel h4,
html[data-theme="dark"] .article-panel strong,
html[data-theme="dark"] .article-panel b {
  color: #f6f9ff !important;
}

html[data-theme="dark"] .article-panel p,
html[data-theme="dark"] .article-panel li,
html[data-theme="dark"] .article-panel span,
html[data-theme="dark"] .article-panel em,
html[data-theme="dark"] .article-panel div {
  color: #d6e3f2 !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content {
  background: transparent !important;
  color: #d6e3f2 !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content section,
html[data-theme="dark"] .article-panel .rich-paste-content div {
  border-color: rgba(125, 158, 194, .28) !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(255, 255, 255)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(255, 255, 255)"],
html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(233, 249, 255)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(233, 249, 255)"],
html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(234, 249, 255)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(234, 249, 255)"],
html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(244, 249, 255)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(244, 249, 255)"] {
  background-color: #172234 !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(177, 214, 247)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(177, 214, 247)"],
html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(82, 177, 234)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(82, 177, 234)"],
html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(95, 156, 239)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(95, 156, 239)"] {
  background-color: #2368ad !important;
  color: #fff !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(219, 219, 219)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(219, 219, 219)"],
html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(191, 220, 255)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(191, 220, 255)"] {
  background-color: rgba(125, 158, 194, .28) !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content img,
html[data-theme="dark"] .article-panel img {
  color: initial !important;
  background: transparent !important;
  border-color: transparent !important;
}

html[data-theme="dark"] .article-image,
html[data-theme="dark"] .article-video,
html[data-theme="dark"] .article-note,
html[data-theme="dark"] .article-panel blockquote,
html[data-theme="dark"] .article-panel code,
html[data-theme="dark"] .article-panel .paste-image-placeholder {
  border-color: rgba(125, 158, 194, .3) !important;
  background: #172234 !important;
  color: #d6e3f2 !important;
}

html[data-theme="dark"] .article-image figcaption,
html[data-theme="dark"] .article-panel .rich-paste-content [style*="font-size: 14px"] span {
  color: #9fb3c9 !important;
}

html[data-theme="dark"] .article-section {
  border-color: rgba(125, 158, 194, .24) !important;
}

html[data-theme="dark"] .system-card {
  border-color: rgba(125, 158, 194, .34) !important;
  background: #172234 !important;
  color: #d6e3f2 !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .22) !important;
}

html[data-theme="dark"] .system-card strong,
html[data-theme="dark"] .body h3 {
  color: #f6f9ff !important;
}

html[data-theme="dark"] .system-card span,
html[data-theme="dark"] .count {
  color: #b7c6d8 !important;
}

html[data-theme="dark"] .category-grid .category-item {
  color: #e8f2ff !important;
  opacity: 1 !important;
  text-shadow: none !important;
}

html[data-theme="dark"] .category-grid .category-icon {
  opacity: 1 !important;
}

html[data-theme="dark"] .announcement,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .top-notice {
  border-color: rgba(125, 158, 194, .26) !important;
  background: rgba(29, 45, 66, .94) !important;
  color: #dcecff !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content :not(img)[style*="background-color"] {
  background-color: #172234 !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content [style*="color"] {
  color: #d6e3f2 !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content strong[style*="color"],
html[data-theme="dark"] .article-panel .rich-paste-content b[style*="color"],
html[data-theme="dark"] .article-panel .rich-paste-content strong span[style*="color"],
html[data-theme="dark"] .article-panel .rich-paste-content b span[style*="color"] {
  color: #f6f9ff !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(177, 214, 247)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(177, 214, 247)"],
html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(82, 177, 234)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(82, 177, 234)"],
html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(95, 156, 239)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(95, 156, 239)"] {
  background-color: #2368ad !important;
  color: #fff !important;
}

html[data-theme="dark"] .article-panel .rich-paste-content section[style*="background-color: rgb(255, 96, 20)"],
html[data-theme="dark"] .article-panel .rich-paste-content div[style*="background-color: rgb(255, 96, 20)"],
html[data-theme="dark"] .article-panel .rich-paste-content span[style*="background-color: rgb(255, 96, 20)"] {
  background-color: #f97316 !important;
  color: #fff !important;
}

html[data-theme="dark"] .comment-delete-sheet {
  border: 1px solid rgba(116, 155, 200, .28);
  background: #172235;
}

html[data-theme="dark"] .comment-delete-sheet strong {
  color: #f4f9ff;
}

html[data-theme="dark"] .comment-delete-sheet p {
  color: #b7c6d8;
}

html[data-theme="dark"] .comment-delete-actions button:first-child {
  background: rgba(231, 240, 255, .12);
  color: #d6e5f7;
}

html[data-theme="dark"] .comment-form {
  box-shadow: 0 16px 36px rgba(0, 0, 0, .26);
}

html[data-theme="dark"] .comment-more {
  border-color: rgba(116, 155, 200, .28);
  background: rgba(119, 173, 255, .14);
  color: #a7caff;
}

/* Server hotfix: stable floating contact */
body > .float-contact {
  position: fixed !important;
  left: auto;
  right: 18px;
  bottom: 72px;
  top: auto;
  z-index: 999 !important;
  box-sizing: border-box !important;
  width: 52px !important;
  height: 52px !important;
  display: grid !important;
  place-items: center !important;
  border-radius: 999px !important;
  border: 1px solid rgba(179, 203, 235, .72) !important;
  background: rgba(255, 255, 255, .96) !important;
  color: #082d67 !important;
  box-shadow: 0 14px 32px rgba(18, 47, 88, .18) !important;
  opacity: 1 !important;
  transform: none !important;
  touch-action: none !important;
  cursor: grab !important;
  user-select: none !important;
}

body > .float-contact:active {
  cursor: grabbing !important;
}

body > .float-contact svg {
  width: 26px !important;
  height: 26px !important;
}

body > .float-contact.is-peek {
  opacity: .9 !important;
  box-shadow: 0 10px 24px rgba(18, 47, 88, .14) !important;
}

body > .float-label {
  display: none !important;
}

html[data-theme="dark"] body > .float-contact {
  border-color: rgba(159, 198, 255, .38) !important;
  background: rgba(255, 255, 255, .94) !important;
  color: #082d67 !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .26) !important;
}

@media (max-width: 360px) {
  body > .float-contact {
    width: 48px !important;
    height: 48px !important;
  }
}


/* Server hotfix: compact category empty state */
html[data-theme="dark"] .grid.is-system-feed {
  display: block !important;
}

html[data-theme="dark"] .system-card.is-empty {
  width: min(100%, 380px) !important;
  min-height: 0 !important;
  padding: 8px 0 2px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .system-card.is-empty strong {
  font-size: 15px !important;
  line-height: 1.28 !important;
  color: #f6f9ff !important;
}

html[data-theme="dark"] .system-card.is-empty span {
  max-width: 28em !important;
  margin-top: 4px !important;
  font-size: 12.5px !important;
  line-height: 1.5 !important;
  color: #c6d6e8 !important;
}

html[data-theme="dark"] .system-card.is-empty .system-actions {
  margin-top: 8px !important;
}

html[data-theme="dark"] .system-card.is-empty .system-actions a {
  min-height: 28px !important;
  padding: 0 10px !important;
  font-size: 12px !important;
}

/* Dark appearance polish: shared page, form, comment, search and account surfaces */
html[data-theme="dark"] {
  --surface-0: #081220;
  --surface-1: #111d2e;
  --surface-2: #17263c;
  --surface-3: #213450;
  --text-1: #f3f8ff;
  --text-2: #c6d6e8;
  --text-3: #8fa3ba;
  --accent-soft: rgba(119, 173, 255, .16);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .page,
html[data-theme="dark"] .app,
html[data-theme="dark"] .phone-shell,
html[data-theme="dark"] .search-page,
html[data-theme="dark"] .settings-page,
html[data-theme="dark"] .auth-page {
  background:
    radial-gradient(circle at 78% 0%, rgba(74, 144, 226, .18), transparent 180px),
    linear-gradient(180deg, #0b1626 0%, var(--surface-0) 58%, #0d1828 100%) !important;
  color: var(--text-1) !important;
}

html[data-theme="dark"] .article-panel,
html[data-theme="dark"] .comments-panel,
html[data-theme="dark"] .comment-section,
html[data-theme="dark"] .comment-drawer-sheet,
html[data-theme="dark"] .comment-delete-sheet,
html[data-theme="dark"] .live-comments,
html[data-theme="dark"] .live-player,
html[data-theme="dark"] .media-frame,
html[data-theme="dark"] .section-card,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .settings-section,
html[data-theme="dark"] .profile-form,
html[data-theme="dark"] .password-form,
html[data-theme="dark"] .security-card,
html[data-theme="dark"] .account-hero,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .auth-panel,
html[data-theme="dark"] .auth-gate-panel,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .search-panel,
html[data-theme="dark"] .search-results,
html[data-theme="dark"] .search-empty,
html[data-theme="dark"] .search-result-card,
html[data-theme="dark"] .empty-state-card,
html[data-theme="dark"] .contact-panel,
html[data-theme="dark"] .contact-card,
html[data-theme="dark"] .contact-band,
html[data-theme="dark"] .summary-item,
html[data-theme="dark"] .record-row,
html[data-theme="dark"] .progress-row,
html[data-theme="dark"] .calendar-card,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .report-card,
html[data-theme="dark"] .list-row,
html[data-theme="dark"] .entry-item {
  border-color: rgba(133, 166, 207, .24) !important;
  background: rgba(17, 29, 46, .94) !important;
  color: var(--text-1) !important;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .28) !important;
}

html[data-theme="dark"] .comment-card,
html[data-theme="dark"] .live-comment-card,
html[data-theme="dark"] .comment-bubble,
html[data-theme="dark"] .comment-item .comment-card {
  border-color: rgba(133, 166, 207, .26) !important;
  background: linear-gradient(180deg, rgba(26, 42, 65, .98), rgba(19, 33, 52, .98)) !important;
  color: var(--text-1) !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .18) !important;
}

html[data-theme="dark"] .comment-item {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .comment-item strong,
html[data-theme="dark"] .comment-name,
html[data-theme="dark"] .comment-author,
html[data-theme="dark"] .comments-head h2,
html[data-theme="dark"] .article-title,
html[data-theme="dark"] .article-panel h1,
html[data-theme="dark"] .article-panel h2,
html[data-theme="dark"] .article-panel h3,
html[data-theme="dark"] .settings-title,
html[data-theme="dark"] .settings-section-title,
html[data-theme="dark"] .profile-title,
html[data-theme="dark"] .auth-title,
html[data-theme="dark"] .search-title,
html[data-theme="dark"] .search-empty strong,
html[data-theme="dark"] .record-main,
html[data-theme="dark"] .calendar-title,
html[data-theme="dark"] .chart-title,
html[data-theme="dark"] .report-title {
  color: var(--text-1) !important;
}

html[data-theme="dark"] .comment-item p,
html[data-theme="dark"] .comment-body,
html[data-theme="dark"] .comment-meta,
html[data-theme="dark"] .live-comment-meta,
html[data-theme="dark"] .article-panel p,
html[data-theme="dark"] .article-panel li,
html[data-theme="dark"] .settings-desc,
html[data-theme="dark"] .settings-row small,
html[data-theme="dark"] .settings-row em,
html[data-theme="dark"] .profile-help,
html[data-theme="dark"] .auth-desc,
html[data-theme="dark"] .search-empty span,
html[data-theme="dark"] .search-result-card p,
html[data-theme="dark"] .record-time,
html[data-theme="dark"] .summary-item span,
html[data-theme="dark"] .calendar-subtitle,
html[data-theme="dark"] .chart-note {
  color: var(--text-2) !important;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .search-box,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] .comment-form,
html[data-theme="dark"] .comment-bottom-input,
html[data-theme="dark"] .comment-drawer textarea,
html[data-theme="dark"] .comment-drawer input,
html[data-theme="dark"] .live-comment-form,
html[data-theme="dark"] .live-comment-form input,
html[data-theme="dark"] .live-comment-form textarea,
html[data-theme="dark"] .auth-input,
html[data-theme="dark"] .auth-field,
html[data-theme="dark"] .profile-input {
  border-color: rgba(133, 166, 207, .28) !important;
  background: rgba(9, 20, 35, .86) !important;
  color: var(--text-1) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] .search-box:focus-within,
html[data-theme="dark"] .comment-form:focus-within,
html[data-theme="dark"] .live-comment-form:focus-within {
  border-color: rgba(119, 173, 255, .72) !important;
  box-shadow: 0 0 0 3px rgba(119, 173, 255, .16) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] .search-placeholder,
html[data-theme="dark"] .rotating-placeholder {
  color: var(--text-3) !important;
}

html[data-theme="dark"] .primary-btn,
html[data-theme="dark"] .submit-btn,
html[data-theme="dark"] .auth-submit,
html[data-theme="dark"] .comment-send,
html[data-theme="dark"] .live-comment-send,
html[data-theme="dark"] .search-submit {
  background: linear-gradient(135deg, #2f7dff, #77adff) !important;
  color: #fff !important;
  box-shadow: 0 14px 28px rgba(47, 125, 255, .26) !important;
}

html[data-theme="dark"] .ghost-btn,
html[data-theme="dark"] .secondary-btn,
html[data-theme="dark"] .settings-row,
html[data-theme="dark"] .settings-action,
html[data-theme="dark"] .switch-row,
html[data-theme="dark"] .tab,
html[data-theme="dark"] .filter-chip,
html[data-theme="dark"] .category-filter,
html[data-theme="dark"] .search-suggestions button,
html[data-theme="dark"] .search-suggestions a,
html[data-theme="dark"] .comment-tool,
html[data-theme="dark"] .share-btn,
html[data-theme="dark"] .favorite-btn {
  border-color: rgba(133, 166, 207, .24) !important;
  background: rgba(31, 49, 76, .78) !important;
  color: #d8eaff !important;
}

html[data-theme="dark"] .tab.active,
html[data-theme="dark"] .filter-chip.active,
html[data-theme="dark"] .category-filter.active {
  background: rgba(119, 173, 255, .22) !important;
  color: #fff !important;
}

html[data-theme="dark"] .bottom-nav,
html[data-theme="dark"] .comment-bottom-bar,
html[data-theme="dark"] .live-input-bar,
html[data-theme="dark"] .fixed-bottom-bar {
  border-color: rgba(133, 166, 207, .2) !important;
  background: rgba(10, 20, 34, .96) !important;
  box-shadow: 0 -14px 34px rgba(0, 0, 0, .28) !important;
}

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .search-topbar,
html[data-theme="dark"] .settings-topbar,
html[data-theme="dark"] .page-header {
  background: linear-gradient(180deg, rgba(11, 22, 38, .96), rgba(11, 22, 38, .76), rgba(11, 22, 38, 0)) !important;
  color: var(--text-1) !important;
}

html[data-theme="dark"] .badge,
html[data-theme="dark"] .tag,
html[data-theme="dark"] .status,
html[data-theme="dark"] .article-meta span,
html[data-theme="dark"] .record-tag,
html[data-theme="dark"] .content-type-badge {
  background: var(--accent-soft) !important;
  color: #bcd8ff !important;
  border-color: rgba(119, 173, 255, .24) !important;
}

html[data-theme="dark"] .empty-illus,
html[data-theme="dark"] .comment-empty-icon,
html[data-theme="dark"] .search-empty-icon {
  background: rgba(218, 230, 246, .08) !important;
  color: #a9bdd8 !important;
}

html[data-theme="dark"] .comment-delete-actions button:first-child,
html[data-theme="dark"] .modal-close,
html[data-theme="dark"] .drawer-close,
html[data-theme="dark"] .back,
html[data-theme="dark"] .back-btn {
  background: rgba(235, 244, 255, .1) !important;
  color: #eaf2ff !important;
  border-color: rgba(133, 166, 207, .22) !important;
}

html[data-theme="dark"] .comment-delete-actions button:last-child,
html[data-theme="dark"] .danger-btn,
html[data-theme="dark"] .logout-btn {
  background: rgba(251, 113, 133, .14) !important;
  color: #ffb4c0 !important;
}

html[data-theme="dark"] .calendar-day,
html[data-theme="dark"] .chart-point,
html[data-theme="dark"] .stat-cell {
  border-color: rgba(133, 166, 207, .18) !important;
  background: rgba(13, 25, 42, .72) !important;
  color: var(--text-2) !important;
}

html[data-theme="dark"] .calendar-day.is-active,
html[data-theme="dark"] .calendar-day.active,
html[data-theme="dark"] .stat-cell.active {
  background: rgba(119, 173, 255, .2) !important;
  color: #fff !important;
}

html[data-theme="dark"] ::selection {
  background: rgba(119, 173, 255, .36);
  color: #fff;
}

/* Manual dark mode v2: calmer, less harsh, and closer to one product system */
html[data-theme="dark"] {
  --surface-0: #0d1726;
  --surface-1: #141f31;
  --surface-2: #1b2940;
  --surface-3: #243550;
  --text-1: #f5f8fc;
  --text-2: #c8d4e3;
  --text-3: #92a2b6;
  --line: rgba(148, 163, 184, .20);
  --card: var(--surface-1);
  --soft: var(--surface-2);
  --shadow: 0 18px 42px rgba(0, 0, 0, .24);
  background: var(--surface-0);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .page,
html[data-theme="dark"] .app,
html[data-theme="dark"] .phone-shell,
html[data-theme="dark"] .settings-page,
html[data-theme="dark"] .search-page,
html[data-theme="dark"] .auth-page {
  background:
    radial-gradient(circle at 82% 0%, rgba(72, 135, 214, .13), transparent 180px),
    linear-gradient(180deg, #101b2b 0%, var(--surface-0) 50%, #0f1929 100%) !important;
}

html[data-theme="dark"] .account-hero,
html[data-theme="dark"] .settings-plain-group,
html[data-theme="dark"] .settings-user-row,
html[data-theme="dark"] .section-card,
html[data-theme="dark"] .learning-summary-card,
html[data-theme="dark"] .today-stat > div,
html[data-theme="dark"] .today-focus-card,
html[data-theme="dark"] .learning-trend-card,
html[data-theme="dark"] .calendar-card,
html[data-theme="dark"] .mine-stat-card,
html[data-theme="dark"] .mine-learning-row,
html[data-theme="dark"] .mine-favorites-card,
html[data-theme="dark"] .article-panel,
html[data-theme="dark"] .comments-panel,
html[data-theme="dark"] .comment-section,
html[data-theme="dark"] .search-result-card,
html[data-theme="dark"] .search-empty,
html[data-theme="dark"] .auth-panel,
html[data-theme="dark"] .auth-gate-panel,
html[data-theme="dark"] .settings-modal-card,
html[data-theme="dark"] .modal-card {
  border-color: rgba(148, 163, 184, .18) !important;
  background: rgba(20, 31, 49, .96) !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .22) !important;
}

html[data-theme="dark"] .settings-plain-group,
html[data-theme="dark"] .settings-user-row {
  border-radius: 16px !important;
}

html[data-theme="dark"] .settings-row,
html[data-theme="dark"] .settings-action,
html[data-theme="dark"] .switch-row {
  border-color: rgba(148, 163, 184, .14) !important;
  background: transparent !important;
  color: var(--text-1) !important;
}

html[data-theme="dark"] .settings-row span,
html[data-theme="dark"] .settings-action span,
html[data-theme="dark"] .settings-user-copy strong,
html[data-theme="dark"] .profile-form label > span,
html[data-theme="dark"] .password-form label > span,
html[data-theme="dark"] .auth-form label span,
html[data-theme="dark"] .auth-gate-form label span,
html[data-theme="dark"] .simple-tabs button.active,
html[data-theme="dark"] .lesson-filter strong,
html[data-theme="dark"] .comment-card strong {
  color: var(--text-1) !important;
}

html[data-theme="dark"] .settings-row strong,
html[data-theme="dark"] .settings-action strong,
html[data-theme="dark"] .settings-user-copy em,
html[data-theme="dark"] .profile-help,
html[data-theme="dark"] .auth-subtitle,
html[data-theme="dark"] .auth-tips,
html[data-theme="dark"] .auth-gate-subtitle,
html[data-theme="dark"] .auth-gate-tips,
html[data-theme="dark"] .comment-meta {
  color: var(--text-3) !important;
}

html[data-theme="dark"] .language-row select,
html[data-theme="dark"] .profile-form input,
html[data-theme="dark"] .password-form input,
html[data-theme="dark"] .auth-form input,
html[data-theme="dark"] .auth-gate-form input,
html[data-theme="dark"] .search-box,
html[data-theme="dark"] .comment-bottom-input,
html[data-theme="dark"] .comment-form textarea,
html[data-theme="dark"] .comment-drawer textarea,
html[data-theme="dark"] .live-comment-form textarea,
html[data-theme="dark"] .live-comment-form input {
  border-color: rgba(148, 163, 184, .22) !important;
  background: rgba(12, 23, 38, .92) !important;
  color: var(--text-1) !important;
}

html[data-theme="dark"] .auth-tabs,
html[data-theme="dark"] .auth-gate-tabs,
html[data-theme="dark"] .simple-tabs,
html[data-theme="dark"] .lesson-filter {
  background: rgba(12, 23, 38, .92) !important;
  border: 1px solid rgba(148, 163, 184, .14) !important;
}

html[data-theme="dark"] .auth-tabs button.active,
html[data-theme="dark"] .auth-gate-tabs button.active,
html[data-theme="dark"] .simple-tabs button.active,
html[data-theme="dark"] .lesson-filter.is-active,
html[data-theme="dark"] .lesson-filter.active {
  background: rgba(80, 145, 230, .24) !important;
  color: #f8fbff !important;
}

html[data-theme="dark"] .auth-close,
html[data-theme="dark"] .auth-gate-close,
html[data-theme="dark"] .back-btn,
html[data-theme="dark"] .tool-btn,
html[data-theme="dark"] .settings-login,
html[data-theme="dark"] .auth-code-btn,
html[data-theme="dark"] .auth-gate-code-btn,
html[data-theme="dark"] .favorite-btn,
html[data-theme="dark"] .share-btn,
html[data-theme="dark"] .comment-tool {
  border-color: rgba(148, 163, 184, .18) !important;
  background: rgba(27, 41, 64, .92) !important;
  color: #dbeafe !important;
}

html[data-theme="dark"] .primary-btn,
html[data-theme="dark"] .login-btn,
html[data-theme="dark"] .auth-submit,
html[data-theme="dark"] .auth-gate-submit,
html[data-theme="dark"] .settings-save-profile,
html[data-theme="dark"] .comment-send,
html[data-theme="dark"] .live-comment-send {
  background: linear-gradient(135deg, #2d73e6, #67a9ff) !important;
  color: #fff !important;
  box-shadow: 0 12px 26px rgba(45, 115, 230, .26) !important;
}

html[data-theme="dark"] .bottom-nav,
html[data-theme="dark"] .comment-bottom-bar,
html[data-theme="dark"] .fixed-bottom-bar {
  border-color: rgba(148, 163, 184, .16) !important;
  background: rgba(13, 23, 38, .94) !important;
  backdrop-filter: blur(18px);
}

html[data-theme="dark"] .comment-card,
html[data-theme="dark"] .live-comment-card,
html[data-theme="dark"] .comment-bubble {
  border-color: rgba(148, 163, 184, .16) !important;
  background: rgba(27, 41, 64, .88) !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .16) !important;
}

html[data-theme="dark"] .comment-avatar {
  border-color: rgba(255, 255, 255, .18) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18) !important;
}

html[data-theme="dark"] .settings-logout-text,
html[data-theme="dark"] .danger-btn,
html[data-theme="dark"] .logout-btn {
  background: rgba(251, 113, 133, .10) !important;
  color: #ffb4c0 !important;
  border-color: rgba(251, 113, 133, .18) !important;
}

/* Comment drawer v2: natural mobile bottom sheet in both appearances */
.comment-drawer-mask {
  background: rgba(8, 18, 34, .42) !important;
  backdrop-filter: blur(8px) !important;
}

.comment-drawer-sheet {
  width: min(100%, 580px) !important;
  height: min(74vh, 700px) !important;
  border: 1px solid rgba(223, 231, 242, .86) !important;
  border-bottom: 0 !important;
  border-radius: 26px 26px 0 0 !important;
  background: #fff !important;
  box-shadow: 0 -18px 46px rgba(23, 36, 58, .16) !important;
}

.comment-drawer-head {
  min-height: 62px !important;
  padding: 0 20px 0 22px !important;
}

.comment-drawer-head h2 {
  margin: 0 !important;
  color: #142033 !important;
  font-size: 20px !important;
  letter-spacing: 0 !important;
}

.comment-drawer-head button {
  width: 42px !important;
  height: 42px !important;
  border: 1px solid rgba(143, 153, 169, .28) !important;
  background: rgba(247, 249, 252, .9) !important;
  color: #7b8492 !important;
  box-shadow: none !important;
}

.comment-drawer-tools {
  padding: 0 22px 16px !important;
  color: #7c8798 !important;
  font-size: 14px !important;
  font-weight: 800 !important;
}

.comment-sort {
  gap: 2px !important;
  padding: 3px !important;
  border: 1px solid rgba(224, 230, 240, .95) !important;
  background: #f4f7fb !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9) !important;
}

.comment-sort button {
  appearance: none !important;
  -webkit-appearance: none !important;
  min-width: 66px !important;
  height: 30px !important;
  padding: 0 12px !important;
  border: 0 !important;
  outline: 0 !important;
  color: #717b8d !important;
  font-size: 13px !important;
  font-weight: 850 !important;
  box-shadow: none !important;
}

.comment-sort button.active {
  background: #fff !important;
  color: #1267ff !important;
  box-shadow: 0 3px 10px rgba(40, 70, 120, .08) !important;
}

.comment-sort button:focus,
.comment-sort button:focus-visible,
.comment-sort button:active {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

.comment-sort button.active:focus,
.comment-sort button.active:focus-visible,
.comment-sort button.active:active {
  box-shadow: 0 3px 10px rgba(40, 70, 120, .08) !important;
}

.comment-drawer .comment-list {
  padding: 4px 22px 18px !important;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%) !important;
}

.comment-drawer .comment-empty {
  min-height: 100% !important;
  padding: 62px 0 80px !important;
  color: #9aa6b6 !important;
  font-size: 15px !important;
  background: transparent !important;
}

.comment-drawer .comment-empty::before {
  width: 96px !important;
  height: 96px !important;
  margin-bottom: 16px !important;
  background:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 64 64' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23c2cad6' d='M18 18h28a5 5 0 0 1 5 5v16a5 5 0 0 1-5 5H31l-10 7v-7h-3a5 5 0 0 1-5-5V23a5 5 0 0 1 5-5Zm3 9v4h22v-4H21Zm0 9v4h14v-4H21Z'/%3E%3C/svg%3E") center / 46px 46px no-repeat,
    linear-gradient(180deg, #f5f7fa, #edf2f7) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .78) !important;
  opacity: .95 !important;
}

.comment-drawer .comment-form {
  grid-template-columns: minmax(0, 1fr) auto !important;
  gap: 10px !important;
  padding: 12px max(18px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-right)) !important;
  border-top: 1px solid rgba(224, 231, 242, .86) !important;
  background: rgba(255, 255, 255, .96) !important;
  box-shadow: 0 -10px 24px rgba(15, 23, 42, .06) !important;
  backdrop-filter: blur(16px) !important;
}

.comment-drawer .comment-form textarea {
  height: 44px !important;
  min-height: 44px !important;
  max-height: 92px !important;
  padding: 11px 16px !important;
  border: 1px solid rgba(218, 226, 238, .96) !important;
  border-radius: 999px !important;
  background: #f5f7fa !important;
  color: #17243a !important;
  font-size: 15px !important;
  line-height: 20px !important;
}

.comment-drawer .comment-form textarea:focus {
  border-color: rgba(18, 103, 255, .36) !important;
  background: #fff !important;
  box-shadow: 0 0 0 4px rgba(18, 103, 255, .08) !important;
}

.comment-drawer .comment-actions button {
  height: 44px !important;
  min-width: 72px !important;
  padding: 0 18px !important;
  border-radius: 999px !important;
  background: #8db7ff !important;
  color: #fff !important;
  font-size: 15px !important;
  box-shadow: none !important;
}

.comment-drawer .comment-form textarea:not(:placeholder-shown) + .comment-actions button {
  background: linear-gradient(135deg, #1267ff, #6fa8ff) !important;
  box-shadow: 0 8px 18px rgba(18, 103, 255, .18) !important;
}

html[data-theme="dark"] .comment-drawer-mask {
  background: rgba(0, 6, 14, .52) !important;
  backdrop-filter: blur(10px) !important;
}

html[data-theme="dark"] .comment-drawer-sheet {
  border-color: rgba(136, 154, 178, .22) !important;
  background: #111c2d !important;
  box-shadow: 0 -18px 48px rgba(0, 0, 0, .36) !important;
}

html[data-theme="dark"] .comment-drawer-head h2 {
  color: #f4f8ff !important;
}

html[data-theme="dark"] .comment-drawer-head button {
  border-color: rgba(170, 188, 214, .22) !important;
  background: rgba(31, 44, 65, .82) !important;
  color: #aebbd0 !important;
}

html[data-theme="dark"] .comment-drawer-tools {
  color: #a8b5c8 !important;
}

html[data-theme="dark"] .comment-sort {
  border-color: rgba(148, 163, 184, .16) !important;
  background: rgba(12, 23, 38, .72) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04) !important;
}

html[data-theme="dark"] .comment-sort button {
  border: 0 !important;
  outline: 0 !important;
  color: #9fadbf !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .comment-sort button.active {
  background: rgba(79, 140, 230, .22) !important;
  color: #d9e8ff !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .comment-drawer .comment-list {
  background: linear-gradient(180deg, #111c2d 0%, #162236 100%) !important;
}

html[data-theme="dark"] .comment-drawer .comment-empty {
  color: #94a4bb !important;
}

html[data-theme="dark"] .comment-drawer .comment-empty::before {
  background:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 64 64' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%237f91aa' d='M18 18h28a5 5 0 0 1 5 5v16a5 5 0 0 1-5 5H31l-10 7v-7h-3a5 5 0 0 1-5-5V23a5 5 0 0 1 5-5Zm3 9v4h22v-4H21Zm0 9v4h14v-4H21Z'/%3E%3C/svg%3E") center / 46px 46px no-repeat,
    linear-gradient(180deg, rgba(225, 235, 247, .10), rgba(225, 235, 247, .06)) !important;
  box-shadow: none !important;
  opacity: 1 !important;
}

html[data-theme="dark"] .comment-drawer .comment-form {
  border-top-color: rgba(148, 163, 184, .18) !important;
  background: rgba(13, 23, 38, .96) !important;
  box-shadow: 0 -10px 24px rgba(0, 0, 0, .22) !important;
}

html[data-theme="dark"] .comment-drawer .comment-form textarea {
  border-color: rgba(148, 163, 184, .20) !important;
  background: rgba(21, 33, 52, .96) !important;
  color: #f4f8ff !important;
}

html[data-theme="dark"] .comment-drawer .comment-form textarea:focus {
  border-color: rgba(110, 169, 255, .48) !important;
  background: rgba(24, 39, 61, .98) !important;
  box-shadow: 0 0 0 4px rgba(110, 169, 255, .10) !important;
}

html[data-theme="dark"] .comment-drawer .comment-actions button {
  background: #4f8ce6 !important;
  color: #fff !important;
}

html[data-theme="dark"] .comment-bottom-input,
html[data-theme="dark"] .live-comment-form textarea {
  border: 1px solid rgba(129, 164, 207, .24) !important;
  background: rgba(21, 33, 52, .92) !important;
  color: #dce9f8 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04) !important;
}

html[data-theme="dark"] .comment-bottom-input {
  display: flex !important;
  align-items: center !important;
}

/* Mobile keyboard guard: keep drawers and fixed input bars inside the visible viewport */
:root {
  --qc-keyboard-inset: 0px;
  --qc-visual-vh: 100vh;
  --qc-visual-offset-top: 0px;
}

.comment-drawer {
  top: var(--qc-visual-offset-top) !important;
  bottom: auto !important;
  height: var(--qc-visual-vh) !important;
}

.comment-drawer:not([hidden]) ~ .float-contact {
  display: none !important;
}

.comment-drawer-sheet {
  max-height: calc(var(--qc-visual-vh) - 8px) !important;
}

html.qc-keyboard-open .comment-drawer-sheet {
  height: min(calc(var(--qc-visual-vh) - 6px), 700px) !important;
  border-radius: 22px 22px 0 0 !important;
}

html.qc-keyboard-open .comment-drawer-head {
  min-height: 54px !important;
}

html.qc-keyboard-open .comment-drawer-tools {
  padding-bottom: 10px !important;
}

html.qc-keyboard-open .comment-drawer .comment-empty {
  padding-top: 36px !important;
  padding-bottom: 48px !important;
}

html.qc-keyboard-open .comment-drawer .comment-empty::before {
  width: 78px !important;
  height: 78px !important;
  background-size: 38px 38px, auto !important;
}

.comment-bottom-bar {
  transform: translateX(-50%) translateY(calc(-1 * var(--qc-keyboard-inset))) !important;
  transition: transform .2s ease, padding-bottom .2s ease !important;
}

.live-comment-form {
  transform: translateY(calc(-1 * var(--qc-keyboard-inset))) !important;
  transition: transform .2s ease, padding-bottom .2s ease !important;
}

html.qc-keyboard-open .comment-bottom-bar,
html.qc-keyboard-open .live-comment-form {
  padding-bottom: 10px !important;
}

.auth-modal,
.auth-gate-modal {
  top: var(--qc-visual-offset-top, 0px) !important;
  bottom: auto !important;
  height: var(--qc-visual-vh, 100vh) !important;
  min-height: var(--qc-visual-vh, 100vh) !important;
}

html.qc-keyboard-open .auth-panel,
html.qc-keyboard-open .auth-gate-panel {
  max-height: calc(var(--qc-visual-vh, 100vh) - 28px) !important;
  scroll-padding-bottom: 96px !important;
}

/* Article/live comment layout guard: keep inline empty states full-width and natural */
.comments-panel .comment-list {
  width: 100% !important;
  box-sizing: border-box !important;
}

.comments-panel .comment-empty {
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  display: grid !important;
  place-items: center !important;
  align-self: stretch !important;
  justify-self: stretch !important;
  min-height: 220px !important;
  padding: 34px 16px !important;
  border: 0 !important;
  border-radius: 16px !important;
  background: rgba(244, 248, 253, .72) !important;
  color: #96a3b5 !important;
  text-align: center !important;
}

.page.is-live-detail .comments-panel .comment-list {
  align-items: stretch !important;
}

.page.is-live-detail .comments-panel .comment-empty {
  min-height: 230px !important;
  flex: 1 1 auto !important;
}

html[data-theme="dark"] .comments-panel .comment-empty {
  background: rgba(255, 255, 255, .045) !important;
  color: #91a2ba !important;
}

/* Comment send state: disabled until trimmed text exists */
.comment-form .comment-actions button,
.live-comment-form .comment-actions button,
.live-comment-form > .live-submit-button,
.comment-drawer .comment-actions button {
  cursor: pointer !important;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, opacity .18s ease, transform .18s ease !important;
}

.comment-form .comment-actions button:disabled,
.live-comment-form .comment-actions button:disabled,
.live-comment-form > .live-submit-button:disabled,
.comment-drawer .comment-actions button:disabled,
.comment-form:not(.has-comment-text) .comment-actions button,
.live-comment-form:not(.has-comment-text) .comment-actions button,
.live-comment-form:not(.has-comment-text) > .live-submit-button,
.comment-drawer .comment-form:not(.has-comment-text) .comment-actions button {
  background: #b9d3ff !important;
  color: rgba(255, 255, 255, .86) !important;
  box-shadow: none !important;
  cursor: default !important;
  opacity: .78 !important;
  pointer-events: none !important;
}

.comment-form.has-comment-text .comment-actions button:not(:disabled),
.live-comment-form.has-comment-text .comment-actions button:not(:disabled),
.live-comment-form.has-comment-text > .live-submit-button:not(:disabled),
.comment-drawer .comment-form.has-comment-text .comment-actions button:not(:disabled) {
  background: linear-gradient(135deg, #1267ff, #6fa8ff) !important;
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(18, 103, 255, .18) !important;
}

html[data-theme="dark"] .comment-form .comment-actions button:disabled,
html[data-theme="dark"] .live-comment-form .comment-actions button:disabled,
html[data-theme="dark"] .live-comment-form > .live-submit-button:disabled,
html[data-theme="dark"] .comment-drawer .comment-actions button:disabled,
html[data-theme="dark"] .comment-form:not(.has-comment-text) .comment-actions button,
html[data-theme="dark"] .live-comment-form:not(.has-comment-text) .comment-actions button,
html[data-theme="dark"] .live-comment-form:not(.has-comment-text) > .live-submit-button,
html[data-theme="dark"] .comment-drawer .comment-form:not(.has-comment-text) .comment-actions button {
  background: rgba(107, 146, 205, .42) !important;
  color: rgba(219, 232, 250, .72) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .comment-form.has-comment-text .comment-actions button:not(:disabled),
html[data-theme="dark"] .live-comment-form.has-comment-text .comment-actions button:not(:disabled),
html[data-theme="dark"] .live-comment-form.has-comment-text > .live-submit-button:not(:disabled),
html[data-theme="dark"] .comment-drawer .comment-form.has-comment-text .comment-actions button:not(:disabled) {
  background: linear-gradient(135deg, #2d73e6, #67a9ff) !important;
  color: #fff !important;
  box-shadow: 0 12px 26px rgba(45, 115, 230, .26) !important;
}

/* Final live comment frame guard: prevent mobile horizontal overflow after theme overrides. */
.page.is-live-detail .comments-panel,
.page.is-live-detail .comments-panel .comment-list,
.page.is-live-detail .comments-panel .comment-empty {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.page.is-live-detail .comments-panel {
  overflow: hidden !important;
}

.page.is-live-detail .live-comment-form {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 8px !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-right: 0 !important;
  margin-left: 0 !important;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom)) !important;
  box-sizing: border-box !important;
  border-top: 1px solid rgba(130, 158, 196, .16) !important;
  border-radius: 0 0 18px 18px !important;
}

.page.is-live-detail .live-comment-form textarea {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  box-sizing: border-box !important;
}

.page.is-live-detail .live-comment-form .comment-actions {
  display: flex !important;
  min-width: 0 !important;
}

.page.is-live-detail .live-comment-form .comment-actions button {
  min-width: 54px !important;
  height: 42px !important;
  padding: 0 12px !important;
  white-space: nowrap !important;
}

html[data-theme="dark"] .page.is-live-detail .live-comment-form {
  border-top-color: rgba(126, 157, 194, .22) !important;
}

.page.is-live-detail .live-comment-form {
  display: block !important;
  position: relative !important;
  width: min(92dvw, 360px) !important;
  max-width: min(92dvw, 360px) !important;
  margin-right: auto !important;
  margin-left: auto !important;
  justify-self: center !important;
}

.page.is-live-detail .live-comment-form textarea {
  padding-right: 78px !important;
}

.page.is-live-detail .live-comment-form .comment-actions {
  position: absolute !important;
  top: 50% !important;
  right: 14px !important;
  left: auto !important;
  transform: translateY(-50%) !important;
  z-index: 2 !important;
}

@media (max-width: 520px) {
  .page.is-live-detail .live-comment-form {
    width: calc(100dvw - 32px) !important;
    max-width: calc(100dvw - 32px) !important;
    justify-self: center !important;
    margin-right: auto !important;
    margin-left: auto !important;
  }
}

@media (max-width: 520px) {
  .page.is-live-detail .live-comment-form {
    display: block !important;
    position: relative !important;
  }

  .page.is-live-detail .live-comment-form textarea {
    padding-right: 76px !important;
  }

  .page.is-live-detail .live-comment-form .comment-actions {
    position: absolute !important;
    top: 50% !important;
    right: auto !important;
    left: calc(100dvw - 102px) !important;
    transform: translateY(-50%) !important;
    z-index: 2 !important;
  }
}

/* Live/replay pages use a fixed input rail like livestream products. */
.page.is-live-detail {
  padding-bottom: 76px !important;
}

.page.is-live-detail .live-comment-form {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  bottom: 0 !important;
  z-index: 80 !important;
  display: grid !important;
  grid-template-columns: minmax(0, calc(100% - 68px)) 58px !important;
  gap: 10px !important;
  width: min(calc(100vw - 56px), 424px) !important;
  max-width: calc(100vw - 56px) !important;
  margin: 0 !important;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom)) !important;
  transform: translateX(-50%) translateY(calc(-1 * var(--qc-keyboard-inset))) !important;
  border-top: 1px solid rgba(130, 158, 196, .16) !important;
  border-radius: 0 !important;
  background: rgba(255, 255, 255, .96) !important;
  box-shadow: 0 -12px 28px rgba(15, 23, 42, .10) !important;
  backdrop-filter: blur(16px) !important;
}

.page.is-live-detail .live-comment-form .comment-actions,
.page.is-live-detail .live-comment-form .live-submit-button {
  position: static !important;
  inset: auto !important;
  transform: none !important;
}

.page.is-live-detail .live-comment-form .live-submit-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 58px !important;
  height: 42px !important;
  padding: 0 14px !important;
  border: 0 !important;
  border-radius: 999px !important;
  font-size: 14px !important;
  font-weight: 900 !important;
  white-space: nowrap !important;
}

.page.is-live-detail .live-comment-form textarea {
  padding-right: 14px !important;
}

html[data-theme="dark"] .page.is-live-detail .live-comment-form {
  border-top-color: rgba(126, 157, 194, .22) !important;
  background: rgba(13, 23, 38, .96) !important;
  box-shadow: 0 -14px 30px rgba(0, 0, 0, .26) !important;
}

html,
body,
.page.is-live-detail,
.page.is-live-detail .article-hero,
.page.is-live-detail .media-stage-shell,
.page.is-live-detail .detail-tabs,
.page.is-live-detail .article-panel,
.page.is-live-detail .comments-panel,
.page.is-live-detail .contact {
  max-width: 100vw !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

.page.is-live-detail .article-hero h1,
.page.is-live-detail .article-hero p {
  max-width: 100% !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}
