:root {
  --red: #d8001b;
  --red-dark: #9f0014;
  --ink: #17202e;
  --muted: #637083;
  --line: #dfe3e8;
  --canvas: #f3f5f7;
  --surface: #fff;
  --focus: #1d4ed8;
  --radius: 7px;
  --gap: clamp(5px, 0.55vw, 9px);
  --columns: 7;
  --button-height: 38px;
  --layer-preview: 30;
  --ease-out-expo: cubic-bezier(.16, 1, .3, 1);
  --font-ui: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
}

button,
input {
  font: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.quick-app {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.topbar {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(170px, auto) minmax(260px, 560px) auto;
  align-items: center;
  gap: 14px;
  padding: 6px 8px 9px;
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 5px;
  background: var(--red);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.brand-copy {
  min-width: 0;
  display: grid;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.command {
  min-height: 40px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 0 10px 0 12px;
  border: 1px solid #cbd2db;
  border-radius: var(--radius);
  background: var(--surface);
}

.command:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(29 78 216 / 12%);
}

.command svg {
  width: 20px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 2;
}

.command input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

.command input::placeholder {
  color: #687589;
  opacity: 1;
}

.command kbd {
  min-width: 24px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f7f8fa;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
}

.resource-links {
  display: inline-flex;
  justify-self: end;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.resource-links a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-decoration: none;
}

.resource-links a:hover {
  background: #f0f2f5;
  color: var(--ink);
}

.resource-links a.active {
  background: var(--red);
  color: #fff;
}

.statusbar {
  min-height: 39px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
}

.filter-tabs {
  max-width: 100%;
  display: inline-flex;
  gap: 3px;
  overflow: hidden;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.filter-tabs button {
  min-height: 27px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.filter-tabs button:hover {
  background: #f0f2f5;
  color: var(--ink);
}

.filter-tabs button[aria-pressed="true"] {
  background: var(--red);
  color: #fff;
}

#resultStatus {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.preview-toggle {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 0 7px;
  border: 1px solid #cbd2db;
  border-radius: 5px;
  background: var(--surface);
  color: #536072;
  font-size: 10px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
}

.preview-toggle:hover {
  border-color: #aeb7c3;
  background: #f8f9fa;
  color: var(--ink);
}

.preview-toggle-track {
  position: relative;
  width: 24px;
  height: 14px;
  flex: none;
  border-radius: 999px;
  background: #8792a3;
  transition: background 140ms ease-out;
}

.preview-toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(20 32 48 / 30%);
  transition: transform 160ms var(--ease-out-expo);
}

.preview-toggle[aria-checked="true"] .preview-toggle-track {
  background: var(--red);
}

.preview-toggle[aria-checked="true"] .preview-toggle-track::after {
  transform: translateX(10px);
}

.menu-workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 23vw, 420px);
  gap: 8px;
  overflow: hidden;
}

.previews-off .menu-workspace {
  grid-template-columns: minmax(0, 1fr);
}

.menu-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
  align-content: start;
  padding: 2px 8px 6px;
  overflow: hidden;
}

.menu-section {
  --tone: #1d638f;
  --tone-dark: #12415f;
  --tone-accent: #65b5dc;
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding: 9px;
  border: 1px solid rgb(22 34 50 / 13%);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 3px 8px rgb(20 32 48 / 8%);
}

.menu-section::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--tone-dark), var(--tone) 58%, var(--tone-accent));
}

.section-title {
  min-height: 26px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 2px 0 6px;
  color: var(--tone-dark);
  font-size: clamp(.9rem, 1.26vw, 1.125rem);
  font-weight: 800;
  line-height: 1;
}

.section-title span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .675rem;
  font-weight: 600;
}

.button-stack {
  min-height: 0;
  display: grid;
  grid-auto-rows: var(--button-height);
  gap: 6px;
  align-content: start;
}

.menu-item {
  position: relative;
  min-width: 0;
  min-height: var(--button-height);
}

.menu-link {
  min-width: 0;
  min-height: var(--button-height);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 100%;
  padding: 3px 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--tone), var(--tone-dark));
  color: #fff;
  box-shadow: 0 1px 3px rgb(20 32 48 / 18%);
  font-size: clamp(.825rem, 1.08vw, .975rem);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  white-space: normal;
  transition: transform 160ms cubic-bezier(.16, 1, .3, 1), box-shadow 160ms ease;
}

.menu-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgb(20 32 48 / 23%);
}

.menu-link:active {
  transform: translateY(1px);
}

.menu-item.has-broken .menu-link {
  box-shadow: inset 0 0 0 2px #ff4d4d, 0 1px 3px rgb(20 32 48 / 18%);
}

.menu-item.has-review .menu-link {
  box-shadow: inset 0 0 0 2px #ffd84d, 0 1px 3px rgb(20 32 48 / 18%);
}

.resource-status {
  position: absolute;
  z-index: 2;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 82%);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 1px 3px rgb(20 32 48 / 32%);
}

.resource-status-broken {
  background: #c40018;
  color: #fff;
}

.resource-status-review {
  background: #ffd84d;
  color: #3c2a00;
}

.resource-preview {
  --preview-tone: var(--red);
  --preview-tone-dark: var(--red-dark);
  --preview-tone-accent: #ff6074;
  position: relative;
  width: auto;
  max-height: 100%;
  align-self: start;
  margin: 2px 8px 6px 0;
  overflow: hidden;
  border: 1px solid rgb(22 34 50 / 13%);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 3px 8px rgb(20 32 48 / 8%);
  opacity: 1;
  visibility: visible;
  pointer-events: none;
  transform: none;
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
  contain: layout paint;
}

.resource-preview::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--preview-tone-dark), var(--preview-tone) 58%, var(--preview-tone-accent));
}

.resource-preview[data-open="true"] {
  border-color: color-mix(in srgb, var(--preview-tone) 46%, #cbd2db);
  box-shadow: 0 4px 12px rgb(20 32 48 / 13%);
}

.previews-off .resource-preview {
  display: none;
}

.resource-preview-heading {
  min-height: 52px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 10px 14px 8px;
}

.resource-preview-heading span {
  color: var(--preview-tone-dark);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.resource-preview-heading strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.1;
}

.resource-preview-media {
  position: relative;
  aspect-ratio: 8 / 5;
  overflow: hidden;
  border-block: 1px solid #d7dde4;
  background: #e8ecf0;
}

.resource-preview-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

.resource-preview-image[hidden] {
  display: none;
}

.resource-preview-fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-content: center;
  gap: 9px;
  padding: 28px;
  background: #e9edf1;
  color: var(--ink);
  text-align: center;
}

.resource-preview-media.is-missing .resource-preview-fallback {
  display: grid;
}

.resource-preview-fallback span {
  width: 46px;
  height: 40px;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 6px;
  background: var(--preview-tone);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}

.resource-preview-fallback strong {
  color: #394454;
  font-size: 13px;
  font-weight: 700;
}

.resource-preview-copy {
  padding: 14px 16px 16px;
}

.resource-preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #536072;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

.resource-preview-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-preview-meta span:first-child {
  color: var(--preview-tone-dark);
  font-family: var(--font-ui);
  font-weight: 800;
}

.resource-preview h2 {
  margin: 10px 0 6px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
  text-wrap: balance;
}

.resource-preview p {
  margin: 0;
  color: #3f4a5a;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.45;
  text-wrap: pretty;
}

.pager {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 5px 8px 0;
  border-top: 1px solid var(--line);
}

.single-screen-menu .pager {
  display: none;
}

.single-screen-menu.fixed-page-menu .quick-app {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.single-screen-menu.fixed-page-menu .pager {
  display: flex;
}

@media (min-width: 1180px) and (min-height: 700px) {
  .single-screen-menu {
    --button-height: 29px;
    --gap: 4px;
  }

  .single-screen-menu:not(.fixed-page-menu) .quick-app {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .single-screen-menu .menu-grid {
    padding-bottom: 8px;
  }

  .single-screen-menu.fixed-page-menu .menu-grid {
    align-items: stretch;
    align-content: stretch;
  }

  .single-screen-menu .menu-column {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .single-screen-menu .menu-column > .menu-section {
    flex: 0 0 auto;
    padding: 8px 5px 6px;
  }

  .single-screen-menu.fixed-page-menu .menu-column {
    height: 100%;
  }

  .single-screen-menu.fixed-page-menu .menu-column > .menu-section {
    flex: var(--section-weight) 1 0;
  }

  .single-screen-menu .section-title {
    min-height: 22px;
    margin-bottom: 4px;
    font-size: .825rem;
  }

  .single-screen-menu .button-stack {
    grid-template-rows: repeat(var(--item-count), var(--button-height));
    grid-auto-rows: unset;
    gap: 3px;
  }

  .single-screen-menu.fixed-page-menu .button-stack,
  .single-screen-menu.fixed-page-menu .menu-section.is-partial .button-stack {
    grid-template-rows: repeat(var(--item-count), minmax(var(--button-height), 1fr));
    align-content: stretch;
  }

  .single-screen-menu .menu-link {
    padding: 2px 6px;
    font-size: clamp(.675rem, .864vw, .825rem);
    line-height: 1.1;
  }

  .single-screen-menu.compact-results .menu-grid {
    grid-template-columns: repeat(var(--columns), minmax(280px, 360px));
    justify-content: start;
  }

  .single-screen-menu.compact-results .menu-column {
    height: auto;
    max-height: 100%;
  }

  .single-screen-menu.compact-results .menu-column > .menu-section {
    flex: 0 0 auto;
  }

  .single-screen-menu.compact-results .menu-section {
    align-self: stretch;
    height: auto;
  }

  .single-screen-menu.compact-results .button-stack {
    grid-template-rows: repeat(var(--item-count), var(--button-height));
  }
}

.page-tabs {
  display: inline-flex;
  gap: 4px;
}

.page-tabs button,
.pager-arrow {
  min-width: 34px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.page-tabs button[aria-current="page"] {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.pager-arrow:disabled {
  opacity: .35;
  cursor: default;
}

.page-summary {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

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

  .resource-links {
    display: none;
  }
}

@media (max-width: 760px), (hover: none) {
  .menu-workspace,
  .previews-off .menu-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .resource-preview,
  .preview-toggle {
    display: none;
  }
}

@media (max-width: 600px) {
  .quick-app {
    padding-inline: max(6px, env(safe-area-inset-left));
  }

  .topbar {
    min-height: 92px;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding-inline: 4px;
  }

  .brand-copy small,
  .command kbd,
  #resultStatus {
    display: none;
  }

  .resource-links {
    width: 100%;
    display: flex;
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
  }

  .resource-links a {
    min-height: 30px;
    flex: 1;
    justify-content: center;
  }

  .command {
    grid-column: 1 / -1;
    grid-row: 3;
    min-height: 42px;
  }

  .statusbar {
    padding-inline: 4px;
  }

  .filter-tabs {
    width: 100%;
  }

  .filter-tabs button {
    flex: 1;
    min-width: 0;
    padding-inline: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .menu-grid {
    padding-inline: 4px;
  }

  .menu-section {
    padding: 8px 6px 6px;
  }

  .section-title {
    font-size: .9rem;
  }

  .menu-link {
    padding-inline: 7px;
    font-size: .825rem;
  }
}

@media (pointer: coarse) {
  :root {
    --button-height: 44px;
  }

  .page-tabs button,
  .pager-arrow {
    min-width: 44px;
    min-height: 40px;
  }

  .menu-link {
    padding: 3px 7px;
  }
}

@media (hover: none) {
  .menu-link:hover {
    transform: none;
    box-shadow: 0 1px 3px rgb(20 32 48 / 18%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
