/* =========================================================================
   Nebula — browser-style shell
   Design tokens first, then layout, then components.
   Light and dark are both fully defined; "system" follows the device.
   ========================================================================= */

/* ---------- Tokens: light (the base palette) ---------- */
:root {
  --bg-app: #dfe3ea;
  --bg-chrome: #eef1f6;
  --bg-surface: #ffffff;
  --bg-sunken: #f4f6fa;
  --bg-hover: rgba(15, 23, 42, 0.06);
  --bg-active: rgba(15, 23, 42, 0.11);

  --fg: #0f172a;
  --fg-muted: #5b6577;
  --fg-faint: #868f9f;
  --fg-invert: #ffffff;

  --line: rgba(15, 23, 42, 0.12);
  --line-strong: rgba(15, 23, 42, 0.22);

  --accent: #3b62f6;
  --accent-hover: #2f52dd;
  --accent-soft: rgba(59, 98, 246, 0.12);
  --accent-fg: #ffffff;

  --danger: #d33a3a;
  --danger-soft: rgba(211, 58, 58, 0.12);
  --warn: #b7791f;
  --ok: #17835a;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.22);

  --radius-sm: 7px;
  --radius: 11px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --tabstrip-h: 42px;
  --toolbar-h: 52px;

  --speed: 180ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

/* ---------- Tokens: dark ---------- */
:root[data-theme="dark"] {
  --bg-app: #0b0d12;
  --bg-chrome: #15181f;
  --bg-surface: #1c2029;
  --bg-sunken: #11141a;
  --bg-hover: rgba(255, 255, 255, 0.07);
  --bg-active: rgba(255, 255, 255, 0.13);

  --fg: #e8ecf4;
  --fg-muted: #9aa4b6;
  --fg-faint: #6e7889;
  --fg-invert: #0b0d12;

  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.2);

  --accent: #6d8bff;
  --accent-hover: #86a0ff;
  --accent-soft: rgba(109, 139, 255, 0.18);
  --accent-fg: #0b0d12;

  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.16);
  --warn: #e0b155;
  --ok: #4ecf9a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.7);

  color-scheme: dark;
}

/* System preference, only when the user has not chosen explicitly. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg-app: #0b0d12;
    --bg-chrome: #15181f;
    --bg-surface: #1c2029;
    --bg-sunken: #11141a;
    --bg-hover: rgba(255, 255, 255, 0.07);
    --bg-active: rgba(255, 255, 255, 0.13);

    --fg: #e8ecf4;
    --fg-muted: #9aa4b6;
    --fg-faint: #6e7889;
    --fg-invert: #0b0d12;

    --line: rgba(255, 255, 255, 0.11);
    --line-strong: rgba(255, 255, 255, 0.2);

    --accent: #6d8bff;
    --accent-hover: #86a0ff;
    --accent-soft: rgba(109, 139, 255, 0.18);
    --accent-fg: #0b0d12;

    --danger: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, 0.16);
    --warn: #e0b155;
    --ok: #4ecf9a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.7);

    color-scheme: dark;
  }
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* Components below set `display`, which would otherwise beat the UA rule for
   `[hidden]` and leave panels such as the drawer permanently visible. */
[hidden] { display: none !important; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 999;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* Global animation kill-switch (settings toggle + OS preference). */
:root[data-animations="off"] *,
:root[data-animations="off"] *::before,
:root[data-animations="off"] *::after {
  transition: none !important;
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* =========================================================================
   App shell
   ========================================================================= */
.app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100dvh;
  height: 100vh;
  min-height: 0;
}

/* ---------- Tab strip ---------- */
.tabstrip {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: var(--tabstrip-h);
  padding: 6px 8px 0;
  background: var(--bg-app);
  padding-top: max(6px, env(safe-area-inset-top));
  height: calc(var(--tabstrip-h) + env(safe-area-inset-top));
}

.tabstrip__scroll {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  flex: 0 1 auto;
  scroll-behavior: smooth;
}
.tabstrip__scroll::-webkit-scrollbar { display: none; }

.tabstrip__spacer { flex: 1 1 auto; }
.tabstrip__new { margin-bottom: 3px; }

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 46px;
  max-width: 220px;
  height: 34px;
  padding: 0 8px 0 11px;
  border: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
  animation: tab-in var(--speed) var(--ease);
}

@keyframes tab-in {
  from { transform: translateY(6px) scale(0.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}

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

.tab.is-active {
  background: var(--bg-chrome);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.tab__favicon {
  width: 15px;
  height: 15px;
  border-radius: 3px;
  flex: none;
  object-fit: contain;
  background: var(--bg-hover);
}

.tab__title {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
  flex: 1 1 auto;
  text-align: left;
}

.tab__close {
  width: 19px;
  height: 19px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: inherit;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.55;
  flex: none;
  padding: 0;
}
.tab__close svg { width: 12px; height: 12px; stroke-width: 2.3; }
.tab__close:hover { background: var(--bg-active); opacity: 1; }

.tab__spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toolbar ---------- */
.toolbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--toolbar-h);
  padding: 0 10px;
  background: var(--bg-chrome);
  border-bottom: 1px solid var(--line);
}

.toolbar__nav,
.toolbar__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.iconbtn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
              transform var(--speed) var(--ease);
}
.iconbtn:hover:not(:disabled) { background: var(--bg-hover); color: var(--fg); }
.iconbtn:active:not(:disabled) { transform: scale(0.92); }
.iconbtn:disabled { opacity: 0.32; cursor: default; }
.iconbtn.is-on { color: var(--accent); background: var(--accent-soft); }

/* Reload button swaps to a stop glyph while loading. */
.icon-stop { display: none; }
.toolbar.is-loading .icon-reload { display: none; }
.toolbar.is-loading .icon-stop { display: block; }

/* Theme button shows the icon for the mode you'd switch TO. */
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="system"] .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .icon-sun { display: block; }
  :root[data-theme="system"] .icon-moon { display: none; }
}

/* ---------- Omnibox ---------- */
.omnibox {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  padding: 0 4px 0 10px;
  background: var(--bg-sunken);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease),
              box-shadow var(--speed) var(--ease);
}
.omnibox:hover { background: var(--bg-surface); }
.omnibox:focus-within {
  background: var(--bg-surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.omnibox__scheme {
  display: grid;
  place-items: center;
  flex: none;
  color: var(--fg-faint);
}
.omnibox__scheme svg { width: 15px; height: 15px; display: none; }
.omnibox[data-mode="secure"] .icon-lock { display: block; color: var(--ok); }
.omnibox[data-mode="search"] .icon-search { display: block; }
.omnibox[data-mode="insecure"] .icon-warn { display: block; color: var(--warn); }

.omnibox__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: none;
  background: none;
  outline: none;
  font-size: 13.5px;
  text-overflow: ellipsis;
}
.omnibox__input::placeholder { color: var(--fg-faint); }

.omnibox__clear,
.omnibox__go { width: 28px; height: 28px; }
.omnibox__clear svg,
.omnibox__go svg { width: 15px; height: 15px; }

/* ---------- Suggestions ---------- */
.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  margin: 0;
  padding: 5px;
  list-style: none;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 52vh;
  overflow-y: auto;
  animation: pop var(--speed) var(--ease);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.suggest__item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
}
.suggest__item:hover,
.suggest__item.is-active { background: var(--accent-soft); }
.suggest__item svg { width: 15px; height: 15px; color: var(--fg-faint); }
.suggest__text { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest__kind {
  font-size: 11px;
  color: var(--fg-faint);
  flex: none;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
}

/* ---------- Progress ---------- */
.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
}
.progress__bar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 260ms var(--ease), opacity 260ms var(--ease);
}

/* ---------- Content ---------- */
.content {
  position: relative;
  min-height: 0;
  background: var(--bg-surface);
}
.panes { position: absolute; inset: 0; }

.pane {
  position: absolute;
  inset: 0;
  display: none;
  overflow: auto;
  background: var(--bg-surface);
  -webkit-overflow-scrolling: touch;
}
.pane.is-active { display: block; animation: fade var(--speed) var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.pane__frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--bg-surface);
}

/* ---------- Status bar ---------- */
.statusbar {
  padding: 4px 12px;
  font-size: 11.5px;
  color: var(--fg-muted);
  background: var(--bg-chrome);
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
   New Tab page
   ========================================================================= */
.newtab {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8vh 20px 40px;
  gap: 26px;
  background:
    radial-gradient(900px 420px at 50% -8%, var(--accent-soft), transparent 70%),
    var(--bg-surface);
}

.newtab__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: rise 420ms var(--ease);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.newtab__logo { width: 40px; height: 40px; }
.newtab__wordmark { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; margin: 0; }

.newtab__search {
  width: min(620px, 100%);
  display: flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding: 0 8px 0 18px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease);
  animation: rise 460ms var(--ease);
}
.newtab__search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md);
}
.newtab__search input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: none;
  outline: none;
  font-size: 15.5px;
}
.newtab__search button {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.newtab__search button:hover { background: var(--accent-hover); }
.newtab__search button:active { transform: scale(0.93); }

.newtab__section { width: min(860px, 100%); animation: rise 520ms var(--ease); }
.newtab__heading {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-faint);
  margin: 0 0 10px 4px;
}

.tilegrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
}
.tile:hover {
  transform: translateY(-3px);
  border-color: var(--line);
  box-shadow: var(--shadow-md);
}
.tile img, .tile .tile__letter {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: contain;
}
.tile__letter {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
  font-size: 15px;
}
.tile__label {
  font-size: 12px;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-muted);
}

.newtab__note {
  width: min(860px, 100%);
  font-size: 12.5px;
  color: var(--fg-faint);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  line-height: 1.6;
}

/* =========================================================================
   Error / info pages
   ========================================================================= */
.errorpage {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background: var(--bg-surface);
}
.errorpage__card {
  width: min(620px, 100%);
  text-align: center;
  animation: rise 300ms var(--ease);
}
.errorpage__glyph {
  width: 60px;
  height: 60px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--accent);
}
.errorpage__glyph svg { width: 30px; height: 30px; stroke-width: 1.6; }
.errorpage--warn .errorpage__glyph { background: var(--danger-soft); color: var(--danger); }

.errorpage h1 { font-size: 21px; margin: 0 0 10px; letter-spacing: -0.01em; }
.errorpage p { margin: 0 0 14px; color: var(--fg-muted); line-height: 1.65; }

.errorpage__detail {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: left;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin: 0 0 18px;
  color: var(--fg-muted);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.errorpage__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--speed) var(--ease), transform var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 15px; height: 15px; }

.btn--ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--fg);
}
.btn--ghost:hover { background: var(--bg-hover); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger); filter: brightness(1.08); }

.btn--danger-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--danger);
}
.btn--danger-ghost:hover { background: var(--danger-soft); }

/* =========================================================================
   Search hand-off page
   ========================================================================= */
.results {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.results__query { font-size: 20px; margin: 0 0 6px; }
.results__lead { color: var(--fg-muted); margin: 0 0 20px; line-height: 1.65; }

.results__engines { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 26px; }

.answer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  padding: 16px 18px;
  margin-bottom: 24px;
}
.answer h2 { font-size: 15.5px; margin: 0 0 8px; }
.answer p { margin: 0 0 10px; line-height: 1.7; color: var(--fg-muted); }
.answer__source { font-size: 12px; color: var(--fg-faint); }

.resultlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.resultlist a {
  display: block;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: background var(--speed) var(--ease);
}
.resultlist a:hover { background: var(--bg-hover); }
.resultlist .r__title { color: var(--accent); font-size: 15px; margin-bottom: 2px; }
.resultlist .r__url { font-size: 12px; color: var(--ok); margin-bottom: 3px; word-break: break-all; }
.resultlist .r__snippet { font-size: 13px; color: var(--fg-muted); line-height: 1.6; }

/* =========================================================================
   Reader view
   ========================================================================= */
.reader { max-width: 720px; margin: 0 auto; padding: 34px 22px 90px; }

.reader__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--fg-faint);
}
.reader__badge {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.reader h1 { font-size: 30px; line-height: 1.25; margin: 0 0 12px; letter-spacing: -0.02em; }
.reader__meta { color: var(--fg-faint); font-size: 13px; margin-bottom: 30px; }

.reader__body { font-size: 16.5px; line-height: 1.75; }
.reader__body h1, .reader__body h2, .reader__body h3,
.reader__body h4, .reader__body h5, .reader__body h6 {
  line-height: 1.3;
  margin: 1.8em 0 0.6em;
  letter-spacing: -0.01em;
}
.reader__body h1 { font-size: 25px; }
.reader__body h2 { font-size: 21px; }
.reader__body h3 { font-size: 18px; }
.reader__body p { margin: 0 0 1.15em; }
.reader__body a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.reader__body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
  margin: 1.6em auto;
}
.reader__body figure { margin: 1.6em 0; }
.reader__body figcaption { font-size: 13px; color: var(--fg-faint); text-align: center; margin-top: 8px; }
.reader__body blockquote {
  margin: 1.5em 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent);
  color: var(--fg-muted);
}
.reader__body pre {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}
.reader__body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-sunken);
  padding: 1px 5px;
  border-radius: 4px;
}
.reader__body pre code { background: none; padding: 0; }
.reader__body ul, .reader__body ol { padding-left: 1.4em; margin: 0 0 1.15em; }
.reader__body li { margin-bottom: 0.4em; }
.reader__body hr { border: none; border-top: 1px solid var(--line); margin: 2.2em 0; }
.reader__body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 1.5em 0;
  display: block;
  overflow-x: auto;
}
.reader__body th, .reader__body td {
  border: 1px solid var(--line);
  padding: 8px 11px;
  text-align: left;
}
.reader__body th { background: var(--bg-sunken); font-weight: 600; }

/* =========================================================================
   Drawer
   ========================================================================= */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(2, 6, 23, 0.5);
  backdrop-filter: blur(2px);
  animation: fade var(--speed) var(--ease);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--bg-chrome);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: slide-in 240ms var(--ease);
}
@keyframes slide-in {
  from { transform: translateX(100%); }
  to { transform: none; }
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 14px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer__title { font-size: 16px; margin: 0; }

.drawer__tabs {
  display: flex;
  gap: 3px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.drawer__tab {
  flex: 1;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-muted);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.drawer__tab:hover { background: var(--bg-hover); }
.drawer__tab.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }

.drawer__body { flex: 1; overflow-y: auto; padding: 14px; }

.panel__toolbar { display: flex; gap: 8px; margin-bottom: 12px; }

.field {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  outline: none;
  font-size: 13.5px;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.list__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--speed) var(--ease);
}
.list__item:hover { background: var(--bg-hover); }
.list__icon { width: 17px; height: 17px; border-radius: 4px; flex: none; background: var(--bg-hover); }
.list__text { flex: 1 1 auto; min-width: 0; }
.list__title {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list__sub {
  font-size: 11.5px;
  color: var(--fg-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list__remove {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-faint);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  flex: none;
}
.list__item:hover .list__remove { opacity: 1; }
.list__remove:hover { background: var(--danger-soft); color: var(--danger); }
.list__remove svg { width: 14px; height: 14px; }

.list__day {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
  padding: 14px 10px 5px;
}

.empty { text-align: center; color: var(--fg-faint); font-size: 13px; padding: 30px 16px; }

.setting { margin-bottom: 20px; }
.setting > label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--fg-muted); }
.setting--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.setting--row > label { margin: 0; }
.setting__heading { font-size: 13px; margin: 0 0 6px; }
.hint { font-size: 12px; color: var(--fg-faint); margin: 7px 0 0; line-height: 1.6; }

/* Toggle switch built from a checkbox. */
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 23px;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background var(--speed) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--speed) var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(17px); }

/* =========================================================================
   Toast
   ========================================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--fg);
  color: var(--bg-surface);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toast-in 260ms var(--ease);
  max-width: min(440px, calc(100vw - 40px));
  text-align: center;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.noscript {
  padding: 60px 24px;
  text-align: center;
  color: var(--fg);
}

/* =========================================================================
   Responsive — Chromebook, tablet, phone
   ========================================================================= */
@media (max-width: 900px) {
  .tab { max-width: 170px; }
}

@media (max-width: 720px) {
  :root { --toolbar-h: 50px; }

  .toolbar { flex-wrap: wrap; gap: 4px; padding: 0 6px; }
  .toolbar__nav { order: 1; }
  .toolbar__actions { order: 2; margin-left: auto; }
  .omnibox { order: 3; flex-basis: 100%; margin-bottom: 6px; }

  .toolbar { height: auto; padding-top: 6px; padding-bottom: 0; }
  .app { grid-template-rows: auto auto 1fr auto; }

  #btnHome { display: none; }
  .tab { max-width: 132px; }
  .newtab { padding-top: 6vh; }
  .newtab__wordmark { font-size: 25px; }
  .reader { padding: 24px 18px 70px; }
  .reader h1 { font-size: 25px; }
  .reader__body { font-size: 16px; }
  .drawer { width: 100%; }
}

@media (max-width: 420px) {
  .toolbar__actions #btnReader { display: none; }
  .tilegrid { grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); }
}

/* Chromebook / short-viewport laptops: reclaim vertical space. */
@media (max-height: 620px) {
  .newtab { padding-top: 4vh; gap: 18px; }
  .newtab__logo { width: 32px; height: 32px; }
  .newtab__wordmark { font-size: 24px; }
}

@media print {
  .tabstrip, .toolbar, .statusbar, .drawer, .scrim { display: none !important; }
  .app { display: block; height: auto; }
  body { overflow: visible; }
}
