@font-face {
  font-family: Manrope;
  src: url("/manrope-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Manrope;
  src: url("/manrope-cyrillic.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  color-scheme: dark;
  --background: #101421;
  --ambient: #243054;
  --surface: #212a40b8;
  --raised: #26324ce8;
  --sheet: #20293e;
  --small-surface: #f2f5ff08;
  --line: #ced9ff29;
  --glint: #dae5ff20;
  --ink: #f2f5ff;
  --muted: #b0bdd5;
  --accent: #bdccff;
  --accent-strong: #d5dfff;
  --accent-surface: #a6baff32;
  --skip: #fac8d0;
  --skip-tint: #e18da928;
  --shadow: #070c1ba0;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
  font-family: Manrope, system-ui, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #edf1f9;
  --ambient: #dbe4fd;
  --surface: #ffffffb8;
  --raised: #f8faffee;
  --sheet: #f5f7ff;
  --small-surface: #3d52830b;
  --line: #445b8d31;
  --glint: #ffffffb8;
  --ink: #17213b;
  --muted: #4a5975;
  --accent: #324e94;
  --accent-strong: #223c7f;
  --accent-surface: #7496f039;
  --skip: #802951;
  --skip-tint: #c36b8e25;
  --shadow: #364a702b;
}

* { box-sizing: border-box; }
h1, h2, h3, p, dl, dd { margin: 0; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 20%, var(--ambient), transparent 37rem), var(--background);
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 31px, var(--small-surface) 31px 32px);
  mask-image: radial-gradient(ellipse at 50% 26%, #000, transparent 67%);
  content: "";
}

.app {
  width: min(100%, 33rem);
  margin-inline: auto;
  padding: calc(1.2rem + var(--safe-top)) 1.25rem calc(6.8rem + var(--safe-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  gap: .68rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.brand-icon, .action, .order-row, .icon-button, .view-count {
  border: 1px solid var(--line);
  box-shadow: inset 0 1px var(--glint);
}

.brand-icon {
  display: grid;
  flex: none;
  width: 2.4rem;
  aspect-ratio: 1;
  place-items: center;
  border-radius: .85rem;
  color: #e4ebff;
  background: linear-gradient(#1a274b45, #18243c73), url("/radar-cover.webp") 56% 57% / cover #1a2743;
}

.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  flex: none;
  width: 1.28rem;
  height: 1.28rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-icon .icon { width: 1.45rem; height: 1.45rem; }

h1 { font-size: 1.06rem; font-weight: 800; letter-spacing: -.035em; }
h1 span { color: var(--accent); }

main { margin-top: 1.45rem; }

.section-heading, .detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
}

.section-heading { min-height: 2.1rem; margin-bottom: .95rem; }
.section-heading h2 { font-size: clamp(1.44rem, 6.7vw, 2rem); font-weight: 800; letter-spacing: -.055em; line-height: 1.15; }

.view-count {
  flex: none;
  padding: .3rem .62rem;
  border-radius: 99px;
  color: var(--muted);
  background: var(--small-surface);
  font-size: .73rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

button {
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled { opacity: .62; cursor: wait; }
button:focus-visible, a:focus-visible, article:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: var(--accent-strong); text-underline-offset: .2em; }

.tabs {
  position: fixed;
  z-index: 2;
  inset-inline: 0;
  bottom: calc(.72rem + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .3rem;
  width: min(calc(100% - 2.5rem), 30.5rem);
  margin-inline: auto;
  padding: .33rem;
  border: 1px solid var(--line);
  border-radius: 1.33rem;
  background: var(--raised);
  box-shadow: inset 0 1px var(--glint), 0 .45rem 1.6rem var(--shadow);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}

.tabs button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: .24rem;
  min-height: 3.3rem;
  border: 1px solid transparent;
  border-radius: 1rem;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 750;
  transition: background 160ms ease, color 160ms ease;
}

.tabs button[aria-pressed="true"] {
  border-color: var(--line);
  color: var(--accent-strong);
  background: linear-gradient(155deg, var(--accent-surface), var(--small-surface));
  box-shadow: inset 0 1px var(--glint);
}

.deck { position: relative; isolation: isolate; margin-bottom: 1.35rem; }
.deck::before {
  position: absolute;
  z-index: -1;
  inset: .7rem .56rem -.45rem;
  border: 1px solid var(--line);
  border-radius: 1.45rem;
  background: var(--surface);
  content: "";
}

.card, .empty-illustrated {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.52rem;
  background: var(--surface);
  box-shadow: inset 0 1px var(--glint), 0 .8rem 1.85rem var(--shadow);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
}

.card {
  padding: 1.12rem 1rem 1rem;
  background: linear-gradient(155deg, var(--glint), transparent 54%), var(--surface);
  cursor: pointer;
  touch-action: pan-y;
  transition: transform 160ms ease, border-color 160ms ease;
}
.card.is-dragging { transition: none; user-select: none; }
.card[data-swipe="review"] { border-color: var(--accent); }
.card[data-swipe="skipped"] { border-color: var(--skip); }

.source-link {
  display: inline-flex;
  align-items: center;
  gap: .36rem;
  min-height: 2.75rem;
  padding: .3rem .68rem;
  border: 1px solid var(--line);
  border-radius: .83rem;
  background: var(--small-surface);
  font-size: .78rem;
  font-weight: 750;
  text-decoration: none;
}
.source-link .icon { width: .97rem; height: .97rem; }
.card > .source-link { margin-bottom: .83rem; box-shadow: inset 0 1px var(--glint); }

.card h3 {
  margin-bottom: 1.03rem;
  font-size: clamp(1.19rem, 5.8vw, 1.85rem);
  font-weight: 800;
  line-height: 1.16;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}

.card-preview {
  display: -webkit-box;
  overflow: hidden;
  margin-top: .85rem;
  color: var(--muted);
  font-size: .83rem;
  font-weight: 550;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.metrics, .actions, .detail-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.metrics > div {
  min-width: 0;
  padding: .59rem .65rem;
  border: 1px solid var(--line);
  border-radius: .78rem;
  background: var(--small-surface);
}
.metrics dt { margin-bottom: .23rem; color: var(--muted); font-size: .69rem; font-weight: 700; }
.metrics dd { font-size: .93rem; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metrics .source { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: .55rem; }
.metrics .source dt { margin: 0; }

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 3rem;
  padding: .45rem .55rem;
  border-radius: .95rem;
  background: var(--surface);
  font-size: .86rem;
  font-weight: 800;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: background 160ms ease, transform 160ms ease;
}
.action .icon { width: 1.04rem; height: 1.04rem; }
.action.save { color: var(--accent-strong); background: linear-gradient(150deg, var(--accent-surface), var(--surface)); }
.action.skip { color: var(--skip); background: linear-gradient(150deg, var(--skip-tint), var(--surface)); }
.action:active { transform: scale(.98); }
.more { width: 100%; margin-top: .65rem; }

.hint, .feedback, .muted { color: var(--muted); font-size: .76rem; font-weight: 650; line-height: 1.5; }
.hint, .feedback { margin-top: .8rem; text-align: center; }
.feedback:empty, .muted:empty { display: none; }
.empty { padding: 2rem .95rem; color: var(--muted); text-align: center; }
.empty-section { display: grid; justify-items: center; gap: .8rem; }
.empty-symbol {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: .85rem;
  color: var(--accent);
  background: var(--small-surface);
}
.empty-illustrated { padding: 0; }
.empty-illustrated img { display: block; width: 100%; height: clamp(8.3rem, 35vw, 11.2rem); object-fit: cover; object-position: center 63%; background: #141d30; }
.empty-illustrated p { padding: 1.05rem 1rem; font-weight: 750; }

.order-list { display: grid; gap: .6rem; }
.order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  padding: .85rem .92rem;
  border-radius: 1rem;
  background: var(--surface);
  text-align: left;
  overflow-wrap: anywhere;
}
.order-row-copy { display: grid; gap: .28rem; min-width: 0; }
.order-row strong { font-size: .98rem; font-weight: 800; line-height: 1.3; }
.order-row-copy > span { color: var(--muted); font-size: .75rem; font-weight: 700; }
.order-row > .icon { color: var(--accent); width: 1.05rem; height: 1.05rem; }

dialog {
  width: min(calc(100% - 1.5rem), 33rem);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 1.75rem);
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  color: var(--ink);
  background: var(--sheet);
  box-shadow: inset 0 1px var(--glint), 0 1rem 3rem var(--shadow);
}
dialog::backdrop { background: #090f20ad; backdrop-filter: blur(5px); }
.detail-status {
  padding: .32rem .62rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--accent-strong);
  background: var(--accent-surface);
  font-size: .76rem;
  font-weight: 800;
}
.icon-button {
  display: grid;
  width: 2.75rem;
  place-items: center;
  border-radius: .82rem;
  color: var(--muted);
  background: var(--small-surface);
}
dialog h2 { margin: .65rem 0 1rem; font-size: 1.37rem; line-height: 1.2; letter-spacing: -.04em; overflow-wrap: anywhere; }
#detail-note { margin-top: .7rem; }
.detail-body { margin: .85rem 0 1.05rem; white-space: pre-wrap; line-height: 1.58; overflow-wrap: anywhere; }

@media (max-height: 680px) {
  .app { padding-top: calc(.85rem + var(--safe-top)); }
  .app-header { padding-bottom: .78rem; }
  main { margin-top: 1rem; }
  .card-preview { -webkit-line-clamp: 3; }
}

@media (min-height: 760px) {
  .card-preview { -webkit-line-clamp: 7; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
