/* Local font declarations (match popup + noctivagous.com) */
@font-face {
  font-family: 'ROBOTECHGPRegular';
  src: url('../fonts/ROBOTECHGPRegular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'TitilliumText';
  src: url('../fonts/TitilliumTextRegular.otf') format('opentype');
  font-weight: 100 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'TitilliumText';
  src: url('../fonts/TitilliumTextBold.ttf') format('truetype');
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cubellan';
  src: url('../fonts/CubellanRegular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Ezarion';
  src: url('../fonts/EzarionRegular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Dosis';
  src: url('../fonts/DosisBook.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/*
 * New Tab themes
 * - cyberforward (default): popup/website slate-cyan direction + noctivagous fonts
 * - earth: original orange/black newtab look
 *
 * Switch via html[data-theme="…"] (persisted in chrome.storage + localStorage).
 */

:root,
html[data-theme="cyberforward"] {
  color-scheme: dark;

  /*
   * Display tokens (overridden by JS / localStorage):
   * - --nt-font-size-px: root type size in CSS px (default 22)
   * - --nt-ui-scale: layout zoom (default 1 = 100%)
   * - --nt-content-max-width: header + main column cap (default 1200px; use none for full)
   */
  --nt-font-size-px: 22;
  --nt-ui-scale: 1;
  --nt-content-max-width: 1200px;
  --nt-card-pad: 14px;
  /* Gap between scroll content and the scrollbar track (not the card edge). */
  --nt-scrollbar-content-gap: 6px;

  /* Card / list metrics in rem so they track the root font size */
  --nt-card-tile-min-height: 5.75rem; /* ~92px at 16px root */
  --nt-section-panel-height: 25rem; /* ~400px at 16px root */
  --nt-top-site-min-height: 5.625rem;

  --nt-font-display: var(--kp-font-display, 'ROBOTECHGPRegular', 'TitilliumText', system-ui, sans-serif);
  --nt-font-heading: var(--kp-font-heading, 'Cubellan', 'TitilliumText', system-ui, sans-serif);
  --nt-font-body: var(--kp-font-body, 'Ezarion', 'Dosis', system-ui, sans-serif);
  --nt-font-mono: var(--kp-font-mono, 'Dosis', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace);

  --nt-fg: #f1f5f9;
  --nt-fg-92: rgba(241, 245, 249, 0.92);
  --nt-fg-78: rgba(241, 245, 249, 0.78);
  --nt-fg-70: rgba(241, 245, 249, 0.70);
  --nt-fg-68: rgba(241, 245, 249, 0.68);
  --nt-fg-66: rgba(241, 245, 249, 0.66);
  --nt-fg-62: rgba(241, 245, 249, 0.62);
  --nt-fg-60: rgba(241, 245, 249, 0.60);
  --nt-fg-58: rgba(241, 245, 249, 0.58);
  --nt-fg-50: rgba(241, 245, 249, 0.50);

  --nt-bg: #1a2332;
  --nt-bg-glow-1: rgba(4, 177, 225, 0.14);
  --nt-bg-glow-2: rgba(91, 226, 241, 0.10);

  --nt-primary: #04b1e1;
  --nt-accent: #5be2f1;
  --nt-brand: #3b82f6;

  --nt-ok-soft: rgba(16, 185, 129, 0.25);
  --nt-ok-border: rgba(16, 185, 129, 0.45);
  --nt-ok-text: rgba(52, 211, 153, 0.95);
  --nt-err-soft: rgba(248, 113, 113, 0.18);
  --nt-err-border: rgba(248, 113, 113, 0.40);
  --nt-err-text: rgba(248, 113, 113, 0.95);

  --nt-domain: #5ceeed;
  /* Section title bars (Toolbar bookmarks, Recent history, …): darker bar, softer aqua */
  --nt-header-bar-fg: #b8f5fb;
  --nt-header-bar-bg: linear-gradient(180deg, rgba(6, 10, 18, 0.96) 0%, rgba(10, 15, 26, 0.90) 100%);
  --nt-header-bar-border: rgba(184, 245, 251, 0.18);

  --nt-card-bg: linear-gradient(180deg, rgba(30, 41, 59, 0.92) 0%, rgba(26, 35, 50, 0.88) 100%);
  --nt-card-border: rgba(71, 85, 105, 0.85);
  --nt-card-shadow: 0 12px 50px rgba(0, 0, 0, 0.38);

  --nt-btn-bg: linear-gradient(180deg, rgba(51, 65, 85, 0.72) 0%, rgba(30, 41, 59, 0.55) 100%);
  --nt-btn-border: rgba(148, 163, 184, 0.22);
  --nt-btn-border-hover: rgba(91, 226, 241, 0.40);
  --nt-btn-secondary-border: rgba(4, 177, 225, 0.40);

  --nt-input-bg: rgba(15, 23, 42, 0.55);
  --nt-input-border: rgba(148, 163, 184, 0.22);
  --nt-input-focus-border: rgba(4, 177, 225, 0.65);
  --nt-focus-ring: 0 0 0 3px rgba(4, 177, 225, 0.20);

  --nt-row-bg: linear-gradient(180deg, rgba(51, 65, 85, 0.48) 0%, rgba(42, 52, 65, 0.34) 100%);
  --nt-row-bg-hover: linear-gradient(180deg, rgba(4, 177, 225, 0.16) 0%, rgba(4, 177, 225, 0.08) 100%);
  --nt-row-border: rgba(148, 163, 184, 0.16);
  --nt-row-shadow: 0 4px 12px rgba(0, 0, 0, 0.28), 0 2px 4px rgba(0, 0, 0, 0.16);
  --nt-row-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.36), 0 3px 6px rgba(0, 0, 0, 0.20);
  --nt-row-shadow-focus: 0 4px 12px rgba(0, 0, 0, 0.28), 0 2px 4px rgba(0, 0, 0, 0.16), 0 0 0 3px rgba(4, 177, 225, 0.20);

  --nt-folder-bg: linear-gradient(180deg, rgba(51, 65, 85, 0.40) 0%, rgba(30, 41, 59, 0.32) 100%);
  --nt-folder-border: rgba(148, 163, 184, 0.16);

  --nt-suggestion-bg: rgba(15, 23, 42, 0.55);
  --nt-suggestion-border: rgba(4, 177, 225, 0.28);
  --nt-suggestion-hover: rgba(4, 177, 225, 0.12);
  --nt-suggestion-selected: rgba(4, 177, 225, 0.18);
  --nt-suggestion-selected-border: rgba(4, 177, 225, 0.85);

  --nt-tab-selected-bg: rgba(4, 177, 225, 0.14);
  --nt-tab-selected-border: rgba(4, 177, 225, 0.45);
  --nt-tab-hover-bg: rgba(148, 163, 184, 0.08);

  --nt-switch-bg: linear-gradient(180deg, rgba(51, 65, 85, 0.55) 0%, rgba(30, 41, 59, 0.40) 100%);
  --nt-switch-border: rgba(148, 163, 184, 0.22);
  --nt-switch-border-hover: rgba(91, 226, 241, 0.40);
  --nt-switch-track-off: rgba(248, 113, 113, 0.15);
  --nt-switch-track-off-border: rgba(248, 113, 113, 0.35);
  --nt-switch-track-on: rgba(16, 185, 129, 0.25);
  --nt-switch-track-on-border: rgba(16, 185, 129, 0.45);
  --nt-switch-thumb: rgba(241, 245, 249, 0.88);
  --nt-switch-thumb-on: #f8fafc;
  --nt-switch-focus: 0 0 0 3px rgba(4, 177, 225, 0.20);

  --nt-logo-bg: rgba(15, 23, 42, 0.55);
  --nt-logo-border: rgba(92, 238, 237, 0.40);
  --nt-logo-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 18px rgba(92, 238, 237, 0.12);

  --nt-scrollbar-track: rgba(255, 255, 255, 0.05);
  --nt-scrollbar-thumb: rgba(4, 177, 225, 0.32);
  --nt-scrollbar-thumb-hover: rgba(4, 177, 225, 0.52);

  --nt-top-site-bg: linear-gradient(180deg, rgba(51, 65, 85, 0.40) 0%, rgba(30, 41, 59, 0.32) 100%);
  --nt-top-site-border: rgba(148, 163, 184, 0.14);
  --nt-top-site-hover-bg: linear-gradient(180deg, rgba(4, 177, 225, 0.16) 0%, rgba(4, 177, 225, 0.08) 100%);
  --nt-top-site-hover-border: rgba(4, 177, 225, 0.30);
  --nt-top-site-hover-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);

  --nt-favicon-bg: rgba(148, 163, 184, 0.12);
  --nt-count-bg: rgba(148, 163, 184, 0.12);

  --nt-caret: rgba(4, 177, 225, 0.90);
  --nt-unfocused-tint: rgba(91, 226, 241, 0.05);
  --nt-focus-hint-fg: rgba(220, 250, 255, 0.94);
  --nt-focus-hint-bg: rgba(15, 23, 42, 0.90);
  --nt-focus-hint-border: rgba(4, 177, 225, 0.40);

  --nt-modal-bg: linear-gradient(rgb(30, 41, 59) 0%, rgb(15, 23, 42) 100%);
  --nt-modal-border: #334155;
  --nt-modal-shadow: rgba(0, 0, 0, 0.65) 0px 8px 24px;
  --nt-modal-backdrop: rgba(2, 6, 23, 0.55);

  --nt-title-use-gradient: 1;

  --kp-bookmark-max-rows: 4;
  --kp-bookmark-card-row-height: var(--nt-card-tile-min-height);
  --kp-bookmark-grid-gap: 0.625rem;
}

html[data-theme="earth"] {
  color-scheme: dark;

  --nt-font-display: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --nt-font-heading: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --nt-font-body: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --nt-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;

  --nt-fg: rgba(255, 255, 255, 0.92);
  --nt-fg-92: rgba(255, 255, 255, 0.92);
  --nt-fg-78: rgba(255, 255, 255, 0.78);
  --nt-fg-70: rgba(255, 255, 255, 0.70);
  --nt-fg-68: rgba(255, 255, 255, 0.68);
  --nt-fg-66: rgba(255, 255, 255, 0.66);
  --nt-fg-62: rgba(255, 255, 255, 0.62);
  --nt-fg-60: rgba(255, 255, 255, 0.60);
  --nt-fg-58: rgba(255, 255, 255, 0.58);
  --nt-fg-50: rgba(255, 255, 255, 0.50);

  --nt-bg: rgb(11, 11, 11);
  --nt-bg-glow-1: rgba(255, 140, 0, 0.18);
  --nt-bg-glow-2: rgba(0, 180, 0, 0.14);

  --nt-primary: #ff8c00;
  --nt-accent: #ff8c00;
  --nt-brand: #ff8c00;

  --nt-ok-soft: rgba(0, 255, 0, 0.25);
  --nt-ok-border: rgba(0, 255, 0, 0.45);
  --nt-ok-text: rgba(0, 255, 0, 0.88);
  --nt-err-soft: rgba(255, 0, 0, 0.15);
  --nt-err-border: rgba(255, 0, 0, 0.35);
  --nt-err-text: rgba(255, 0, 0, 0.88);

  --nt-domain: rgba(255, 200, 130, 0.92);
  --nt-header-bar-fg: rgba(255, 200, 130, 0.95);
  --nt-header-bar-bg: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.30) 100%);
  --nt-header-bar-border: rgba(255, 140, 0, 0.22);

  --nt-card-bg: linear-gradient(180deg, rgba(10, 10, 10, 0.85) 0%, rgba(20, 20, 20, 0.75) 100%);
  --nt-card-border: rgba(255, 255, 255, 0.10);
  --nt-card-shadow: 0 12px 50px rgba(0, 0, 0, 0.38);

  --nt-btn-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.03) 100%);
  --nt-btn-border: rgba(255, 255, 255, 0.18);
  --nt-btn-border-hover: rgba(255, 255, 255, 0.28);
  --nt-btn-secondary-border: rgba(255, 140, 0, 0.35);

  --nt-input-bg: rgba(0, 0, 0, 0.28);
  --nt-input-border: rgba(255, 255, 255, 0.14);
  --nt-input-focus-border: rgba(255, 140, 0, 0.55);
  --nt-focus-ring: 0 0 0 3px rgba(255, 140, 0, 0.16);

  --nt-row-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.06) 100%);
  --nt-row-bg-hover: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
  --nt-row-border: rgba(255, 255, 255, 0.12);
  --nt-row-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.15);
  --nt-row-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.35), 0 3px 6px rgba(0, 0, 0, 0.20);
  --nt-row-shadow-focus: 0 4px 12px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(255, 140, 0, 0.16);

  --nt-folder-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
  --nt-folder-border: rgba(255, 255, 255, 0.12);

  --nt-suggestion-bg: rgba(0, 0, 0, 0.22);
  --nt-suggestion-border: rgba(255, 140, 0, 0.22);
  --nt-suggestion-hover: rgba(255, 140, 0, 0.12);
  --nt-suggestion-selected: rgba(255, 140, 0, 0.18);
  --nt-suggestion-selected-border: rgba(255, 140, 0, 0.85);

  --nt-tab-selected-bg: rgba(255, 140, 0, 0.14);
  --nt-tab-selected-border: rgba(255, 140, 0, 0.45);
  --nt-tab-hover-bg: rgba(255, 255, 255, 0.06);

  --nt-switch-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.03) 100%);
  --nt-switch-border: rgba(255, 255, 255, 0.18);
  --nt-switch-border-hover: rgba(255, 255, 255, 0.28);
  --nt-switch-track-off: rgba(255, 0, 0, 0.15);
  --nt-switch-track-off-border: rgba(255, 0, 0, 0.35);
  --nt-switch-track-on: rgba(0, 255, 0, 0.25);
  --nt-switch-track-on-border: rgba(0, 255, 0, 0.45);
  --nt-switch-thumb: rgba(255, 255, 255, 0.82);
  --nt-switch-thumb-on: rgba(255, 255, 255, 0.92);
  --nt-switch-focus: 0 0 0 3px rgba(255, 140, 0, 0.18);

  --nt-logo-bg: rgba(0, 0, 0, 0.35);
  --nt-logo-border: rgba(255, 140, 0, 0.35);
  --nt-logo-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);

  --nt-scrollbar-track: rgba(255, 255, 255, 0.05);
  --nt-scrollbar-thumb: rgba(255, 140, 0, 0.30);
  --nt-scrollbar-thumb-hover: rgba(255, 140, 0, 0.50);

  --nt-top-site-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
  --nt-top-site-border: rgba(255, 255, 255, 0.08);
  --nt-top-site-hover-bg: linear-gradient(180deg, rgba(255, 140, 0, 0.15) 0%, rgba(255, 140, 0, 0.08) 100%);
  --nt-top-site-hover-border: rgba(255, 140, 0, 0.25);
  --nt-top-site-hover-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);

  --nt-favicon-bg: rgba(255, 255, 255, 0.08);
  --nt-count-bg: rgba(255, 255, 255, 0.08);

  --nt-caret: rgba(255, 140, 0, 0.85);
  --nt-unfocused-tint: rgba(255, 255, 255, 0.07);
  --nt-focus-hint-fg: rgba(255, 240, 220, 0.94);
  --nt-focus-hint-bg: rgba(0, 0, 0, 0.85);
  --nt-focus-hint-border: rgba(255, 140, 0, 0.40);

  --nt-modal-bg: linear-gradient(rgb(18, 18, 18) 0%, rgb(11, 11, 11) 100%);
  --nt-modal-border: rgb(43, 43, 43);
  --nt-modal-shadow: rgba(0, 0, 0, 0.65) 0px 8px 24px;
  --nt-modal-backdrop: rgba(0, 0, 0, 0.5);

  --nt-title-use-gradient: 0;

  --kp-bookmark-max-rows: 4;
  --kp-bookmark-card-row-height: var(--nt-card-tile-min-height);
  --kp-bookmark-grid-gap: 0.625rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

/*
 * Root font-size drives rem-based type (default 22px).
 * UI scale zooms the whole surface (layout + chrome) independently of type size.
 */
html {
  font-size: calc(var(--nt-font-size-px, 22) * 1px);
  zoom: var(--nt-ui-scale, 1);
}

body {
  margin: 0;
  font-family: var(--nt-font-body);
  background:
    radial-gradient(1200px 600px at 20% 10%, var(--nt-bg-glow-1), transparent 60%),
    radial-gradient(900px 500px at 80% 25%, var(--nt-bg-glow-2), transparent 65%),
    var(--nt-bg);
  background-repeat: no-repeat;
  background-size: 100% 100vh;
  background-attachment: fixed;
  color: var(--nt-fg);
  overflow-x: hidden; /* prevent long unbroken URLs from pushing layout sideways */
}

.topbar {
  /* Compact control grid: identity | overlays | display | pages */
  display: grid;
  grid-template-columns:
    minmax(8.5rem, auto)
    minmax(13.5rem, 1.4fr)
    minmax(7.5rem, auto)
    minmax(9.5rem, auto);
  align-items: end;
  gap: 8px 10px;
  padding: 12px 18px 10px;
  /* width: 100% + max-width: shrinks with the window below the chosen content width */
  width: 100%;
  max-width: var(--nt-content-max-width, 1200px);
  margin: 0 auto;
  box-sizing: border-box;
}

/* Labeled control zones inside the topbar grid */
.topbar-zone {
  display: grid;
  grid-template-rows: auto auto;
  gap: 5px;
  min-width: 0;
  align-content: end;
}

.topbar-zone-label {
  font-family: var(--nt-font-heading);
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nt-fg-50);
  line-height: 1;
  padding-left: 2px;
  user-select: none;
}

.topbar-zone-body {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
  min-height: 2.75rem;
}

.topbar-zone-body--nav {
  gap: 6px;
}

.topbar-zone--identity {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  grid-template-rows: none;
}

.topbar-zone--identity .topbar-zone-label {
  display: none;
}

.topbar-zone--display .topbar-zone-body,
.topbar-zone--nav .topbar-zone-body {
  align-items: stretch;
}

.topbar-zone--display .btn-display {
  flex: 0 1 auto;
  width: auto;
  max-width: none;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-height: 2.75rem;
  padding: 8px 10px;
  white-space: nowrap;
}

.topbar-zone--nav .btn {
  flex: 1 1 0;
  min-height: 2.75rem;
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
}

/* Collapse to 2×2 then stacked as the content column narrows */
@media (max-width: 860px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .topbar-zone--identity {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar-zone--identity {
    grid-column: auto;
  }
}

/* Unfocused state: blur the page content and add tint */
/* body.kp-unfocused .main {
  filter: blur(2px);
}

body.kp-unfocused header {
  filter: blur(2px);
} */

body.kp-unfocused::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2147483040; /* below focus-hint + modals */
  pointer-events: none;
  background: var(--nt-unfocused-tint);
  mix-blend-mode: lighten;
}

/* Full-page omnibox focus cue (shown when the page loses focus to Chrome UI) */
.focus-hint {
  position: fixed;
  inset: 0;
  z-index: 2147483042; /* above tint, below modal (modal-root is 2147483045) */
  pointer-events: none;
  filter: none; /* Ensure focus hint stays sharp even when page is blurred */
}

/* Dim page content so the watermark stays readable on busy new-tab layouts */
.focus-hint-scrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 18, 0.42);
  pointer-events: none;
}

/* SVG watermark layer: address-bar cue + upward chevrons + copy.
   Use a real <img> (not CSS background-image) so the graphic paints reliably. */
.focus-hint-bg {
  position: absolute;
  left: 50%;
  top: -48px;
  width: min(1100px, 92vw);
  height: auto;
  transform: translateX(-50%);
  opacity: 1;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Cyberforward: shift the earth-orange SVG toward the theme accent */
html[data-theme="cyberforward"] .focus-hint-bg {
  filter: hue-rotate(165deg) saturate(1.15) brightness(1.08);
}

.focus-hint-message {
  position: relative;
  display: block;
  width: 75vw;
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 20px;
  text-align: center;
  user-select: none;
  color: var(--nt-focus-hint-fg);
  background: var(--nt-focus-hint-bg);
  border-bottom: 1px solid var(--nt-focus-hint-border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.30);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  opacity: 0.92;
}

/* Title + extension toggle as one chrome group */
.brand-lockup {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
  padding: 6px 10px 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--nt-switch-border);
  background: var(--nt-switch-bg);
  min-height: 2.75rem;
  box-sizing: border-box;
}

.brand-lockup:hover {
  border-color: var(--nt-switch-border-hover);
}

.brand-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.brand-heading .kp-switch-shortcut {
  flex-shrink: 0;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  background: var(--nt-logo-bg);
  border: 1px solid var(--nt-logo-border);
  box-shadow: var(--nt-logo-shadow);
}

.title {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--nt-font-display);
  color: var(--nt-fg);
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}

/* Cyberforward brand gradient title (website / popup style) */
html[data-theme="cyberforward"] .title {
  background: linear-gradient(135deg, #5ceeed 0%, #5bf5f3 50%, #4f7397 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-fa-icon {
  display: block;
  flex-shrink: 0;
  width: 0.875rem;
  height: 0.875rem;
  opacity: 0.92;
}

.btn-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: none;
}

.btn-display-summary {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15px;
  color: var(--nt-fg-92);
  white-space: nowrap;
  line-height: 1.2;
}

.btn-display-caret {
  font-size: 0.6875rem;
  opacity: 0.75;
  flex-shrink: 0;
  line-height: 1;
}

.btn-display[aria-expanded="true"] {
  border-color: var(--nt-input-focus-border);
  box-shadow: var(--nt-focus-ring);
}

/* Theme dropdown popover (Popover API top layer) */
.nt-display-popover {
  /* Reset UA popover margins; we position via left/top */
  margin: 0;
  inset: unset;
  position: fixed;
  z-index: 2147483046;
  width: min(480px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--nt-modal-border);
  border-radius: 10px;
  background: var(--nt-modal-bg);
  box-shadow: var(--nt-modal-shadow), 0 0 0 1px rgba(255, 255, 255, 0.04);
  color: var(--nt-fg);
  font-family: var(--nt-font-body);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.nt-display-popover:not(:popover-open) {
  display: none;
}

/* Fallback when Popover API is unavailable (hidden attr / inline display). */
.nt-display-popover[hidden] {
  display: none !important;
}

.nt-display-popover-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}

.nt-display-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.nt-display-field-label {
  font-family: var(--nt-font-heading);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--nt-header-bar-fg);
}

.nt-display-field-hint {
  font-size: 0.6875rem;
  line-height: 1.35;
  color: var(--nt-fg-60);
}

.nt-display-segmented {
  width: 100%;
  justify-content: stretch;
}

.nt-display-segmented .kp-segmented-control-btn {
  flex: 1 1 auto;
}

.nt-display-popover-footer {
  display: flex;
  justify-content: stretch;
  align-items: center;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--nt-card-border);
}

.nt-display-reset-btn {
  width: 100%;
  text-align: center;
  font-weight: 600;
}

.btn {
  background: var(--nt-btn-bg);
  border: 1px solid var(--nt-btn-border);
  color: var(--nt-fg-92);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.8125rem;
  font-family: var(--nt-font-heading);
  cursor: pointer;
}

.btn:hover {
  border-color: var(--nt-btn-border-hover);
}

.btn-secondary {
  border-color: var(--nt-btn-secondary-border);
}

.kp-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--nt-switch-border);
  background: var(--nt-switch-bg);
}

.kp-switch:hover {
  border-color: var(--nt-switch-border-hover);
}

/* Nested inside brand lockup: chrome comes from the parent container */
.kp-switch--brand {
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0;
  gap: 6px;
  width: 100%;
  justify-content: flex-start;
}

.kp-switch--brand:hover {
  border-color: transparent;
}

/* Compact cell: label stack above control row — fills a grid slot */
.kp-switch--cell {
  flex: 1 1 0;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 5px;
  padding: 6px 8px 7px;
  min-height: 2.75rem;
  box-sizing: border-box;
}

.kp-switch--cell .kp-switch-track {
  width: 36px;
  height: 18px;
}

.kp-switch--cell .kp-switch-thumb {
  width: 12px;
  height: 12px;
}

.kp-switch--cell .kp-switch-input:checked + .kp-switch-track .kp-switch-thumb {
  transform: translateX(18px);
}

.kp-switch--brand .kp-switch-track {
  width: 36px;
  height: 18px;
}

.kp-switch--brand .kp-switch-thumb {
  width: 12px;
  height: 12px;
}

.kp-switch--brand .kp-switch-input:checked + .kp-switch-track .kp-switch-thumb {
  transform: translateX(18px);
}

.kp-switch-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.kp-switch-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.kp-switch-label {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.35px;
  color: var(--nt-fg-78);
  text-transform: uppercase;
  font-family: var(--nt-font-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.kp-switch-hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--nt-fg-70);
  letter-spacing: 0.2px;
}

.kp-switch-hint-keys {
  font-size: 0.625rem;
  font-weight: 400;
  color: var(--nt-fg-50);
  letter-spacing: 0.1px;
}

.kp-switch-shortcut {
  font-size: 0.5625rem;
  font-weight: 500;
  color: var(--nt-fg-50);
  letter-spacing: 0.04em;
  font-family: var(--nt-font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.kp-switch-state {
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  min-width: 1.5rem; /* keeps width stable between ON/OFF */
  text-align: right;
  font-family: var(--nt-font-mono);
}

/* Red for OFF state */
.kp-switch-state[data-state="off"] {
  color: var(--nt-err-text);
}

/* Green for ON state */
.kp-switch-state[data-state="on"] {
  color: var(--nt-ok-text);
}

.kp-switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* Rectangular toggle track + thumb (not pill-shaped) */
.kp-switch-track {
  width: 42px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--nt-switch-track-off-border);
  background: var(--nt-switch-track-off);
  display: inline-flex;
  align-items: center;
  padding: 2px;
  transition: background 140ms ease, border-color 140ms ease;
  box-sizing: border-box;
}

.kp-switch-thumb {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--nt-switch-thumb);
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  transform: translateX(0);
  transition: transform 140ms ease, background 140ms ease;
}

/* checked */
.kp-switch-input:checked + .kp-switch-track {
  background: var(--nt-switch-track-on);
  border-color: var(--nt-switch-track-on-border);
}

.kp-switch-input:checked + .kp-switch-track .kp-switch-thumb {
  transform: translateX(20px);
  background: var(--nt-switch-thumb-on);
}

/* focus */
.kp-switch-input:focus-visible + .kp-switch-track {
  outline: none;
  box-shadow: var(--nt-switch-focus);
  border-color: var(--nt-input-focus-border);
}

.main {
  /* Same content column as .topbar; shrinks when the viewport is narrower than max-width */
  width: 100%;
  max-width: var(--nt-content-max-width, 1200px);
  margin: 0 auto;
  padding: 0 18px 40px;
  display: grid;
  gap: 14px;
  box-sizing: border-box;
}

.main > * {
  /* Important for CSS grid: allow children to shrink smaller than their content's min-content width */
  min-width: 0;
}

.card {
  border-radius: 10px;
  border: 1px solid var(--nt-card-border);
  background: var(--nt-card-bg);
  box-shadow: var(--nt-card-shadow);
  padding: var(--nt-card-pad, 14px);
  min-width: 0;
}

/*
 * Cards with internal scrollers: drop right (and bottom where the body scrolls)
 * padding so the scrollbar sits on the card chrome edge instead of 14px inset.
 * Content keeps left/top inset via remaining card padding + scroller padding.
 */
.toolbar-section.card,
.history-section.card {
  padding: var(--nt-card-pad, 14px) 0 0 var(--nt-card-pad, 14px);
}

.bookmarks-card.card,
.top-sites-section.card {
  padding: var(--nt-card-pad, 14px) 0 var(--nt-card-pad, 14px) var(--nt-card-pad, 14px);
}

.search form {
  display: flex;
  gap: 10px;
}

#search-input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid var(--nt-input-border);
  background: var(--nt-input-bg);
  padding: 12px 12px;
  font-size: 1rem;
  font-family: var(--nt-font-body);
  color: var(--nt-fg-92);
  outline: none;
}

#search-input:focus {
  border-color: var(--nt-input-focus-border);
  box-shadow: var(--nt-focus-ring);
}

.search-meta {
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--nt-fg-68);
  font-family: var(--nt-font-mono);
}

.suggestions {
  margin-top: 10px;
  border-radius: 10px;
  border: 1px solid var(--nt-suggestion-border);
  background: var(--nt-suggestion-bg);
  overflow: hidden;
}

.suggestion-row {
  padding: 10px 12px;
  border-left: 3px solid transparent;
  cursor: pointer;
}

.suggestion-row:hover {
  background: var(--nt-suggestion-hover);
}

.suggestion-row:focus-visible {
  outline: none;
  box-shadow: var(--nt-focus-ring);
}

.suggestion-row.selected {
  background: var(--nt-suggestion-selected);
  border-left-color: var(--nt-suggestion-selected-border);
}

.suggestion-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--nt-fg-92);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-url {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--nt-fg-62);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--nt-font-mono);
}

/* Shared URL listing helpers (used by newtab.js via renderUrlListing) */
.kp-url-row {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--nt-row-bg);
  border: 1px solid var(--nt-row-border);
  box-shadow: var(--nt-row-shadow);
  margin: 6px 6px 6px 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
}

.kp-url-row:hover {
  background-color: var(--nt-row-bg-hover);
  box-shadow: var(--nt-row-shadow-hover);
  transform: translateY(-1px);
}

/*
 * Page thumbs paint via ::before so the media layer is full-bleed under the
 * 1px border (avoids subpixel / border-box gaps on top-bottom or left-right).
 */
.kp-url-row.kp-has-page-thumb {
  /* Solid underlay; image lives on the pseudo */
  background-color: #0a0a0a;
  background-image: none;
  border-color: rgba(255, 255, 255, 0.1);
  isolation: isolate;
}

.kp-url-row.kp-has-page-thumb::before {
  content: "";
  position: absolute;
  /* Bleed 1px under the border so AA / subpixel never leaves a seam */
  inset: -1px;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  background-color: #0a0a0a;
  background-image:
    /* Idle = former hover darkness; hover lifts further so the photo reads more */
    linear-gradient(to bottom, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.78) 100%),
    var(--kp-page-thumb);
  /* Gradient always fills; photo covers */
  background-size: 100% 100%, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

.kp-url-row.kp-has-page-thumb:hover {
  background-color: #0a0a0a;
  background-image: none;
}

.kp-url-row.kp-has-page-thumb:hover::before {
  background-image:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.32) 0%, rgba(0, 0, 0, 0.52) 100%),
    var(--kp-page-thumb);
}

.kp-url-row.kp-has-page-thumb > * {
  position: relative;
  z-index: 1;
}

.kp-card-grid .kp-url-row.kp-has-page-thumb .kp-url-domain,
.kp-card-grid .kp-url-row.kp-has-page-thumb .kp-url-title,
.kp-card-grid .kp-url-row.kp-has-page-thumb .kp-url-path {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.kp-url-row:focus-visible {
  outline: none;
  box-shadow: var(--nt-row-shadow-focus);
  border-color: var(--nt-input-focus-border);
}

.kp-url-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.kp-url-text {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kp-url-domain,
.kp-url-title,
.kp-url-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.kp-url-domain {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.15px;
  color: var(--nt-domain);
  font-family: var(--nt-font-mono);
}

.kp-url-title {
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--nt-fg-92);
}

.kp-url-path {
  font-size: 0.6875rem;
  color: var(--nt-fg-58);
  font-family: var(--nt-font-mono);
}

.kp-url-favicon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--nt-favicon-bg);
  flex: 0 0 auto;
}

h2 {
  margin: 0 0 10px 0;
  font-size: 0.9375rem;
  font-family: var(--nt-font-heading);
}

/* Section headers as full-width bars, separated from their lists */
.top-sites-section > h2,
.toolbar-section > h2,
.history-section > h2 {
  /* Pull into card top/left pad; right is already flush (card padding-right: 0). */
  margin: calc(-1 * var(--nt-card-pad, 14px)) 0 12px calc(-1 * var(--nt-card-pad, 14px));
  padding: 12px var(--nt-card-pad, 14px);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--nt-header-bar-fg);
  background: var(--nt-header-bar-bg);
  border-bottom: 1px solid var(--nt-header-bar-border);
  border-radius: 10px 10px 0 0;
  font-family: var(--nt-font-heading);
}

.toolbar {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
}

.toolbar .kp-url-row {
  margin: 0;
}

.toolbar details {
  border: 1px solid var(--nt-folder-border);
  border-radius: 10px;
  background: var(--nt-folder-bg);
  box-shadow: var(--nt-row-shadow);
  padding: 8px 10px;
  min-width: 0;
}

.toolbar summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--nt-font-heading);
}

.toolbar summary::-webkit-details-marker {
  display: none;
}

.toolbar-folder-children {
  margin-top: 8px;
  padding-left: 16px;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.toolbar-link {
  display: block;
  color: var(--nt-fg-92);
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-link:hover {
  text-decoration: underline;
}

.toolbar-link small {
  display: block;
  font-size: 0.75rem;
  color: var(--nt-fg-60);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.bookmarks {
  margin: 0;
  padding-left: 18px;
}

.bookmarks li {
  margin: 8px 0;
  min-width: 0;
}

.bookmarks li .kp-url-content {
  align-items: flex-start;
}

/* Bookmarks now use the shared three-line URL renderer on the row itself. */
.bookmarks .kp-url-row {
  margin: 8px 0;
}

/* Tabbed bookmarks card — keep non-scrolling chrome padded on the right */
.bookmarks-card .tabbar,
.bookmarks-card .bookmarks-header,
.bookmarks-card .empty {
  padding-right: var(--nt-card-pad, 14px);
}

.tabbar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--nt-card-border);
}

.tabbar-tab {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--nt-fg-70);
  font: inherit;
  font-family: var(--nt-font-heading);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.tabbar-tab:hover {
  background: var(--nt-tab-hover-bg);
  color: var(--nt-fg-92);
}

.tabbar-tab:focus-visible {
  outline: 2px solid var(--nt-input-focus-border);
  outline-offset: 1px;
}

.tabbar-tab[aria-selected="true"] {
  background: var(--nt-tab-selected-bg);
  border-color: var(--nt-tab-selected-border);
  color: var(--nt-fg-92);
}

.bookmarks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.bookmarks-header h2 {
  margin: 0;
}

/* Shared card (grid) view for URL listings */
.kp-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: var(--kp-bookmark-grid-gap, 0.625rem);
  min-width: 0;
  align-content: start;
}

.kp-card-grid > * {
  min-width: 0;
  max-width: 100%;
}

.bookmarks.kp-card-grid {
  list-style: none;
  padding-left: 0;
}

.kp-card-grid .kp-url-row {
  margin: 0;
  /* Grow with type; rem tracks --nt-font-size-px */
  min-height: var(--nt-card-tile-min-height);
  height: auto;
  overflow: hidden;
}

.kp-card-grid .kp-url-content {
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  width: 100%;
}

.kp-card-grid .kp-url-text {
  width: 100%;
  min-width: 0;
}

.kp-card-grid .kp-url-favicon {
  width: 1.5rem;
  height: 1.5rem;
}

/* Toolbar bookmarks render as two fixed columns of cards */
.toolbar.kp-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* All bookmarks tree */
.bm-tree {
  display: grid;
  gap: 8px;
  min-width: 0;
}

/*
 * Recent + All bookmarks: show at most 4 rows of card tiles, then scroll.
 * Row height is rem-based so it tracks the selected font size.
 */
#bookmark-list,
#all-bookmarks {
  max-height: calc(
    var(--kp-bookmark-max-rows) * var(--kp-bookmark-card-row-height)
    + (var(--kp-bookmark-max-rows) - 1) * var(--kp-bookmark-grid-gap)
  );
  overflow-y: auto;
  overflow-x: hidden;
  /* Small gap content↔scrollbar only; scroller itself is flush to the card edge. */
  padding-right: var(--nt-scrollbar-content-gap, 6px);
  align-content: start;
  min-width: 0;
}

#bookmark-list::-webkit-scrollbar,
#all-bookmarks::-webkit-scrollbar {
  width: 8px;
}

#bookmark-list::-webkit-scrollbar-track,
#all-bookmarks::-webkit-scrollbar-track {
  background: var(--nt-scrollbar-track);
  border-radius: 4px;
}

#bookmark-list::-webkit-scrollbar-thumb,
#all-bookmarks::-webkit-scrollbar-thumb {
  background: var(--nt-scrollbar-thumb);
  border-radius: 4px;
}

#bookmark-list::-webkit-scrollbar-thumb:hover,
#all-bookmarks::-webkit-scrollbar-thumb:hover {
  background: var(--nt-scrollbar-thumb-hover);
}

.bm-folder {
  border: 1px solid var(--nt-folder-border);
  border-radius: 10px;
  background: var(--nt-folder-bg);
  box-shadow: var(--nt-row-shadow);
  padding: 8px 10px;
  min-width: 0;
  overflow: hidden;
}

.bm-folder-summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--nt-font-heading);
}

.bm-folder-summary::-webkit-details-marker {
  display: none;
}

.bm-folder-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform 120ms ease;
  color: var(--nt-caret);
}

.bm-folder[open] > .bm-folder-summary::before {
  transform: rotate(90deg);
}

.bm-folder-children {
  margin-top: 8px;
  padding-left: 14px;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.bm-folder-children > .kp-card-grid {
  min-width: 0;
}

.bm-folder-children .bm-folder {
  padding: 6px 8px;
}

.bm-leaf {
  margin: 0;
}

.empty {
  font-size: 0.8125rem;
  color: var(--nt-fg-68);
  padding: 6px 0 0;
}

/* Modal (matches overlay-manager sizing/feel) */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 2147483045;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--nt-modal-backdrop);
}

.modal-container {
  position: absolute;
  inset: 0;
  width: 80vw;
  height: 80vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: auto;
  /* Match overlay-manager.showPopover shell */
  border-radius: 8px;
  border: 1px solid var(--nt-modal-border);
  background: var(--nt-modal-bg);
  box-shadow: var(--nt-modal-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Titlebar chrome comes from createPopoverTitlebar (inline styles). */

.modal-iframe {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Two-column container for toolbar and history */
.toolbar-history-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-width: 0;
}

/* When toolbar section is hidden, make history section full width */
.toolbar-history-container:has(#toolbar-bookmarks-section[style*="display: none"]) {
  grid-template-columns: 1fr;
}

/* Fixed height cards: header stays put, list scrolls beneath.
   Height is rem-based so larger fonts get a taller panel and tiles stay inside. */
.toolbar-section,
.history-section {
  height: var(--nt-section-panel-height);
  min-height: 18rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toolbar-section > h2,
.history-section > h2 {
  flex: 0 0 auto;
}

/* Scrollable list region under the section header — flush to card right/bottom */
.toolbar-section > .toolbar,
.toolbar-section > .empty,
.history-section > .history {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* Bottom inset for last row; right gap only before the scrollbar track. */
  padding-bottom: var(--nt-card-pad, 14px);
  padding-right: var(--nt-scrollbar-content-gap, 6px);
}

/* Custom scrollbar styling (list containers only) */
.toolbar-section > .toolbar::-webkit-scrollbar,
.toolbar-section > .empty::-webkit-scrollbar,
.history-section > .history::-webkit-scrollbar {
  width: 8px;
}

.toolbar-section > .toolbar::-webkit-scrollbar-track,
.toolbar-section > .empty::-webkit-scrollbar-track,
.history-section > .history::-webkit-scrollbar-track {
  background: var(--nt-scrollbar-track);
  border-radius: 4px;
}

.toolbar-section > .toolbar::-webkit-scrollbar-thumb,
.toolbar-section > .empty::-webkit-scrollbar-thumb,
.history-section > .history::-webkit-scrollbar-thumb {
  background: var(--nt-scrollbar-thumb);
  border-radius: 4px;
}

.toolbar-section > .toolbar::-webkit-scrollbar-thumb:hover,
.toolbar-section > .empty::-webkit-scrollbar-thumb:hover,
.history-section > .history::-webkit-scrollbar-thumb:hover {
  background: var(--nt-scrollbar-thumb-hover);
}

.history {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
}

.history .kp-url-row {
  margin: 0;
}

/* Recent history grouped by website in outline containers */
.history-outline {
  border: 1px solid var(--nt-folder-border);
  border-radius: 10px;
  background: var(--nt-folder-bg);
  box-shadow: var(--nt-row-shadow);
  padding: 6px 8px;
  min-width: 0;
}

/*
 * Page preview lives on the summary header only (collapsed face).
 * Do not put overflow:hidden / absolute full-bleed on the <details> itself —
 * that clipped the 1.5em caret + label and made rows look too short.
 */
.history-outline.kp-has-page-thumb {
  /* Edge-to-edge header: outer pad moves onto summary / children */
  padding: 0;
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--nt-folder-bg);
}

.history-outline-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 2px 2px;
  font-weight: 700;
  font-family: var(--nt-font-heading);
  position: relative;
}

.history-outline.kp-has-page-thumb > .history-outline-summary {
  /* Replaces the 6×8 container pad so text/caret have full room */
  padding: 8px 10px;
  border-radius: 10px;
  isolation: isolate;
  overflow: hidden;
  min-height: 2.25rem;
  box-sizing: border-box;
}

.history-outline.kp-has-page-thumb[open] > .history-outline-summary {
  border-radius: 10px 10px 0 0;
}

/* Thumb on ::after — summary ::before is the ▸ caret */
.history-outline.kp-has-page-thumb > .history-outline-summary::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  background-color: #0a0a0a;
  background-image:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.78) 100%),
    var(--kp-page-thumb);
  background-size: 100% 100%, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

.history-outline.kp-has-page-thumb > .history-outline-summary:hover::after {
  background-image:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.32) 0%, rgba(0, 0, 0, 0.52) 100%),
    var(--kp-page-thumb);
}

.history-outline.kp-has-page-thumb > .history-outline-summary::before,
.history-outline.kp-has-page-thumb > .history-outline-summary > * {
  position: relative;
  z-index: 1;
}

.history-outline.kp-has-page-thumb > .history-outline-summary .history-outline-label {
  color: var(--nt-fg-92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.history-outline.kp-has-page-thumb > .history-outline-summary .history-outline-count {
  background: rgba(0, 0, 0, 0.45);
  color: var(--nt-fg-92);
}

.history-outline.kp-has-page-thumb > .history-outline-summary::before {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.history-outline.kp-has-page-thumb > .history-outline-children {
  padding: 6px 8px 8px;
  margin-top: 0;
}

.history-outline-summary::-webkit-details-marker {
  display: none;
}

.history-outline-summary::before {
  content: "▸";
  display: inline-block;
  font-size: 1.5em;
  line-height: 1;
  margin-right: 2px;
  transition: transform 120ms ease;
  color: var(--nt-caret);
  flex: 0 0 auto;
}

.history-outline[open] > .history-outline-summary::before {
  transform: rotate(90deg);
}

.history-outline-favicon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--nt-favicon-bg);
  flex: 0 0 auto;
}

.history-outline-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
}

.history-outline-count {
  flex: 0 0 auto;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--nt-fg-60);
  background: var(--nt-count-bg);
  border-radius: 999px;
  padding: 1px 8px;
  font-family: var(--nt-font-mono);
}

.history-outline-children {
  margin-top: 6px;
  padding-left: 12px;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.history-outline-children .kp-url-row {
  margin: 0;
}

/* History uses .kp-url-row hover/focus styles + the shared three-line renderer. */

/* Top sites — compact rectangular tiles; URL overlaid at bottom (clips on overflow) */
.top-sites-list {
  /* Let the horizontal scroller reach the card’s right edge. */
  margin-right: 0;
}

.top-sites-horizontal {
  display: flex;
  gap: 10px;
  overflow-x: scroll;
  overflow-y: hidden;
  padding: 6px var(--nt-card-pad, 14px) 8px 0;
  min-width: 0;
  /* Horizontal scrollbar sits on the bottom of this box (card bottom pad is 0 on right path). */
  box-sizing: border-box;
}

.top-sites-horizontal::-webkit-scrollbar {
  height: 8px;
}

.top-sites-horizontal::-webkit-scrollbar-track {
  background: var(--nt-scrollbar-track);
  border-radius: 2px;
}

.top-sites-horizontal::-webkit-scrollbar-thumb {
  background: var(--nt-scrollbar-thumb);
  border-radius: 2px;
}

.top-sites-horizontal::-webkit-scrollbar-thumb:hover {
  background: var(--nt-scrollbar-thumb-hover);
}

.top-site-item {
  flex: 0 0 auto;
  min-width: 0;
  width: 4.5rem; /* compact tile (~72px at 16px root) */
}

/* Card shell: chrome lives on the tile */
.top-site-link,
.top-site-card {
  display: block;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  text-decoration: none;
  color: var(--nt-fg-92);
  width: 100%;
  min-height: 0;
  height: auto;
  overflow: visible;
  box-sizing: border-box;
  transition: transform 120ms ease;
}

.top-site-card:hover {
  transform: translateY(-2px);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.top-site-card:focus-visible {
  outline: none;
}

.top-site-card:focus-visible .top-site-tile {
  border-color: var(--nt-input-focus-border);
  box-shadow: var(--nt-focus-ring);
}

/* Rectangular container: favicon + overlaid title */
.top-site-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: var(--nt-top-site-bg);
  border: 1px solid var(--nt-top-site-border);
  box-sizing: border-box;
  overflow: hidden;
  isolation: isolate;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.top-site-tile.kp-has-page-thumb {
  background-color: #0a0a0a;
  background-image: none;
  border-color: rgba(255, 255, 255, 0.12);
}

.top-site-tile.kp-has-page-thumb::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  background-color: #0a0a0a;
  background-image:
    /* Idle = former hover; hover lifts further */
    linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.68) 100%),
    var(--kp-page-thumb);
  background-size: 100% 100%, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

.top-site-tile.kp-has-page-thumb > * {
  position: relative;
  z-index: 1;
}

.top-site-card:hover .top-site-tile:not(.kp-has-page-thumb) {
  background: var(--nt-top-site-hover-bg);
  border-color: var(--nt-top-site-hover-border);
  box-shadow: var(--nt-top-site-hover-shadow);
}

.top-site-card:hover .top-site-tile.kp-has-page-thumb {
  background-color: #0a0a0a;
  background-image: none;
  border-color: var(--nt-top-site-hover-border);
  box-shadow: var(--nt-top-site-hover-shadow);
}

.top-site-card:hover .top-site-tile.kp-has-page-thumb::before {
  background-image:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0%, rgba(0, 0, 0, 0.42) 100%),
    var(--kp-page-thumb);
}

.top-site-favicon {
  width: 1.75rem; /* display box; source is upgraded to ~128px when available */
  height: 1.75rem;
  border-radius: 0.3rem;
  background: var(--nt-favicon-bg);
  flex-shrink: 0;
  object-fit: contain;
  image-rendering: auto;
}

/* Shared overlay text chrome on tiles */
.top-site-page-title,
.top-site-url {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  margin: 0;
  box-sizing: border-box;
  font-size: 0.5rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: left;
  color: var(--nt-fg-92);
  overflow: hidden;
  max-height: 2.4em; /* ~2 lines, then clip */
  word-break: break-word;
  pointer-events: none;
}

/* Page title: top of tile */
.top-site-page-title {
  top: 0;
  bottom: auto;
  padding: 3px 5px 4px;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.62) 0%,
    rgba(0, 0, 0, 0.32) 70%,
    transparent 100%
  );
}

/* URL / domain: bottom of tile — single-line ellipsis when it overflows */
.top-site-url {
  top: auto;
  bottom: 0;
  padding: 4px 5px 3px;
  font-family: var(--nt-font-mono);
  font-weight: 500;
  color: var(--nt-fg-78);
  max-height: none;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  word-break: normal;
  background: linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.62) 0%,
    rgba(0, 0, 0, 0.32) 70%,
    transparent 100%
  );
}

.top-site-card:hover .top-site-page-title,
.top-site-card:hover .top-site-url {
  color: #fff;
}

/* Legacy class kept so older markup does not break mid-session */
.top-site-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  overflow: hidden;
  max-height: 2.4em;
  pointer-events: none;
}
