:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --engine-color: #4285f4;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: #172033;
  background: #eef3f7;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  --page-bg: #eef3f7;
  --surface: rgba(255, 255, 255, 0.36);
  --surface-strong: rgba(255, 255, 255, 0.58);
  --surface-muted: rgba(255, 255, 255, 0.28);
  --border: rgba(255, 255, 255, 0.5);
  --border-strong: rgba(255, 255, 255, 0.72);
  --text: #172033;
  --muted: #66758c;
  --faint: #8795a8;
  --shadow: 0 24px 70px rgba(39, 58, 89, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --shadow-soft: 0 14px 34px rgba(39, 58, 89, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  --sidebar-bg: rgba(255, 255, 255, 0.42);
  --focus: rgba(66, 133, 244, 0.26);
  --glass-blur: blur(26px) saturate(1.45);
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(238, 243, 247, 0.32), rgba(238, 243, 247, 0.86)),
    url("../img/bg.png") center / cover fixed,
    var(--page-bg);
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.38), transparent 70%);
}

.app-shell[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #121313;
  --surface: rgba(36, 37, 35, 0.34);
  --surface-strong: rgba(44, 45, 42, 0.56);
  --surface-muted: rgba(55, 56, 52, 0.34);
  --border: rgba(255, 255, 255, 0.18);
  --border-strong: rgba(255, 255, 255, 0.28);
  --text: #f4f1ea;
  --muted: #beb7ac;
  --faint: #938d84;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  --shadow-soft: 0 14px 34px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  --sidebar-bg: rgba(28, 29, 27, 0.44);
  --focus: rgba(20, 184, 166, 0.28);
  background:
    linear-gradient(180deg, rgba(18, 19, 19, 0.45), rgba(18, 19, 19, 0.88)),
    url("../img/bg-night.jpg") center / cover fixed,
    var(--page-bg);
}

.app-shell[data-wallpaper="off"] {
  background:
    linear-gradient(135deg, rgba(249, 250, 251, 0.86), rgba(228, 235, 242, 0.92)),
    var(--page-bg);
}

.app-shell[data-theme="dark"][data-wallpaper="off"] {
  background:
    linear-gradient(135deg, rgba(18, 19, 19, 0.98), rgba(38, 37, 35, 0.96)),
    var(--page-bg);
}

.menu-toggle {
  position: fixed;
  z-index: 40;
  top: 22px;
  left: 22px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text);
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(39, 58, 89, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 15px;
  height: 2px;
  margin: 2.5px auto;
  background: currentColor;
  border-radius: 999px;
  transition: transform 160ms ease, opacity 160ms ease;
}

.is-menu-open .menu-toggle span:nth-child(1) {
  transform: translateY(4.5px) rotate(45deg);
}

.is-menu-open .menu-toggle span:nth-child(2) {
  opacity: 0;
}

.is-menu-open .menu-toggle span:nth-child(3) {
  transform: translateY(-4.5px) rotate(-45deg);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: min(330px, 88vw);
  flex-direction: column;
  gap: 24px;
  padding: 88px 22px 26px;
  overflow-y: auto;
  color: var(--text);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  box-shadow: 18px 0 60px rgba(15, 23, 42, 0.16);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transform: translateX(-105%);
  transition: transform 220ms ease;
}

.is-menu-open .sidebar {
  transform: translateX(0);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: none;
  background: rgba(17, 24, 39, 0.34);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.is-menu-open .scrim {
  display: block;
}

.sidebar__brand {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
  align-items: center;
}

.brand-mark,
.brand-chip {
  display: grid;
  place-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.brand-mark {
  width: 46px;
  height: 46px;
}

.brand-mark img,
.brand-chip img {
  width: 27px;
  height: 27px;
  object-fit: contain;
}

.sidebar__eyebrow,
.kicker,
.section-heading__eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
  font-weight: 760;
}

.sidebar h1 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.1;
}

.sidebar__sections {
  display: grid;
  gap: 20px;
}

.sidebar-section h2 {
  margin: 0 0 10px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
  font-weight: 820;
}

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

.sidebar-link,
.sidebar-action {
  display: flex;
  min-width: 0;
  min-height: 58px;
  flex-direction: column;
  justify-content: center;
  padding: 10px 11px;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.sidebar-link:hover,
.sidebar-action:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--surface-strong);
}

.sidebar-link span,
.sidebar-action span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 760;
}

.sidebar-link small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.sidebar__controls {
  margin-top: auto;
}

.sidebar-action {
  align-items: flex-start;
  gap: 7px;
  text-align: left;
}

.sidebar-action__icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--engine-color);
  background: color-mix(in srgb, var(--engine-color) 12%, transparent);
  border-radius: 999px;
}

.sidebar__footer {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

.sidebar__footer a {
  color: var(--muted);
  font-weight: 760;
}

.start-page {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto 1fr auto;
  padding: clamp(110px, 18vh, 172px) clamp(18px, 5vw, 64px) 30px;
}

.search-stage {
  width: min(760px, 100%);
  margin: 0 auto;
  text-align: center;
}

.search-panel {
  position: relative;
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 36px;
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.search-panel::before,
.bookmark-card__icon::before,
.engine-menu::before,
.suggestions::before {
  content: "";
  position: absolute;
  inset: 1px;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.42), transparent 36%, rgba(255, 255, 255, 0.08));
  opacity: 0.8;
}

.search-panel__engine {
  position: relative;
}

.engine-current,
.engine-option {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.engine-current {
  justify-content: flex-start;
  min-height: 44px;
  padding: 6px 9px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

.engine-current img,
.engine-option img {
  width: 24px;
  height: 24px;
  padding: 4px;
  object-fit: contain;
  background: color-mix(in srgb, var(--surface-strong) 82%, white);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.engine-current span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 780;
}

.engine-current__chevron {
  margin-left: auto;
  color: var(--muted);
}

.engine-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 10;
  display: none;
  width: min(250px, 88vw);
  padding: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  overflow: hidden;
}

.engine-menu.is-open {
  display: grid;
  gap: 4px;
}

.engine-option {
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 999px;
  text-align: left;
}

.engine-option:hover,
.engine-option.is-active {
  background: color-mix(in srgb, var(--engine-color) 12%, transparent);
}

.engine-option.is-active {
  color: var(--engine-color);
  font-weight: 780;
}

.search-form {
  position: relative;
  display: flex;
  align-items: center;
}

.search-form input {
  width: 100%;
  min-height: 44px;
  padding: 0 54px 0 16px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.search-form input:focus {
  border-color: var(--engine-color);
  background: var(--surface-strong);
  box-shadow: 0 0 0 4px var(--focus);
}

.search-submit {
  position: absolute;
  right: 5px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--engine-color);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.search-submit:hover {
  transform: translateX(1px);
  filter: brightness(1.04);
}

.search-submit span {
  font-size: 21px;
  line-height: 1;
}

.suggestions {
  position: absolute;
  top: calc(100% + 10px);
  right: 8px;
  left: 174px;
  z-index: 8;
  display: grid;
  padding: 8px;
  text-align: left;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  overflow: hidden;
}

.suggestions[hidden] {
  display: none;
}

.suggestions a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 999px;
}

.suggestions a:hover {
  background: color-mix(in srgb, var(--engine-color) 10%, transparent);
}

.suggestions span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: var(--engine-color);
  background: color-mix(in srgb, var(--engine-color) 13%, transparent);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 820;
}

.suggestions strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.bookmark-section {
  width: min(980px, 100%);
  margin: clamp(72px, 13vh, 132px) auto 0;
}

.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 16px 14px;
}

.bookmark-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 0;
  padding: 14px 8px 12px;
  color: var(--text);
  border: 0;
  border-radius: 32px;
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.bookmark-card:hover {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  box-shadow: 0 18px 38px color-mix(in srgb, var(--accent) 18%, rgba(39, 58, 89, 0.1));
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}

.bookmark-card__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  background: var(--surface-strong);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: 999px;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--accent) 14%, rgba(39, 58, 89, 0.12));
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  overflow: hidden;
}

.bookmark-card__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  transform: scale(1.08);
}

.bookmark-card__text {
  min-width: 0;
  max-width: 100%;
  text-align: center;
}

.bookmark-card__text strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.25;
}

.bookmark-card__text small {
  display: none;
}

.site-footer {
  margin-top: 38px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.site-footer a {
  font-weight: 760;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .app-shell {
    background:
      linear-gradient(180deg, rgba(238, 243, 247, 0.48), rgba(238, 243, 247, 0.9)),
      url("../img/bg-xs.png") center / cover fixed,
      var(--page-bg);
  }

  .app-shell[data-theme="dark"] {
    background:
      linear-gradient(180deg, rgba(18, 19, 19, 0.58), rgba(18, 19, 19, 0.9)),
      url("../img/bg-night.jpg") center / cover fixed,
      var(--page-bg);
  }

  .menu-toggle {
    top: 20px;
    left: 18px;
  }

  .start-page {
    padding: 112px 15px 28px;
  }

  .search-stage {
    margin-top: 0;
  }

  .search-panel {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .suggestions {
    right: 12px;
    left: 12px;
  }

  .bookmark-section {
    margin-top: 54px;
  }

  .bookmark-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 8px;
  }

  .bookmark-card {
    padding: 10px 4px;
  }

  .bookmark-card__icon {
    width: 48px;
    height: 48px;
  }

  .bookmark-card__icon img {
    width: 100%;
    height: 100%;
  }

  .sidebar-links,
  .sidebar__controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .bookmark-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
