:root {
  --bg-0: #071122;
  --bg-1: #0d1b34;
  --bg-2: #102748;
  --surface: rgba(13, 25, 47, 0.66);
  --surface-strong: rgba(18, 34, 60, 0.9);
  --line: rgba(190, 214, 255, 0.18);
  --line-strong: rgba(190, 214, 255, 0.28);
  --text: #f1f6ff;
  --muted: #a8bbda;
  --accent: #65d1ff;
  --accent-2: #8bffcf;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 8% 12%, rgba(101, 209, 255, 0.18), transparent 62%),
    radial-gradient(900px 700px at 92% 16%, rgba(139, 255, 207, 0.14), transparent 65%),
    radial-gradient(700px 500px at 50% 100%, rgba(93, 117, 255, 0.16), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg-0));
  font-family: "Avenir Next", "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 420px;
  height: 420px;
  filter: blur(24px);
  z-index: 0;
  opacity: 0.55;
  pointer-events: none;
}

body::before {
  top: -120px;
  left: -80px;
  background:
    radial-gradient(circle at 30% 30%, rgba(101, 209, 255, 0.45), transparent 65%),
    radial-gradient(circle at 70% 70%, rgba(122, 96, 255, 0.35), transparent 70%);
  animation: floatA 20s ease-in-out infinite;
}

body::after {
  right: -120px;
  bottom: -140px;
  background:
    radial-gradient(circle at 55% 35%, rgba(139, 255, 207, 0.42), transparent 68%),
    radial-gradient(circle at 30% 75%, rgba(101, 209, 255, 0.25), transparent 70%);
  animation: floatB 24s ease-in-out infinite;
}

@keyframes floatA {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(14px, 22px, 0) rotate(7deg); }
}

@keyframes floatB {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(-22px, -18px, 0) rotate(-9deg); }
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-items: center;
  padding: 28px;
  gap: 14px;
}

.shell {
  width: min(1120px, 100%);
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.site-footer {
  width: min(1120px, 100%);
  text-align: center;
  color: rgba(168, 187, 218, 0.8);
  font-size: 12px;
  line-height: 1.4;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hero {
  padding: 26px;
  display: grid;
  gap: 18px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -15% -35% auto;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, rgba(101, 209, 255, 0.2), transparent 60%),
    radial-gradient(circle at 65% 70%, rgba(139, 255, 207, 0.18), transparent 68%);
  z-index: -1;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.title-wrap {
  display: grid;
  gap: 6px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-2);
  opacity: 0.9;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.btn.primary {
  border-color: rgba(101, 209, 255, 0.3);
  background:
    linear-gradient(180deg, rgba(101, 209, 255, 0.16), rgba(101, 209, 255, 0.08)),
    rgba(255, 255, 255, 0.03);
}

.search-card {
  display: grid;
  gap: 12px;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.search-input {
  width: 100%;
  min-height: 56px;
  border-radius: 18px;
  border: 1px solid rgba(190, 214, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(7, 16, 31, 0.5);
  color: var(--text);
  padding: 0 18px;
  font-size: 16px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.search-input::placeholder {
  color: #9bb0d3;
}

.search-input:focus {
  border-color: rgba(101, 209, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(101, 209, 255, 0.14);
}

.search-submit {
  min-height: 56px;
  border-radius: 18px;
  border: 1px solid rgba(101, 209, 255, 0.35);
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  color: #081526;
  background:
    linear-gradient(135deg, rgba(139, 255, 207, 0.95), rgba(101, 209, 255, 0.95));
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(33, 140, 180, 0.18);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.search-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(33, 140, 180, 0.24);
}

.search-suggestions {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(190, 214, 255, 0.16);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(7, 16, 31, 0.58);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
}

.search-suggestion {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.search-suggestion:hover,
.search-suggestion.active {
  border-color: rgba(101, 209, 255, 0.28);
  background: rgba(101, 209, 255, 0.1);
  transform: translateY(-1px);
}

.search-suggestion-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.search-suggestion-text {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.search-suggestion-title {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-suggestion-meta {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-suggestion-scope {
  border: 1px solid rgba(190, 214, 255, 0.16);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.search-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.02);
}

.chip-button {
  appearance: none;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  line-height: inherit;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 6px 10px;
  box-shadow: none;
}

.chip-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
}

.chip-button:focus-visible {
  outline: none;
  border-color: rgba(101, 209, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(101, 209, 255, 0.12);
}

.favorites {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: 14px;
  border: 1px solid rgba(190, 214, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
}

.pager[hidden] {
  display: none !important;
}

.pager-btn {
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 10px;
}

.pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.pager-info {
  min-width: 64px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  user-select: none;
}

.add-btn {
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 14px;
  font-size: 22px;
  line-height: 1;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.favorites-grid.page-enter-forward {
  animation: favoritesPageEnterForward 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-origin: center center;
}

.favorites-grid.page-enter-backward {
  animation: favoritesPageEnterBackward 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-origin: center center;
}

@keyframes favoritesPageEnterForward {
  from {
    opacity: 0.2;
    transform: translate3d(18px, 0, 0) scale(0.992);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    filter: blur(0);
  }
}

@keyframes favoritesPageEnterBackward {
  from {
    opacity: 0.2;
    transform: translate3d(-18px, 0, 0) scale(0.992);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    filter: blur(0);
  }
}

.favorite-card {
  position: relative;
  min-height: 122px;
  border-radius: 18px;
  border: 1px solid rgba(190, 214, 255, 0.13);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    rgba(7, 16, 31, 0.35);
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.favorite-card:hover {
  transform: translateY(-2px);
  border-color: rgba(190, 214, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)),
    rgba(7, 16, 31, 0.42);
}

.favorite-main {
  width: 100%;
  height: 100%;
  min-height: 122px;
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 14px;
  cursor: pointer;
}

.favorite-card.empty {
  border-style: dashed;
  border-color: rgba(190, 214, 255, 0.18);
  background: rgba(7, 16, 31, 0.18);
}

.favorite-card.empty:hover {
  border-color: rgba(101, 209, 255, 0.36);
  background: rgba(7, 16, 31, 0.28);
}

.favorite-card.empty .favorite-main {
  grid-template-columns: 52px 1fr;
}

.card-edit {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(190, 214, 255, 0.16);
  background: rgba(11, 22, 42, 0.78);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 120ms ease, transform 120ms ease, border-color 120ms ease, color 120ms ease;
}

.favorite-card:hover .card-edit,
.favorite-card:focus-within .card-edit {
  opacity: 1;
  transform: translateY(0);
}

.card-edit:hover {
  color: var(--text);
  border-color: rgba(190, 214, 255, 0.28);
}

.icon-shell {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 1px solid rgba(190, 214, 255, 0.14);
  background:
    radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 58%),
    rgba(16, 28, 49, 0.8);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.icon-shell::after {
  content: "";
  position: absolute;
  inset: -15%;
  opacity: 0.22;
  background: var(--icon-bg, linear-gradient(135deg, rgba(101, 209, 255, 0.6), rgba(139, 255, 207, 0.6)));
  filter: blur(10px);
  pointer-events: none;
}

.icon-shell img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  z-index: 1;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.85);
  padding: 2px;
}

.icon-fallback {
  z-index: 1;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: white;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.card-text {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: center;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  white-space: normal;
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-url {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.favorite-card.title-wraps .card-url {
  display: none;
}

.empty .card-title {
  color: var(--muted);
}

.empty .card-url {
  color: rgba(168, 187, 218, 0.65);
}

.footer-note {
  color: var(--muted);
  font-size: 12px;
  padding: 0 2px;
}

dialog {
  width: min(520px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

dialog::backdrop {
  background: rgba(3, 8, 18, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-body {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h3 {
  margin: 0;
  font-size: 16px;
}

.dialog-close {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
}

.field input:not([type="radio"]):not([type="checkbox"]) {
  width: 100%;
  border: 1px solid rgba(190, 214, 255, 0.2);
  background: rgba(7, 16, 31, 0.45);
  color: var(--text);
  border-radius: 12px;
  min-height: 42px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

.field input:not([type="radio"]):not([type="checkbox"]):focus {
  border-color: rgba(101, 209, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(101, 209, 255, 0.12);
}

.inline-choice-group {
  display: grid;
  gap: 8px;
}

.inline-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(190, 214, 255, 0.2);
  border-radius: 12px;
  background: rgba(7, 16, 31, 0.45);
  color: var(--text);
  font-size: 13px;
}

.inline-choice input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  flex: 0 0 auto;
  margin: 0;
  accent-color: #65d1ff;
}

.field-hint {
  color: rgba(168, 187, 218, 0.78);
  font-size: 12px;
  line-height: 1.35;
}

.field-error {
  color: #ffb4b4;
  font-size: 12px;
  line-height: 1.35;
}

.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.actions-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn.danger {
  border-color: rgba(255, 153, 153, 0.25);
  color: #ffd2d2;
  background: rgba(255, 112, 112, 0.07);
}

.btn.danger:hover {
  border-color: rgba(255, 153, 153, 0.36);
  background: rgba(255, 112, 112, 0.1);
}

@media (max-width: 720px) {
  .page {
    padding: 14px;
  }

  .hero {
    padding: 16px;
  }

  .favorites {
    padding: 14px;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .search-submit {
    width: 100%;
  }

  .search-suggestion {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .search-suggestion-scope {
    grid-column: 2;
    justify-self: start;
  }

  .favorites-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-actions {
    width: 100%;
    justify-content: space-between;
  }

  .favorite-main {
    grid-template-columns: 44px 1fr;
    min-height: 108px;
  }

  .icon-shell {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .icon-shell img {
    width: 24px;
    height: 24px;
  }
}

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