:root {
  --bg: #08090b;
  --bg-elevated: #101216;
  --fg: #e8eef2;
  --fg-muted: #8b959e;
  --fg-subtle: #5c656d;
  --horizon: color-mix(in oklab, var(--fg) 14%, transparent);
  --ice: #e8eef2;
  --void: #050506;
  --font-display: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --text-xs: 0.68rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

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

* {
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
}

html {
  -webkit-font-smoothing: antialiased;
  background: #08090b;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: #08090b;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.5;
}

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

button,
[role="button"] {
  cursor: pointer;
}

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

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.chrome {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 12px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-left: calc(12px + env(safe-area-inset-left, 0px));
  padding-right: calc(12px + env(safe-area-inset-right, 0px));
  pointer-events: none;
}

.chrome-row {
  --frame: 16px;
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: var(--frame);
  border-radius: 22px;
  background: rgba(18, 20, 24, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 0.5px 0 rgba(255, 255, 255, 0.18) inset,
    0 12px 36px rgba(0, 0, 0, 0.22);
  isolation: isolate;
}

.chrome-row::before,
.viewer-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(
    320px 180px at var(--glint-x, 38%) var(--glint-y, 26%),
    rgba(255, 255, 255, 0.16),
    transparent 64%
  );
  mix-blend-mode: soft-light;
}

.chrome-row::after,
.viewer-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
  padding: 1.5px;
  background: conic-gradient(
    from var(--glint-a, 120deg),
    rgba(210, 236, 255, 0.04),
    rgba(190, 230, 255, 0.82) 8%,
    rgba(255, 214, 236, 0.4) 16%,
    rgba(255, 255, 255, 0.08) 28%,
    rgba(170, 220, 255, 0.7) 52%,
    rgba(255, 255, 255, 0.32) 60%,
    rgba(210, 236, 255, 0.05) 78%,
    rgba(255, 210, 240, 0.38) 90%,
    rgba(210, 236, 255, 0.04)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.chrome-row.is-stowed::before,
.chrome-row.is-stowed::after,
.chrome-row.is-blooming::before,
.chrome-row.is-blooming::after {
  display: none;
}

.chrome-row.is-slim .ticker {
  display: none;
}

.chrome-top,
.ticker {
  position: relative;
  z-index: 1;
}

.chrome-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: 88px;
  height: 30px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
}

.mark-glow,
.mark-frost,
.mark-bevel {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-mask: url("/icons/mark.png") center / contain no-repeat;
  mask: url("/icons/mark.png") center / contain no-repeat;
}

.mark-glow {
  inset: -30%;
  background: url("/icons/mark.png") center / contain no-repeat;
  filter: blur(16px) brightness(2.4);
  opacity: 0;
  -webkit-mask: none;
  mask: none;
}

.mark-frost {
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.42), rgba(196, 208, 218, 0.16) 48%, rgba(18, 20, 24, 0.18)),
    rgba(220, 230, 238, 0.18);
}

.mark-img {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.36;
}

.mark-bevel {
  z-index: 2;
  background: conic-gradient(
    from var(--glint-a, 130deg),
    transparent 0%,
    rgba(210, 236, 255, 0.8) 8%,
    transparent 22%,
    rgba(255, 255, 255, 0.45) 48%,
    transparent 62%,
    rgba(190, 220, 255, 0.55) 82%,
    transparent 100%
  );
  mix-blend-mode: screen;
  opacity: 0.72;
}

.chrome-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.wordmark,
.nav-set {
  position: relative;
  z-index: 1;
}

.wordmark {
  display: block;
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1;
  color: #fff;
  white-space: nowrap;
}

.nav-set {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  font-family: var(--font-display);
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 500;
}

.nav-link:last-child {
  padding-right: 0;
}

.nav-link:hover,
.nav-link[aria-pressed="true"] {
  color: #fff;
}

.ticker {
  display: flex;
  align-items: center;
  overflow: hidden;
  touch-action: none;
  min-height: 22px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(0, 0, 0, 0.35);
}

.filters {
  display: flex;
  width: max-content;
  cursor: grab;
}

.filters.is-dragging {
  cursor: grabbing;
}

.ticker-run {
  display: flex;
  align-items: center;
  padding: 0 14px;
  height: 22px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: rgba(243, 245, 247, 0.86);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chip[aria-pressed="true"] {
  color: #fff;
}

main {
  position: relative;
  padding: 0 8px 8px;
  padding-left: calc(8px + env(safe-area-inset-left, 0px));
  padding-right: calc(8px + env(safe-area-inset-right, 0px));
}

.field {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

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

.sentinel {
  height: 1px;
}

.tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--ar, 1);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--void);
  overflow: hidden;
}

.tile-frame {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 18px 6px rgba(8, 9, 11, 0.45);
  background: radial-gradient(130% 120% at 50% 50%, transparent 46%, rgba(8, 9, 11, 0.72) 100%);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.tile img.is-in {
  opacity: 1;
}

.tile-copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: 28px 10px 10px;
  background: linear-gradient(to top, rgba(5, 5, 6, 0.82), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 360ms var(--ease-out);
}

.tile.is-caption .tile-copy {
  opacity: 1;
}

.tile-copy .meta {
  display: block;
  color: var(--fg-muted);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.empty {
  max-width: 28ch;
  margin: 22vh auto;
  text-align: center;
}

.empty-hint {
  color: var(--fg-subtle);
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
}

.viewer[hidden] {
  display: none;
}

body.is-viewing .chrome,
body.is-viewing main {
  pointer-events: none;
}

.viewer-back {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(5, 5, 6, 0.72);
}

.viewer-hold,
.viewer-stage {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: 100%;
}

.viewer-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  padding: 12px;
  border-radius: 20px;
  background: rgba(232, 238, 242, 0.08);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(232, 238, 242, 0.16);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.viewer-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 148px);
}

.viewer-shell img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 148px);
  object-fit: contain;
  border-radius: 10px;
  opacity: 0;
}

.viewer-shell img.is-in {
  opacity: 1;
}

.viewer-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.glass-chip {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(232, 238, 242, 0.16);
  border-radius: 999px;
  background: rgba(232, 238, 242, 0.08);
  color: var(--ice);
  font: inherit;
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.manual-shell {
  width: min(640px, calc(100vw - 28px));
  max-height: min(84dvh, 760px);
  overflow: auto;
  align-items: stretch;
}

.manual-shell h2 {
  margin: 22px 16px 0;
  font-size: 21px;
  font-weight: 600;
}

.manual-shell .search-wrap {
  display: block;
  margin: 12px 16px 0;
}

.manual-shell .search {
  width: 100%;
  height: 44px;
  border: 0;
  border-bottom: 1px solid var(--horizon);
  background: transparent;
  color: #fff;
  font-size: 21px;
}

.manual-sort {
  display: block;
  margin: 12px 16px 16px;
  padding: 0;
  border: 0;
  background: none;
  color: rgba(232, 238, 242, 0.78);
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.manual-sort[aria-pressed="true"] {
  color: #fff;
}

.manual-group {
  margin: 0 8px 18px;
}

.manual-group h3 {
  margin: 0 4px 8px;
  color: var(--fg-subtle);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.manual-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.viewer-tools {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.dl,
.close {
  position: absolute;
  top: 16px;
  z-index: 5;
}

.dl {
  left: 16px;
}

.close {
  right: 16px;
}

.forget {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #ff4d4d;
  min-width: 88px;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.delete-ask {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  transform: translate(-50%, -50%);
  min-width: 196px;
  padding: 16px 16px 14px;
  border-radius: 16px;
  background: rgba(18, 20, 24, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 0.5px 0 rgba(255, 255, 255, 0.18) inset,
    0 12px 36px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.delete-ask[hidden] {
  display: none;
}

.delete-ask p {
  margin: 0 0 12px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.delete-ask-row {
  display: flex;
  gap: 8px;
}

.delete-ask-row button {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
}

#delete-yes {
  background: #ff4d4d;
  color: #fff;
}

#delete-no {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.gate-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
}

.gate-layer[hidden] {
  display: none;
}

.gate {
  width: min(280px, calc(100vw - 40px));
  padding: 18px 16px 14px;
  border-radius: 16px;
  background: rgba(18, 20, 24, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 0.5px 0 rgba(255, 255, 255, 0.18) inset,
    0 12px 36px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.gate p {
  margin: 0 0 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.gate input {
  width: 100%;
  min-height: 40px;
  margin: 0 0 12px;
  padding: 0 12px;
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font: inherit;
}

.gate-row {
  display: flex;
  gap: 8px;
}

.gate-row button {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
}

#gate-ok {
  background: rgba(255, 255, 255, 0.16);
}

#gate-cancel {
  background: rgba(255, 255, 255, 0.08);
}

#viewer .viewer-tools .glass-chip {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  opacity: 0;
  pointer-events: none;
  background: rgba(18, 20, 24, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 0.5px 0 rgba(255, 255, 255, 0.18) inset,
    0 12px 36px rgba(0, 0, 0, 0.22);
}

#viewer .viewer-tools .forget {
  color: #ff4d4d;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
}

#viewer .viewer-tools .glass-chip svg {
  width: 16px;
  height: 16px;
}

#viewer.is-tooled .viewer-tools .close,
#viewer.is-tooled .viewer-tools .dl,
#viewer.is-tooled .forget.is-ready {
  opacity: 1;
  pointer-events: auto;
}

#viewer .viewer-tools .forget {
  color: #ff4d4d;
}

#viewer .delete-ask {
  pointer-events: auto;
}

.manual-shell .close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(8, 9, 11, 0.55);
  color: var(--ice);
}

.suggest {
  display: flex;
  flex-direction: column;
  margin: 8px 16px 0;
}

.suggest[hidden] {
  display: none;
}

.suggest button {
  width: 100%;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
}

.toast-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.toast-layer[hidden] {
  display: none;
}

.toast {
  min-width: 280px;
  padding: 24px 32px;
  border-radius: 20px;
  background: rgba(232, 238, 242, 0.14);
  backdrop-filter: blur(34px);
  -webkit-backdrop-filter: blur(34px);
  color: var(--ice);
  text-align: center;
  pointer-events: auto;
}

.toast strong {
  display: block;
  color: #6fefb0;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.confirm-layer {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 20px;
}

.confirm-layer[hidden] {
  display: none;
}

.confirm {
  min-width: 240px;
  padding: 22px 22px 18px;
  border-radius: 18px;
  background: rgba(18, 20, 24, 0.55);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.confirm p {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}

.confirm-row {
  display: flex;
  gap: 10px;
}

.confirm-yes,
.confirm-no {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
}

.confirm-yes {
  background: #fff;
  color: #111;
}

.confirm-no {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ice);
  background: var(--ice);
  color: var(--bg);
}

@media (max-width: 800px) {
  .chrome {
    padding: 10px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    padding-left: calc(10px + env(safe-area-inset-left, 0px));
    padding-right: calc(10px + env(safe-area-inset-right, 0px));
  }
}

@media (max-width: 800px) and (orientation: portrait) {
  .chrome {
    display: flex;
    justify-content: center;
    z-index: 60;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
  }

  .chrome-row {
    width: 100%;
    max-width: 100%;
    gap: 6px;
    padding: 10px 12px 8px;
    border-radius: 20px;
  }

  .chrome-row.is-stowed,
  .chrome-row.is-blooming {
    width: 164px;
    max-width: 164px;
    height: 56px;
    padding: 0;
    gap: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    cursor: pointer;
  }

  .chrome-row.is-stowed .chrome-mark,
  .chrome-row.is-blooming .chrome-mark {
    display: block;
    position: relative;
    left: auto;
    top: auto;
    width: 164px;
    height: 56px;
    transform: none;
  }

  .chrome-row:not(.is-stowed):not(.is-blooming) .chrome-mark,
  .chrome-row.is-stowed .wordmark,
  .chrome-row.is-stowed .nav-set,
  .chrome-row.is-stowed .ticker,
  .chrome-row.is-blooming .wordmark,
  .chrome-row.is-blooming .nav-set,
  .chrome-row.is-blooming .ticker {
    display: none !important;
  }

  .chrome-row.is-blooming .chrome-mark {
    animation: mark-bloom 460ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }

  .chrome-row.is-blooming .mark-glow {
    animation: mark-halo 460ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }

  .chrome-row.is-revealing {
    animation: card-reveal 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  .chrome-top {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .chrome-row.is-stowed .chrome-top,
  .chrome-row.is-blooming .chrome-top {
    justify-content: center;
    height: 100%;
    gap: 0;
  }

  .wordmark {
    width: 100%;
    font-size: 15px;
    text-align: center;
  }

  .nav-set {
    width: 100%;
    max-width: none;
    justify-content: space-between;
    margin-left: 0;
  }

  .nav-link {
    flex: 1 1 0;
    justify-content: center;
    padding: 0;
    font-size: 12px;
  }
}

@keyframes mark-bloom {
  0% {
    transform: scale(1);
    filter: blur(0) brightness(1);
    opacity: 1;
  }
  42% {
    transform: scale(1.42);
    filter: blur(6px) brightness(2.15);
    opacity: 1;
  }
  100% {
    transform: scale(2.15);
    filter: blur(28px) brightness(2.8);
    opacity: 0;
  }
}

@keyframes mark-halo {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  32% {
    opacity: 0.95;
    transform: scale(1.55);
  }
  100% {
    opacity: 0;
    transform: scale(2.6);
  }
}

@keyframes card-reveal {
  0% {
    opacity: 0;
    filter: blur(22px);
  }
  100% {
    opacity: 1;
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chrome-row.is-blooming .chrome-mark,
  .chrome-row.is-blooming .mark-glow,
  .chrome-row.is-revealing {
    animation: none;
  }
}
