:root {
  color-scheme: light;
  /* Demo chrome. The light values are the demo's original colours, unchanged. */
  --bg: #eef1f5;
  --frame-bg: #fff;
  --frame-border: #d8dce3;
  --frame-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  --titlebar-bg: #2a2e37;
  --titlebar-text: #b7bdc9;
  --toolbar-bg: #f4f5f7;
  --toolbar-border: #e1e4ea;
  --nav-icon: #9aa1ad;
  --url-bg: #fff;
  --url-border: #dde1e7;
  --url-text: #4b5563;
  --toolbar-btn-hover: #e5e7eb;
  --panel-border: #d8dce3;
  --panel-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
  --note-text: #5b6472;
  /* Theme switch */
  --muted: rgba(213, 218, 226, 0.6);
  --fg: #1c1e26;
  --muted-fg: #5b6472;
  --ring: rgba(15, 118, 110, 0.8); /* 0.6 only reaches 2.4:1 on the light page; 0.8 clears 3:1 */
}

/* Dark theme. Only the demo chrome and the popup panel change: the mock article inside
   the browser window is a stand-in third-party page and stays a light page in both
   themes, because its first planted finding is white text on a white background. */
:root.dark {
  color-scheme: dark;
  --bg: #0b0f14;
  --frame-bg: #1a1d23;
  --frame-border: #2c313a;
  --frame-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  --titlebar-bg: #111418;
  --titlebar-text: #9aa3b0;
  --toolbar-bg: #22262d;
  --toolbar-border: #30353e;
  --nav-icon: #7d8592;
  --url-bg: #15181d;
  --url-border: #3a404a;
  --url-text: #c9ced6;
  --toolbar-btn-hover: #343a44;
  --panel-border: #3a404a;
  --panel-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  --note-text: #9aa3b0;
  --muted: rgba(38, 43, 51, 0.6);
  --fg: #e5e7eb;
  --muted-fg: #9aa3b0;
  --ring: rgba(45, 212, 191, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  /* 86px top: the 34px source bar, then room for the fixed theme switch above the browser window. */
  padding: 86px 16px 48px;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.browser-frame {
  width: 100%;
  max-width: 860px;
  background: var(--frame-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--frame-shadow);
  border: 1px solid var(--frame-border);
}

.browser-titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  background: var(--titlebar-bg);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.browser-title {
  margin-left: 10px;
  color: var(--titlebar-text);
  font-size: 12px;
}

.browser-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
}

.nav-btn {
  color: var(--nav-icon);
  font-size: 14px;
  width: 22px;
  text-align: center;
}

.url-bar {
  flex: 1;
  background: var(--url-bg);
  border: 1px solid var(--url-border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--url-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-btn {
  border: none;
  background: transparent;
  padding: 4px;
  border-radius: 7px;
  cursor: pointer;
}

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

.toolbar-mark {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1f2937, #0f766e 65%, #14b8a6);
  position: relative;
}

.toolbar-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px dashed rgba(255, 255, 255, 0.85);
  border-radius: 4px;
}

.browser-body {
  position: relative;
  max-height: 70vh;
  overflow-y: auto;
  background: #fafafa;
  color-scheme: light; /* the mock web page is a light page in both themes */
}

.popup-panel {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 20;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}

.popup-panel.cloakscan-popup {
  width: min(360px, calc(100vw - 48px));
}

.mock-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 32px 40px;
  background: #ffffff;
}

.mock-page h2 {
  margin: 0 0 12px;
  font-size: 22px;
  color: #111827;
}

.mock-page p {
  font-size: 14.5px;
  line-height: 1.65;
  color: #374151;
  margin: 0 0 14px;
}

.cs-mock-badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.harness-note {
  max-width: 640px;
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--note-text);
  text-align: center;
}

@media (max-width: 480px) {
  .mock-page {
    padding: 20px 16px 28px;
  }

  .popup-panel {
    left: 12px;
    right: 12px;
  }
}

/* Org source bar, fixed across the very top (docs/SOURCE-BAR.md in the landing-page repo). */
.src-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 34px;
  padding: 0 16px;
  background: var(--frame-bg);
  border-bottom: 1px solid var(--frame-border);
  font: 12px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.src-note {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted-fg);
}

.src-note strong {
  font-weight: 600;
  color: #0f766e;
}

:root.dark .src-note strong {
  color: #2dd4bf;
}

.src-link {
  margin-left: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-fg);
  text-decoration: none;
}

.src-link:hover {
  color: var(--fg);
}

/* Light / dark switch, fixed top-right under the source bar: the demo has no header of its own. */
.theme-toggle {
  position: fixed;
  top: 46px;
  right: 12px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 12px;
  background: var(--muted);
}

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted-fg);
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease;
}

.theme-btn:hover {
  color: var(--fg);
}

.theme-btn[aria-pressed="true"] {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.theme-btn:focus {
  outline: none;
}

.theme-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--ring);
}

.theme-btn svg {
  width: 13px;
  height: 13px;
}

/* The popup panel in dark. The demo's popup is styled by extension/popup.css, which the
   shipped extension also uses; these overrides only apply under the demo's .dark class,
   so the real extension popup is untouched. */
:root.dark .popup-panel {
  color-scheme: dark;
}

:root.dark .popup-panel.cloakscan-popup {
  background: #1b1e24;
  color: #e5e7eb;
}

:root.dark .popup-panel .cs-sub {
  color: #a1a8b3;
}

:root.dark .popup-panel .cs-scan-btn:disabled {
  background: #134e4a;
  color: #99f6e4;
}

:root.dark .popup-panel .cs-status,
:root.dark .popup-panel .cs-footnote {
  color: #949ba7;
}

:root.dark .popup-panel .cs-summary.clear {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
}

:root.dark .popup-panel .cs-summary.caution {
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
}

:root.dark .popup-panel .cs-summary.high {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

:root.dark .popup-panel .cs-finding {
  border-color: #343a44;
}

:root.dark .popup-panel .cs-finding .cs-tag {
  background: #4c1d1d;
  color: #fecaca;
}

:root.dark .popup-panel .cs-finding.confidence-medium .cs-tag {
  background: #46300c;
  color: #fde68a;
}

:root.dark .popup-panel .cs-finding p {
  color: #c9ced6;
}

:root.dark .popup-panel .cs-copy-btn {
  border-color: #3d434d;
  background: #262a31;
  color: #e5e7eb;
}

:root.dark .popup-panel .cs-copy-btn:disabled {
  color: #6b7280;
}

:root.dark .popup-panel .cs-copy-btn:not(:disabled):hover {
  background: #2f343c;
}
