:root {
  --theme-picker-border: rgba(128, 151, 184, .24);
  --theme-picker-surface: rgba(18, 27, 39, .72);
  --theme-picker-text: #f4f7fb;
  --theme-picker-muted: #91a0b5;
}

/* Theme selection stays compact and uses flat swatches instead of decorative imagery. */
.theme-picker {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.theme-picker legend {
  margin-bottom: 9px;
  font-size: 1rem;
  font-weight: 700;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.theme-option {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  min-height: 54px;
  padding: 9px 11px;
  border: 1px solid var(--theme-picker-border);
  border-radius: 11px;
  background: var(--theme-picker-surface);
  color: var(--theme-picker-text);
  cursor: pointer;
}

.theme-option:hover {
  border-color: rgba(93, 214, 177, .58);
}

.theme-option:has(input:checked) {
  border-color: #5dd6b1;
  box-shadow: inset 0 0 0 1px rgba(93, 214, 177, .24);
}

.theme-option:has(input:focus-visible) {
  outline: 2px solid #5dd6b1;
  outline-offset: 2px;
}

.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.theme-option-copy strong {
  font-size: .92rem;
}

.theme-option-copy small {
  overflow: hidden;
  color: var(--theme-picker-muted);
  font-size: .76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-swatch {
  display: block;
  box-sizing: border-box;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(128, 151, 184, .38);
  border-radius: 9px;
}

.theme-swatch.system { background: linear-gradient(90deg, #151b25 0 50%, #f4f6f8 50%); }
.theme-swatch.dark { background: #151b25; }
.theme-swatch.light { background: #f4f6f8; }
.theme-swatch.mist { background: linear-gradient(145deg, #f2f8f6, #cfe5df); }

html[data-theme="light"] {
  --app-page: #f3f5f7;
  --app-page-accent: #e8edf1;
  --app-surface: rgba(255, 255, 255, .96);
  --app-surface-raised: #ffffff;
  --app-surface-soft: #edf1f4;
  --app-card: #ffffff;
  --app-card-live: #f4fbf8;
  --app-border: #d7dee5;
  --app-border-strong: #b9c4cf;
  --app-text: #17212b;
  --app-muted: #5f6d7a;
  --app-faint: #7b8793;
  --app-accent: #238e72;
  --app-accent-soft: #dcefe9;
  --app-live: #148666;
  --app-danger: #ba3e49;
  --app-shadow: rgba(32, 46, 58, .13);
  --theme-picker-border: #d7dee5;
  --theme-picker-surface: #ffffff;
  --theme-picker-text: #17212b;
  --theme-picker-muted: #667482;
}

html[data-theme="mist"] {
  --app-page: #e5efec;
  --app-page-accent: #d6e6e1;
  --app-surface: rgba(246, 250, 249, .92);
  --app-surface-raised: #f5faf8;
  --app-surface-soft: rgba(222, 237, 232, .76);
  --app-card: rgba(247, 251, 250, .88);
  --app-card-live: rgba(235, 247, 243, .94);
  --app-border: #bfd2cd;
  --app-border-strong: #94b8ae;
  --app-text: #17332f;
  --app-muted: #526e68;
  --app-faint: #6f8983;
  --app-accent: #2c9c7f;
  --app-accent-soft: #d4ebe4;
  --app-live: #128362;
  --app-danger: #b64a55;
  --app-shadow: rgba(45, 78, 70, .13);
  --theme-picker-border: #bfd2cd;
  --theme-picker-surface: rgba(247, 251, 250, .82);
  --theme-picker-text: #17332f;
  --theme-picker-muted: #5c7771;
}

html[data-theme="light"] body,
html[data-theme="mist"] body {
  color: var(--app-text);
  background: linear-gradient(145deg, var(--app-page) 0%, var(--app-page-accent) 100%);
}

html[data-theme="mist"] body {
  background:
    radial-gradient(circle at 18% 5%, rgba(255, 255, 255, .48) 0, rgba(255, 255, 255, 0) 42%),
    linear-gradient(145deg, #e8f1ee 0%, #dfece8 56%, #d7e6e1 100%);
}

html[data-theme="light"] .widget,
html[data-theme="mist"] .widget {
  color: var(--app-text);
  border-color: var(--app-border);
  background: var(--app-surface);
  box-shadow: 0 20px 55px var(--app-shadow);
}

html[data-theme="light"] .titlebar,
html[data-theme="light"] .status-summary,
html[data-theme="light"] .view-tabs,
html[data-theme="light"] .tab-toolbar,
html[data-theme="light"] .footer-actions,
html[data-theme="mist"] .titlebar,
html[data-theme="mist"] .status-summary,
html[data-theme="mist"] .view-tabs,
html[data-theme="mist"] .tab-toolbar,
html[data-theme="mist"] .footer-actions {
  border-color: var(--app-border);
  background-color: transparent;
}

html[data-theme="light"] .streamer-card,
html[data-theme="mist"] .streamer-card {
  color: var(--app-text);
  border-color: var(--app-border);
  background: var(--app-card);
  box-shadow: 0 5px 17px rgba(42, 67, 62, .055);
}

html[data-theme="light"] .streamer-card.is-live,
html[data-theme="mist"] .streamer-card.is-live {
  border-color: var(--app-border-strong);
  background: var(--app-card-live);
  box-shadow: inset 0 0 0 1px rgba(44, 156, 127, .08), 0 7px 20px rgba(35, 107, 88, .08);
}

html[data-theme="light"] .brand h1,
html[data-theme="light"] .streamer-copy > strong,
html[data-theme="light"] dialog h2,
html[data-theme="light"] dialog strong,
html[data-theme="light"] dialog legend,
html[data-theme="mist"] .brand h1,
html[data-theme="mist"] .streamer-copy > strong,
html[data-theme="mist"] dialog h2,
html[data-theme="mist"] dialog strong,
html[data-theme="mist"] dialog legend {
  color: var(--app-text);
}

html[data-theme="light"] .widget .titlebar p,
html[data-theme="light"] .widget .tab-toolbar p,
html[data-theme="light"] .widget #updatedAt,
html[data-theme="light"] .streamer-copy .status-text,
html[data-theme="light"] .form-note,
html[data-theme="light"] .share-note,
html[data-theme="light"] .settings-footnote,
html[data-theme="light"] .settings-intro,
html[data-theme="light"] dialog small,
html[data-theme="mist"] .widget .titlebar p,
html[data-theme="mist"] .widget .tab-toolbar p,
html[data-theme="mist"] .widget #updatedAt,
html[data-theme="mist"] .streamer-copy .status-text,
html[data-theme="mist"] .form-note,
html[data-theme="mist"] .share-note,
html[data-theme="mist"] .settings-footnote,
html[data-theme="mist"] .settings-intro,
html[data-theme="mist"] dialog small {
  color: var(--app-muted);
}

html[data-theme="light"] .streamer-main > .elapsed-time,
html[data-theme="mist"] .streamer-main > .elapsed-time {
  color: var(--app-live);
}

/* Keep the platform palette soft on bright themes without washing out the labels. */
html[data-theme="light"] .supported-sites > .yt,
html[data-theme="mist"] .supported-sites > .yt { color: #c96f78; }
html[data-theme="light"] .supported-sites > .tw,
html[data-theme="mist"] .supported-sites > .tw { color: #766cc0; }
html[data-theme="light"] .supported-sites > .kc,
html[data-theme="mist"] .supported-sites > .kc { color: #4f914e; }
html[data-theme="light"] .supported-sites > .tc,
html[data-theme="mist"] .supported-sites > .tc { color: #4289a7; }

html[data-theme="light"] .brand-mark i,
html[data-theme="light"] .live-pulse,
html[data-theme="mist"] .brand-mark i,
html[data-theme="mist"] .live-pulse {
  background: var(--app-accent);
  box-shadow: none;
}

html[data-theme="light"] .widget .brand-mark,
html[data-theme="mist"] .widget .brand-mark {
  border-color: var(--app-border-strong);
  background: var(--app-accent-soft);
}

html[data-theme="light"] .widget .brand-mark .signal,
html[data-theme="mist"] .widget .brand-mark .signal {
  stroke: var(--app-accent);
}

html[data-theme="light"] .widget .brand-mark .lamp,
html[data-theme="mist"] .widget .brand-mark .lamp {
  fill: var(--app-accent);
}

html[data-theme="light"] .connection-alert,
html[data-theme="mist"] .connection-alert {
  color: var(--app-danger);
  border-color: color-mix(in srgb, var(--app-danger) 38%, transparent);
  background: color-mix(in srgb, var(--app-danger) 9%, transparent);
}

html[data-theme="light"] .view-tab,
html[data-theme="light"] .sort-mode,
html[data-theme="light"] .settings-tab,
html[data-theme="mist"] .view-tab,
html[data-theme="mist"] .sort-mode,
html[data-theme="mist"] .settings-tab {
  color: var(--app-muted);
  border-color: transparent;
  background: transparent;
}

html[data-theme="light"] .view-tab.active,
html[data-theme="light"] .sort-mode.active,
html[data-theme="light"] .settings-tab.active,
html[data-theme="mist"] .view-tab.active,
html[data-theme="mist"] .sort-mode.active,
html[data-theme="mist"] .settings-tab.active {
  color: var(--app-text);
  border-color: var(--app-border);
  background: var(--app-accent-soft);
}

html[data-theme="light"] .primary-button,
html[data-theme="mist"] .primary-button {
  color: #082b23;
  border-color: transparent;
  background: #65ceb0;
  box-shadow: none;
}

html[data-theme="light"] .primary-button:hover,
html[data-theme="mist"] .primary-button:hover {
  background: #54bea1;
}

html[data-theme="light"] .secondary-button,
html[data-theme="light"] .feedback-button,
html[data-theme="light"] .icon-button,
html[data-theme="light"] .notify-button,
html[data-theme="light"] .pin-button,
html[data-theme="mist"] .secondary-button,
html[data-theme="mist"] .feedback-button,
html[data-theme="mist"] .icon-button,
html[data-theme="mist"] .notify-button,
html[data-theme="mist"] .pin-button {
  color: var(--app-muted);
  border-color: var(--app-border);
  background: var(--app-surface-soft);
  box-shadow: none;
}

html[data-theme="light"] .notify-button[aria-pressed="true"],
html[data-theme="mist"] .notify-button[aria-pressed="true"] {
  color: var(--app-live);
  border-color: var(--app-border-strong);
  background: var(--app-accent-soft);
}

html[data-theme="light"] .pin-button[aria-pressed="true"],
html[data-theme="mist"] .pin-button[aria-pressed="true"] {
  color: #9b741f;
  border-color: #d8c38b;
  background: #f3ead2;
}

html[data-theme="light"] .notify-button svg,
html[data-theme="light"] .pin-button svg,
html[data-theme="light"] .icon-button svg,
html[data-theme="mist"] .notify-button svg,
html[data-theme="mist"] .pin-button svg,
html[data-theme="mist"] .icon-button svg {
  stroke: currentColor;
}

html[data-theme="light"] .avatar,
html[data-theme="mist"] .avatar {
  color: var(--app-text);
  border-color: var(--app-border);
  background: var(--app-surface-soft);
}

html[data-theme="light"] .avatar i,
html[data-theme="mist"] .avatar i {
  border-color: var(--app-card);
  background: var(--app-faint);
}

html[data-theme="light"] .streamer-card.is-live .avatar i,
html[data-theme="mist"] .streamer-card.is-live .avatar i {
  background: var(--app-live);
}

html[data-theme="light"] .platform-link:not(.online),
html[data-theme="light"] .add-platform-button,
html[data-theme="mist"] .platform-link:not(.online),
html[data-theme="mist"] .add-platform-button {
  color: var(--app-faint);
  border-color: var(--app-border);
  background: var(--app-surface-soft);
}

html[data-theme="light"] dialog,
html[data-theme="mist"] dialog {
  color: var(--app-text);
  border-color: var(--app-border);
  background: var(--app-surface-raised);
  box-shadow: 0 24px 70px var(--app-shadow);
}

html[data-theme="light"] dialog::backdrop,
html[data-theme="mist"] dialog::backdrop {
  background: rgba(28, 43, 47, .38);
}

html[data-theme="light"] dialog input,
html[data-theme="light"] dialog textarea,
html[data-theme="mist"] dialog input,
html[data-theme="mist"] dialog textarea {
  color: var(--app-text);
  border-color: var(--app-border);
  background: var(--app-surface-raised);
}

html[data-theme="light"] dialog input::placeholder,
html[data-theme="light"] dialog textarea::placeholder,
html[data-theme="mist"] dialog input::placeholder,
html[data-theme="mist"] dialog textarea::placeholder {
  color: var(--app-faint);
}

html[data-theme="light"] .quick-site-panel,
html[data-theme="light"] .sync-box,
html[data-theme="light"] .install-box,
html[data-theme="light"] .uninstall-guide,
html[data-theme="light"] .beta-box,
html[data-theme="light"] .developer-box,
html[data-theme="light"] .notification-modes,
html[data-theme="light"] .feedback-types,
html[data-theme="mist"] .quick-site-panel,
html[data-theme="mist"] .sync-box,
html[data-theme="mist"] .install-box,
html[data-theme="mist"] .uninstall-guide,
html[data-theme="mist"] .beta-box,
html[data-theme="mist"] .developer-box,
html[data-theme="mist"] .notification-modes,
html[data-theme="mist"] .feedback-types {
  color: var(--app-text);
  border-color: var(--app-border);
  background: var(--app-surface-soft);
}

html[data-theme="light"] .uninstall-guide summary,
html[data-theme="mist"] .uninstall-guide summary,
html[data-theme="light"] .sync-conflict-lead,
html[data-theme="mist"] .sync-conflict-lead,
html[data-theme="light"] .sync-overwrite-confirm h3,
html[data-theme="mist"] .sync-overwrite-confirm h3 {
  color: var(--app-text);
}

html[data-theme="light"] .uninstall-guide p,
html[data-theme="light"] .uninstall-guide small,
html[data-theme="mist"] .uninstall-guide p,
html[data-theme="mist"] .uninstall-guide small,
html[data-theme="light"] .sync-conflict-note,
html[data-theme="light"] .sync-overwrite-confirm p,
html[data-theme="mist"] .sync-conflict-note,
html[data-theme="mist"] .sync-overwrite-confirm p {
  color: var(--app-muted);
}

html[data-theme="light"] .uninstall-guide code,
html[data-theme="mist"] .uninstall-guide code {
  border-color: var(--app-border);
  background: var(--app-surface-raised);
}

html[data-theme="light"] .sync-compare-card,
html[data-theme="mist"] .sync-compare-card {
  color: var(--app-text);
  border-color: var(--app-border);
  background: var(--app-surface-soft);
}

html[data-theme="light"] .sync-compare-card.recommended,
html[data-theme="mist"] .sync-compare-card.recommended {
  border-color: var(--app-border-strong);
  background: var(--app-accent-soft);
}

html[data-theme="light"] .sync-compare-card strong,
html[data-theme="mist"] .sync-compare-card strong {
  color: var(--app-text);
}

html[data-theme="light"] .sync-source-label,
html[data-theme="mist"] .sync-source-label {
  color: var(--app-accent);
}

html[data-theme="light"] .sync-compare-card small,
html[data-theme="light"] .sync-compare-card em,
html[data-theme="mist"] .sync-compare-card small,
html[data-theme="mist"] .sync-compare-card em {
  color: var(--app-muted);
}

html[data-theme="light"] .warning-mark,
html[data-theme="mist"] .warning-mark {
  color: var(--app-danger);
  border-color: color-mix(in srgb, var(--app-danger) 45%, transparent);
  background: color-mix(in srgb, var(--app-danger) 10%, transparent);
}

html[data-theme="light"] .notification-modes label,
html[data-theme="light"] .feedback-types label,
html[data-theme="mist"] .notification-modes label,
html[data-theme="mist"] .feedback-types label {
  border-color: var(--app-border);
  background: var(--app-surface-raised);
}

html[data-theme="light"] .notification-modes label:has(input:checked),
html[data-theme="light"] .feedback-types label:has(input:checked),
html[data-theme="mist"] .notification-modes label:has(input:checked),
html[data-theme="mist"] .feedback-types label:has(input:checked) {
  border-color: var(--app-border-strong);
  background: var(--app-accent-soft);
}

html[data-theme="light"] .dialog-inline-message,
html[data-theme="mist"] .dialog-inline-message {
  color: #7d2630;
  border-color: #dda8ad;
  background: #f8e7e9;
  box-shadow: none;
}

html[data-theme="light"] .site-dialog .streamer-delete-button,
html[data-theme="mist"] .site-dialog .streamer-delete-button {
  color: var(--app-danger);
}

html[data-theme="light"] .toast,
html[data-theme="mist"] .toast {
  color: var(--app-text);
  border-color: var(--app-border-strong);
  background: var(--app-surface-raised);
  box-shadow: 0 12px 36px var(--app-shadow);
}

html[data-theme="light"] .empty-state,
html[data-theme="mist"] .empty-state {
  color: var(--app-muted);
  border-color: var(--app-border);
  background: var(--app-surface-soft);
}

html[data-theme="light"] .duplicate-choice span,
html[data-theme="mist"] .duplicate-choice span {
  color: var(--app-muted);
}

html[data-theme="light"] *,
html[data-theme="mist"] * {
  scrollbar-color: var(--app-border-strong) transparent;
}

@media (max-width: 560px) {
  .theme-option {
    grid-template-columns: 26px minmax(0, 1fr);
    padding-inline: 9px;
  }

  .theme-swatch {
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }
}
