:root {
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-pill: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --transition-fast: 120ms ease-out;
  --transition-default: 200ms ease-out;
  --transition-slow: 300ms ease-out;
}

/* dark */
:root,
[data-theme="dark"] {
  --bg-base: #0f0b1a;
  --bg-surface: #1a1528;
  --bg-elevated: #241e35;
  --bg-overlay: #2e2645;

  --color-text: #e8e2f4;
  --color-text-secondary: #9b8fad;
  --color-text-tertiary: #6b5f7e;

  --color-accent: #a78bfa;
  --color-accent-hover: #c4b5fd;
  --color-accent-dim: rgba(167, 139, 250, 0.15);
  --color-accent-subtle: rgba(167, 139, 250, 0.04);
  --color-accent-hover-dim: rgba(167, 139, 250, 0.25);

  --color-green: #6ee7b7;
  --color-green-dim: rgba(110, 231, 183, 0.12);
  --color-green-border: rgba(110, 231, 183, 0.25);
  --color-green-hover-dim: rgba(110, 231, 183, 0.2);
  --color-amber: #fbbf24;
  --color-amber-dim: rgba(251, 191, 36, 0.12);
  --color-blue: #60a5fa;
  --color-blue-dim: rgba(96, 165, 250, 0.12);
  --color-cyan: #67e8f9;
  --color-cyan-dim: rgba(103, 232, 249, 0.12);
  --color-cyan-border: rgba(103, 232, 249, 0.25);
  --color-cyan-hover-dim: rgba(103, 232, 249, 0.2);
  /* Outline used ONLY on favicons measured to blend into this theme. See
     tuneFaviconContrast in popup.js - a plate behind every icon looked worse
     than the problem it solved, so nothing is drawn behind them at all and
     the few icons that would vanish get a shape-hugging edge instead. */
  --favicon-outline: rgba(255, 255, 255, 0.55);
  --color-gold: #f59e0b;
  --color-danger: #f87171;
  --color-danger-dim: rgba(248, 113, 113, 0.12);
  --color-muted: #6b5f7e;
  --color-muted-dim: rgba(107, 95, 126, 0.15);

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(167, 139, 250, 0.3);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-zone: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 15px rgba(167, 139, 250, 0.12);
  --shadow-glow-sm: 0 0 8px rgba(167, 139, 250, 0.18);
  --shadow-ring-focus: 0 0 0 2px rgba(167, 139, 250, 0.4);
  --gradient-primary: linear-gradient(135deg, #b89cfd 0%, #8b5cf6 100%);
  --gradient-primary-hover: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 100%);
  --bg-hover-accent: rgba(167, 139, 250, 0.06);
  --border-light-top: rgba(255, 255, 255, 0.06);
}

/* light */
[data-theme="light"] {
  --bg-base: #ffffff;
  --bg-surface: #f9f7fc;
  --bg-elevated: #eceaf0;
  --bg-overlay: #e0dcea;

  --color-text: #1a1025;
  --color-text-secondary: #544968;
  --color-text-tertiary: #6d6180;

  --color-accent: #7c3aed;
  --color-accent-hover: #6d28d9;
  --color-accent-dim: rgba(124, 58, 237, 0.12);
  --color-accent-subtle: rgba(124, 58, 237, 0.05);
  --color-accent-hover-dim: rgba(124, 58, 237, 0.18);

  --color-green: #059669;
  --color-green-dim: rgba(5, 150, 105, 0.1);
  --color-green-border: rgba(5, 150, 105, 0.25);
  --color-green-hover-dim: rgba(5, 150, 105, 0.15);
  --color-amber: #d97706;
  --color-amber-dim: rgba(217, 119, 6, 0.1);
  --color-blue: #2563eb;
  --color-blue-dim: rgba(37, 99, 235, 0.1);
  --color-cyan: #0891b2;
  --color-cyan-dim: rgba(8, 145, 178, 0.1);
  --color-cyan-border: rgba(8, 145, 178, 0.25);
  --color-cyan-hover-dim: rgba(8, 145, 178, 0.15);
  /* see the dark block; on light the edge is dark so a white glyph shows */
  --favicon-outline: rgba(26, 16, 37, 0.62);
  --color-gold: #b45309;
  --color-danger: #dc2626;
  --color-danger-dim: rgba(220, 38, 38, 0.1);
  --color-muted: #877c9a;
  --color-muted-dim: rgba(135, 124, 154, 0.14);

  --border-subtle: rgba(0, 0, 0, 0.09);
  --border-default: rgba(0, 0, 0, 0.14);
  --border-accent: rgba(124, 58, 237, 0.35);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.13);
  --shadow-zone: 0 2px 6px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 15px rgba(124, 58, 237, 0.1);
  --shadow-glow-sm: 0 0 8px rgba(124, 58, 237, 0.14);
  --shadow-ring-focus: 0 0 0 2px rgba(124, 58, 237, 0.3);
  --gradient-primary: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  --gradient-primary-hover: linear-gradient(135deg, #6d28d9 0%, #4c1d95 100%);
  --bg-hover-accent: rgba(124, 58, 237, 0.07);
  --border-light-top: rgba(255, 255, 255, 0);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow: hidden;
}

body {
  width: 340px;
  max-height: 580px;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
}

body.popup-ready {
  animation: popupOpen 220ms ease-out forwards;
}
/* Fallback: show content if JS hasn't added .popup-ready within 500ms */
@keyframes opacityFallback { to { opacity: 1; } }
body:not(.popup-ready) {
  animation: opacityFallback 0s 500ms forwards;
}

.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-default), transform 60ms ease-out;
  user-select: none;
  outline: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-overlay);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.btn .icon { opacity: 0.8; }

.btn-primary {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), var(--shadow-glow-sm);
}

.btn-primary:hover {
  background: var(--gradient-primary-hover);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), var(--shadow-glow);
}

.btn-primary .icon { opacity: 1; }

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
  gap: 4px;
}

.btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background-color var(--transition-fast), transform 60ms ease-out;
  outline: none;
}

.btn-icon-only:hover {
  color: var(--color-text);
  background: var(--bg-hover-accent);
}

.btn-icon-only:active {
  transform: scale(0.9);
}

.btn-icon-only:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.btn-ghost-danger {
  background: none;
  border-color: transparent;
  color: var(--color-text-tertiary);
}

.btn-ghost-danger:hover {
  color: var(--color-danger);
  background: var(--color-danger-dim);
  border-color: transparent;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  line-height: 1.6;
  animation: badgePop 200ms ease-out backwards;
}

.badge .icon { flex-shrink: 0; }

.badge-active { color: var(--color-blue); background: var(--color-blue-dim); }
.badge-pinned { color: var(--color-amber); background: var(--color-amber-dim); }
.badge-audio { color: var(--color-green); background: var(--color-green-dim); }
.badge-starred { color: var(--color-gold); background: var(--color-amber-dim); }
.badge-system { color: var(--color-muted); background: var(--color-muted-dim); }
.badge-timer { color: var(--color-muted); background: var(--color-muted-dim); }
.badge-sleeping { color: var(--color-accent); background: var(--color-accent-dim); }
.badge-awake { color: var(--color-cyan); background: var(--color-cyan-dim); }

/* inputs */
.input {
  background: var(--bg-elevated);
  color: var(--color-text);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus { border-color: var(--color-accent); box-shadow: var(--shadow-ring-focus); }
.input:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.input::placeholder { color: var(--color-text-tertiary); }

.select {
  background: var(--bg-elevated);
  color: var(--color-text);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.select:focus { border-color: var(--color-accent); box-shadow: var(--shadow-ring-focus); }
.select:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }

.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color var(--transition-default), box-shadow var(--transition-default), border-color var(--transition-default);
  border: 1px solid var(--border-subtle);
}

.slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  bottom: 2px;
  left: 2px;
  background: var(--color-text-tertiary);
  border-radius: 50%;
  transition: transform var(--transition-default), background-color var(--transition-default);
}

.switch input:focus-visible + .slider {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.switch input:checked + .slider {
  background: var(--color-accent);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow-sm);
}

.switch input:checked + .slider::before {
  transform: translateX(16px);
  background: var(--color-text);
}

[data-theme="light"] .switch input:checked + .slider {
  background: #a78bfa;
  border-color: #a78bfa;
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.18);
}

[data-theme="light"] .switch input:checked + .slider::before {
  background: #fff;
}

.popup-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 580px;
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-surface);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  flex-shrink: 0;
  color: var(--color-accent);
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-icon-enter .icon {
  animation: themeIconSpin 250ms ease-out;
}

.stats-strip {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 12px 14px 14px;
  background: var(--bg-surface);
}

.strip-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.strip-stat-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--color-text);
  line-height: 1.2;
  /* "6.4 GB" is a number and a unit; inside an RTL panel the bidi algorithm
     reorders them to "GB 6.4". Isolating the value as LTR keeps the figure
     readable in Arabic, Hebrew, Persian and Urdu without touching alignment. */
  unicode-bidi: isolate;
  direction: ltr;
  transition: color var(--transition-default);
}

#statSleepingValue { color: var(--color-accent); }
#statProtectedValue { color: var(--color-green); }
#statMemoryValue { color: var(--color-blue); }

.strip-stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.strip-stat-label::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transition: background-color var(--transition-default);
}

.strip-stat:first-child .strip-stat-label::before { background: var(--color-accent); }
.strip-stat:nth-child(3) .strip-stat-label::before { background: var(--color-green); }
.strip-stat:last-child .strip-stat-label::before { background: var(--color-blue); }

/* When the third slot is rendering the forecast (no tabs suspended yet but
   eligible ones exist), differentiate from "saved" with an amber dot + value
   color so the number doesn't read as already-realized savings. */
.strip-stat.strip-stat-forecast .strip-stat-label::before { background: var(--color-amber); }
.strip-stat.strip-stat-forecast #statMemoryValue { color: var(--color-amber); }

.strip-divider {
  width: 1px;
  height: 36px;
  background: linear-gradient(to bottom, transparent, var(--border-default) 20%, var(--border-default) 80%, transparent);
}

.stat-updated {
  animation: statPulse 400ms ease-out;
}


.quick-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-surface);
  box-shadow: 0 1px 0 var(--border-subtle), var(--shadow-zone);
  position: relative;
  z-index: 1;
}

.quick-actions .btn {
  flex: 1;
}


.main-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  background: var(--bg-base);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-overlay) transparent;
}

.current-tab {
  padding: 10px 14px 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  border-left: 2px solid var(--color-accent);
  background: var(--color-accent-subtle);
  transition: background-color var(--transition-default);
}

.current-tab-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.current-tab-details { min-width: 0; }

.current-tab-domain {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.current-tab-status {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 1px;
}

/* inline "Open settings" next to a protection reason - a link, not a button,
   so it reads as a shortcut rather than a third competing action */
.current-tab-fix {
  display: inline-block;
  margin-top: 2px;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 11px;
  color: var(--color-accent);
  text-decoration: underline;
  cursor: pointer;
}

.current-tab-fix:hover {
  color: var(--color-accent-hover);
}

/* brief highlight on the setting the user was sent to */
.setting-row-flash {
  animation: settingFlash 1.6s ease-out;
  border-radius: 6px;
}

@keyframes settingFlash {
  0%, 60% { background: var(--color-accent-dim); }
  100% { background: transparent; }
}

.btn-suspend-current {
  width: 100%;
  margin-bottom: 6px;
  background: var(--color-accent-dim);
  color: var(--color-accent);
  border-color: var(--border-accent);
  box-shadow: none;
}

.btn-suspend-current:hover {
  background: var(--color-accent-hover-dim);
  color: var(--color-accent-hover);
  box-shadow: var(--shadow-glow-sm);
}

.btn-keep-awake {
  width: 100%;
  margin-bottom: 6px;
  background: var(--color-accent-dim);
  color: var(--color-accent);
  border-color: var(--border-accent);
  box-shadow: none;
}

.btn-keep-awake:hover {
  background: var(--color-accent-hover-dim);
  color: var(--color-accent-hover);
  box-shadow: var(--shadow-glow-sm);
}

/* held: cyan, the one colour not already spoken for by a protection badge,
   so "this tab is being held awake" never reads as pinned or whitelisted */
.btn-keep-awake.is-kept-awake {
  background: var(--color-cyan-dim);
  color: var(--color-cyan);
  border-color: var(--color-cyan-border);
}

.btn-keep-awake.is-kept-awake:hover {
  background: var(--color-cyan-hover-dim);
}

.btn-whitelist {
  width: 100%;
  background: var(--color-accent-dim);
  color: var(--color-accent);
  border-color: var(--border-accent);
  box-shadow: none;
}

.btn-whitelist:hover {
  background: var(--color-accent-hover-dim);
  color: var(--color-accent-hover);
  box-shadow: var(--shadow-glow-sm);
}

.btn-whitelist.is-whitelisted {
  background: var(--color-green-dim);
  color: var(--color-green);
  border-color: var(--color-green-border);
}

.btn-whitelist.is-whitelisted:hover {
  background: var(--color-green-hover-dim);
}


.favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
  object-fit: contain;
}

/* Measured as blending into the panel, and coloured - so it cannot be
   flipped without changing its hue. drop-shadow follows the alpha channel,
   tracing the glyph rather than boxing it: no plate, no visible background. */
.favicon.needs-contrast {
  filter:
    drop-shadow(0 0 0.5px var(--favicon-outline))
    drop-shadow(0 0 1px var(--favicon-outline));
}

/* Measured as blending AND monochrome on transparency - a mark like GitHub's,
   which the site itself publishes in both a light and a dark version. Chrome
   only cached one of them, so we produce the other: inverting near-black
   gives near-white and vice versa. Hue is untouched because there isn't any. */
.favicon.needs-invert {
  filter: invert(1);
}

.favicon[src=""],
.favicon:not([src]) {
  display: none;
}

.favicon-fallback {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent-dim);
  color: var(--color-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  flex-shrink: 0;
}

/* icon variant (extension / system / file pages): muted, because these are
   never suspendable and shouldn't compete with real favicons for attention */
.favicon-fallback-icon {
  background: var(--color-muted-dim);
  color: var(--color-text-tertiary);
}

.favicon-fallback-icon .icon,
.favicon-fallback-icon svg {
  display: block;
}

.tab-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 4px;
}

.section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text);
  opacity: 0.55;
}

.tab-list-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tab-search {
  padding: 0 10px 6px;
}

.tab-search .input {
  width: 100%;
  padding: 5px 8px;
}

.tab-list {
  padding: 0 6px 4px;
}

.tab-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 16px 24px;
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: 12px;
  font-weight: 500;
}

.tab-list-empty .empty-icon,
.empty-state .empty-icon {
  display: inline-flex;
  opacity: 0.55;
  color: var(--color-text-secondary);
  line-height: 0;
}

.tab-list-empty.is-loading .empty-icon {
  animation: emptyPulse 1.6s ease-in-out infinite;
}

@keyframes emptyPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.96); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast), opacity var(--transition-default);
  animation: tabSlideIn 200ms ease-out backwards;
  animation-delay: calc(var(--i, 0) * 25ms);
}

.tab-item.no-anim {
  animation: none;
}

.tab-item:hover {
  background: var(--bg-hover-accent);
}

.tab-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.tab-item.sleeping {
  opacity: 0.45;
}

.tab-item.sleeping:hover {
  opacity: 0.75;
}

/* Boost contrast in light mode so sleeping titles clear WCAG AA */
[data-theme="light"] .tab-item.sleeping {
  opacity: 0.55;
}

[data-theme="light"] .tab-item.sleeping:hover {
  opacity: 0.82;
}

.tab-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.4;
}

.tab-item.sleeping .tab-title {
  color: var(--color-text-secondary);
}

.tab-suspend-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--color-text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
  outline: none;
}

.tab-item:hover .tab-suspend-btn {
  opacity: 1;
}

.tab-suspend-btn:hover {
  color: var(--color-accent);
  background: var(--color-accent-dim);
}

.tab-suspend-btn:active {
  transform: scale(0.9);
}

.tab-suspend-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.tab-meta {
  flex-shrink: 0;
}

/* collapsible panels */
.section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 14px;
  border: none;
  border-top: 1px solid var(--border-default);
  background: none;
  color: var(--color-text);
  opacity: 0.6;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity var(--transition-fast), background var(--transition-fast);
  outline: none;
  user-select: none;
}

.section-toggle:hover {
  opacity: 1;
  background: var(--bg-hover-accent);
}

.section-toggle:active {
  background: var(--bg-overlay);
}

.section-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.section-toggle-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-chevron .icon {
  transition: transform var(--transition-default);
}

.section-toggle[aria-expanded="true"] {
  opacity: 0.75;
}

.section-toggle[aria-expanded="true"] .section-chevron .icon {
  transform: rotate(90deg);
}

.section-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms ease-out;
}

.section-body.open {
  grid-template-rows: 1fr;
}

.section-body > .section-body-inner {
  overflow: hidden;
  min-height: 0;
  padding: 0 14px;
  opacity: 0;
  transition: opacity 160ms ease-out, padding 220ms ease-out;
}

.section-body.open > .section-body-inner {
  padding: 4px 14px 10px;
  opacity: 1;
}

.session-save-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.session-save-row .input {
  flex: 1;
}

.session-feedback {
  font-size: 11px;
  min-height: 0;
  transition: opacity var(--transition-default);
}

.session-feedback.success { color: var(--color-green); margin-bottom: 6px; }
.session-feedback.error { color: var(--color-danger); margin-bottom: 6px; }

.session-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-tertiary);
  text-align: center;
  padding: 14px 8px;
}

.session-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  box-shadow: inset 0 1px 0 var(--border-light-top);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity 200ms ease-out, max-height 220ms ease-out, margin 220ms ease-out, padding 220ms ease-out;
  animation: tabSlideIn 200ms ease-out backwards;
  animation-delay: calc(var(--i, 0) * 40ms);
  max-height: 60px;
  transform-origin: top center;
}

.session-card:hover {
  border-color: var(--border-default);
  background: var(--bg-hover-accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.session-card.is-new {
  /* plain ease-out: the old curve ended at 1.15, which overshoots and springs */
  animation: sessionCardEnter 320ms ease-out;
}

.session-card.is-removing {
  animation: sessionCardLeave 220ms ease-out forwards;
  pointer-events: none;
}

.session-favicon-stack {
  display: flex;
  flex-shrink: 0;
}

.session-favicon-stack img {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1.5px solid var(--bg-surface);
  margin-left: -4px;
  object-fit: contain;
}

/* no per-surface duplicates: stacked session icons carry .favicon too, so the
   .favicon.needs-contrast / .needs-invert rules above already apply */

.session-favicon-stack img:first-child {
  margin-left: 0;
}

.session-info {
  flex: 1;
  min-width: 0;
}

.session-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 1px;
}

.session-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.session-card:hover .session-actions,
.session-card:focus-within .session-actions {
  opacity: 1;
}

.btn-ghost-danger.confirming {
  color: #fff;
  background: var(--color-danger);
  border-color: var(--color-danger);
  animation: deleteConfirmPulse 1.4s ease-in-out infinite;
}

.btn-ghost-danger.confirming:hover {
  color: #fff;
  background: var(--color-danger);
  border-color: var(--color-danger);
}

.stat-hero {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--border-light-top);
  animation: tabSlideIn 180ms ease-out backwards;
}

.stat-hero-icon {
  color: var(--color-text-tertiary);
}

.stat-hero-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stat-hero-value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--color-text);
  line-height: 1.2;
  /* same number-and-unit isolation as .strip-stat-value */
  unicode-bidi: isolate;
  direction: ltr;
}

.stat-hero-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--border-light-top);
  animation: tabSlideIn 180ms ease-out backwards;
}

.stat-card:nth-child(1) { animation-delay: 40ms; }
.stat-card:nth-child(2) { animation-delay: 80ms; }

.stat-card-icon {
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

.stat-card-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stat-card-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
}

.stat-card-value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.stats-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.stat-member {
  font-size: 11px;
  color: var(--color-text-tertiary);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--color-text-secondary);
}

.setting-row:last-child { border-bottom: none; }

.setting-row label:first-child { flex: 1; }

.setting-row-block {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.whitelist-add {
  display: flex;
  gap: 6px;
  width: 100%;
}

.whitelist-add .input { flex: 1; }

.whitelist-list {
  list-style: none;
  width: 100%;
  max-height: 140px;
  overflow-y: auto;
}

.whitelist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  font-size: 11.5px;
  color: var(--color-text-secondary);
}

.whitelist-domain {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.whitelist-count {
  font-size: 11px;
  color: var(--color-text-tertiary);
  font-weight: normal;
}

.whitelist-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border-default, rgba(255,255,255,0.1));
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  line-height: 1;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform 60ms ease-out;
  outline: none;
}

.whitelist-remove-x {
  font-size: 13px;
  line-height: 1;
}

.whitelist-remove:hover {
  color: var(--color-danger);
  background: var(--color-danger-dim);
  border-color: var(--color-danger);
}

.whitelist-remove:active {
  transform: scale(0.95);
}

.whitelist-remove:focus-visible {
  outline: 2px solid var(--color-danger);
  outline-offset: 1px;
}

.empty-whitelist {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-tertiary);
  padding: 10px 6px;
  list-style: none;
}

.empty-whitelist .empty-icon {
  display: inline-flex;
  opacity: 0.55;
  color: var(--color-text-secondary);
  line-height: 0;
}

.whitelist-io {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}

.input-error {
  border-color: var(--color-danger) !important;
  box-shadow: 0 0 0 2px var(--color-danger-dim) !important;
}

.settings-link {
  font-size: 11px;
  color: var(--color-accent);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.settings-link:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.shortcuts-row-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.shortcuts-status {
  font-size: 11px;
  color: var(--color-text-secondary);
}

/* review prompt banner */
.review-prompt {
  /* Stacked layout: question on its own row, action buttons wrapping below.
     This keeps the prompt readable in long languages (de, ru, fr, pt) and in
     RTL without the buttons overflowing the ~360px popup width. */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--color-accent-dim);
  border-bottom: 1px solid var(--border-accent);
  border-left: 2px solid var(--color-accent);
  overflow: hidden;
  max-height: 160px;
  opacity: 1;
  transition: max-height 250ms ease-out, opacity 200ms ease-out, padding 250ms ease-out, border-width 250ms ease-out;
}

.review-prompt.entering {
  animation: reviewSlideIn 250ms ease-out;
}

.review-prompt.dismissing {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-width: 0;
  /* Block further clicks while sliding away so a second button (e.g. "Don't
     ask again" right after "Maybe later") can't fire a conflicting action. */
  pointer-events: none;
}

.review-prompt-text {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  white-space: normal;
  line-height: 1.35;
}

.review-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.review-prompt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  max-width: 100%;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform 60ms ease-out;
  outline: none;
}

.review-prompt-btn:active {
  transform: scale(0.97);
}

.review-prompt-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* Primary action - leave a review. Uses the same gradient + white text as
   .btn-primary so contrast holds in both light and dark themes. */
.review-prompt-leave {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-glow-sm);
}

.review-prompt-leave:hover {
  filter: brightness(1.06);
}

/* Secondary actions - maybe later / don't ask again. */
.review-prompt-later:hover,
.review-prompt-never:hover {
  color: var(--color-text);
  background: var(--bg-overlay);
  border-color: var(--border-default);
}

@keyframes reviewSlideIn {
  from { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; }
  to { max-height: 160px; opacity: 1; padding-top: 10px; padding-bottom: 10px; }
}

.popup-footer {
  padding: 6px 14px;
  text-align: center;
  font-size: 10px;
  color: var(--color-text-tertiary);
  letter-spacing: 0.02em;
}

.toast {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 8px 14px;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-default), transform var(--transition-default);
  z-index: 100;
  /* Wraps instead of widening past the popup: a fixed, centred box with nowrap
     clips both ends of any message longer than the panel, which the 90-char
     "needs another open tab" reason already did. Short toasts still sit on
     one line because the box only grows to fit its text. */
  white-space: normal;
  /* max-content, not shrink-to-fit: with left at 50% the box would otherwise
     only get the right half of the panel to size itself in */
  width: max-content;
  max-width: calc(100% - 24px);
  text-align: center;
  box-shadow: var(--shadow-md);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

@keyframes popupOpen {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes tabSlideIn {
  from { opacity: 0; transform: translateY(4px); }
}

@keyframes sessionCardEnter {
  0%   { opacity: 0; transform: translateY(-6px); background: var(--bg-hover-accent); }
  60%  { opacity: 1; transform: translateY(0); background: var(--bg-hover-accent); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes sessionCardLeave {
  0%   { opacity: 1; transform: translateX(0) scale(1); max-height: 60px; padding-top: 7px; padding-bottom: 7px; margin-top: 0; }
  100% { opacity: 0; transform: translateX(8px) scale(0.96); max-height: 0; padding-top: 0; padding-bottom: 0; margin-top: -4px; border-width: 0; }
}

@keyframes deleteConfirmPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.55); }
  50%      { box-shadow: 0 0 0 5px rgba(248, 113, 113, 0); }
}

/* Fade, don't bounce. Suspend Others re-renders every row at once, and a
   scale-up on each badge plus the stat numbers read as cartoony rather than
   responsive. Opacity alone still shows something changed. */
@keyframes badgePop {
  from { opacity: 0; }
}

@keyframes statPulse {
  0% { opacity: 0.55; }
  100% { opacity: 1; }
}

@keyframes themeIconSpin {
  from { transform: rotate(-90deg); opacity: 0; }
  to { transform: rotate(0deg); opacity: 1; }
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 2px; }
.main-content::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}

/* ---- Right-to-left languages (ar, he, fa, ur) ----
   Flexbox and text alignment mirror automatically from the html[dir="rtl"]
   attribute set in popup.js. These overrides fix the few places that use
   physical (non-logical) properties so the accent rail and overlapping
   favicons sit on the correct side. */
[dir="rtl"] .current-tab {
  border-left: none;
  border-right: 2px solid var(--color-accent);
}

[dir="rtl"] .review-prompt {
  border-left: none;
  border-right: 2px solid var(--color-accent);
}

[dir="rtl"] .session-favicon-stack img {
  margin-left: 0;
  margin-right: -4px;
}

[dir="rtl"] .session-favicon-stack img:first-child {
  margin-right: 0;
}
