@font-face {
  font-family: 'Geist';
  src: url('../assets/fonts/geist-latin-variable.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --line: #262626;
  --line-strong: #3a3a3a;
  --text: #ededed;
  --muted: #8f8f8f;
  --accent: #a3a6ff;
  --danger: #d93036;
  --radius: 0.75rem;
  --font: 'Geist', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --gutter: clamp(1rem, 3.2vw, 2.5rem);
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 0.9375rem/1.5 var(--font);
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.skip {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip:focus-visible {
  transform: translateY(0);
}

/* ---- top bar ----------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: grid;
  grid-template-columns: 1fr minmax(0, 34rem) 1fr;
  align-items: center;
  gap: 1rem;
  max-width: 112rem;
  margin: 0 auto;
  padding: 0.75rem var(--gutter);
}

.brand {
  justify-self: start;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.lite-tag {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.1rem 0.35rem;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  border-radius: 0.35rem;
  color: var(--accent);
  font-size: 0.675rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: 0.15em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: end;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4375rem 0.625rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 0.625rem;
  color: var(--muted);
  font-size: 0.8125rem;
  text-decoration: none;
  transition: color 0.12s, background-color 0.12s;
}

.icon-link:hover {
  background: var(--surface);
  color: var(--text);
}

.icon-link svg {
  width: 18px;
  height: 18px;
}

.icon-link span {
  font-variant-numeric: tabular-nums;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.875rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  color: var(--muted);
  transition: border-color 0.12s, color 0.12s;
}

.search:focus-within {
  border-color: var(--accent);
  color: var(--text);
}

.search svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.search input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0;
  background: none;
  border: 0;
  font-size: 0.875rem;
}

.search input:focus-visible {
  outline: none;
}

.search input::placeholder {
  color: var(--muted);
}

.primary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4375rem 0.875rem;
  border: 1px solid transparent;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 550;
  text-decoration: none;
}

.primary {
  background: var(--text);
  color: var(--bg);
}

.primary:hover:not(:disabled) {
  background: #fff;
}

.primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.primary svg,
.ghost svg {
  width: 16px;
  height: 16px;
}

.ghost {
  background: none;
  color: var(--muted);
}

.ghost:hover {
  color: var(--text);
}

.ghost-danger:hover {
  color: #ff6b70;
}

/* ---- lite line --------------------------------------------------------- */

.lite-line {
  border-bottom: 1px solid var(--line);
  background: #101010;
}

.lite-line-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  max-width: 112rem;
  margin: 0 auto;
  padding: 0.5rem var(--gutter);
  color: var(--muted);
  font-size: 0.75rem;
}

.lite-line a {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.lite-line a:hover {
  text-decoration: underline;
}

/* ---- toolbar ----------------------------------------------------------- */

.container {
  flex: 1 0 auto;
  width: 100%;
  max-width: 112rem;
  margin: 0 auto;
  padding: 1.5rem var(--gutter) 5rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
}

.tabs {
  display: flex;
  gap: 1.5rem;
  margin-right: auto;
}

.tabs button {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.375rem 0;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 550;
  transition: color 0.12s, border-color 0.12s;
}

.tabs button span {
  font-size: 0.8125rem;
  font-weight: 450;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.tabs button:hover {
  color: var(--text);
}

.tabs button[aria-pressed='true'] {
  border-bottom-color: var(--text);
  color: var(--text);
}

.summary {
  display: flex;
  gap: 0.75rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.summary span:last-child:not(:empty) {
  color: var(--text);
}

.menu {
  position: relative;
}

.menu-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3125rem 0.625rem 0.3125rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: border-color 0.12s;
}

.menu-button:hover,
.menu-button[aria-expanded='true'] {
  border-color: var(--line-strong);
}

.menu-button svg {
  width: 14px;
  height: 14px;
}

.menu-prefix {
  color: var(--muted);
}

.menu-list {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 11rem;
  padding: 0.25rem;
  background: var(--surface-2);
  border: 1px solid #333;
  border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.menu-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4375rem 0.625rem;
  background: none;
  border: 0;
  border-radius: 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: left;
}

.menu-list button svg {
  width: 14px;
  height: 14px;
  visibility: hidden;
}

.menu-list button[aria-checked='true'] {
  color: var(--text);
}

.menu-list button[aria-checked='true'] svg {
  visibility: visible;
  color: var(--accent);
}

.menu-list button:hover,
.menu-list button:focus-visible {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  outline: none;
}

/* ---- site chips -------------------------------------------------------- */

.sites {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.sites button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: color 0.12s, border-color 0.12s, background-color 0.12s;
}

.sites button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.sites button[aria-pressed='true'] {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--text);
}

.chip-count {
  font-variant-numeric: tabular-nums;
  opacity: 0.65;
}

/* ---- grid -------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr));
  gap: 1.75rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  position: relative;
  min-width: 0;
}

.card-link {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  color: inherit;
  text-decoration: none;
}

.media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #444;
}

.media-empty svg {
  width: 30px;
  height: 30px;
}

.media::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px transparent;
  transition: box-shadow 0.12s;
  pointer-events: none;
}

.card-link:hover .media::after,
.card-link:focus-visible .media::after {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.card-link:focus-visible {
  outline: none;
}

.badge {
  position: absolute;
  bottom: 0.5rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.125rem 0.4375rem;
  background: rgba(10, 10, 10, 0.78);
  backdrop-filter: blur(6px);
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.badge-duration {
  right: 0.5rem;
}

.badge-collection {
  left: 0.5rem;
  color: #d4d4d4;
}

.badge-collection svg {
  width: 13px;
  height: 13px;
}

.title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.9375rem;
  font-weight: 520;
  line-height: 1.35;
  letter-spacing: -0.012em;
  overflow-wrap: anywhere;
}

.host,
.note {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note {
  color: color-mix(in srgb, var(--accent) 55%, var(--muted));
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.625rem;
  max-height: 1.4em;
  margin-top: 0.125rem;
  overflow: hidden;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.tag {
  padding: 0;
  background: none;
  border: 0;
  color: color-mix(in srgb, var(--accent) 70%, var(--muted));
  white-space: nowrap;
}

button.tag:hover {
  color: var(--text);
  text-decoration: underline;
}

.card:hover .remove,
.card:focus-within .remove,
.card:hover .tool,
.card:focus-within .tool,
.pin[aria-pressed='true'] {
  opacity: 1;
}

.remove,
.tool {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: rgba(10, 10, 10, 0.78);
  backdrop-filter: blur(6px);
  border: 0;
  border-radius: 0.5rem;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.12s, background-color 0.12s;
}

.remove {
  top: 0.5rem;
  right: 0.5rem;
}

.remove:hover {
  background: #7f1d1d;
}

.remove svg,
.tool svg {
  width: 16px;
  height: 16px;
}

.card-tools {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 4;
  display: flex;
  gap: 0.25rem;
}

.pin[aria-pressed='true'] {
  color: var(--accent);
}

.pin[aria-pressed='true'] svg {
  fill: currentColor;
}

.tool:hover {
  background: rgba(40, 40, 46, 0.9);
}

.grid:not([data-order='default']) .pin {
  display: none;
}


@media (hover: none) {
  .remove,
  .tool {
    opacity: 1;
  }
}

.skeleton {
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 250% 100%;
  animation: shimmer 1.4s linear infinite;
}

.title-pending {
  display: block;
  width: 72%;
  height: 0.9375rem;
  margin: 0.25rem 0;
  border-radius: 0.3rem;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

/* ---- empty states ------------------------------------------------------ */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 18vh 1rem 0;
  text-align: center;
}

.empty h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.empty p {
  max-width: 30rem;
  margin: 0 0 1rem;
  color: var(--muted);
}

/* ---- dialogs ----------------------------------------------------------- */

dialog {
  width: min(36rem, calc(100vw - 2rem));
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
}

dialog.narrow {
  width: min(26rem, calc(100vw - 2rem));
}

dialog.confirm .hint {
  margin: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

dialog.confirm .dialog-actions {
  justify-content: flex-end;
  margin-top: 0.5rem;
}

dialog form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
}

dialog h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.hint {
  margin: -0.25rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.field,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  font-size: 0.9375rem;
}

.field {
  padding: 0.625rem 0.875rem;
}

textarea {
  padding: 0.75rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.55;
  resize: vertical;
  min-height: 8rem;
  max-height: 55vh;
}

.field:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.found {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* ---- trash ------------------------------------------------------------- */

.trash-dialog {
  width: min(46rem, calc(100vw - 2rem));
  max-height: min(80vh, 46rem);
}

.trash-dialog[open] {
  display: flex;
  flex-direction: column;
}

.trash-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
}

.trash-head .hint {
  margin: 0.25rem 0 0;
}

.trash-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 1rem 1.5rem;
  overflow-y: auto;
  list-style: none;
}

.trash-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.875rem;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}

.trash-thumb {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg);
  border-radius: 0.4rem;
  color: #444;
}

.trash-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trash-thumb span {
  display: grid;
  place-items: center;
  height: 100%;
}

.trash-info {
  min-width: 0;
}

.trash-info strong {
  display: block;
  overflow: hidden;
  font-size: 0.8125rem;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-info span {
  color: var(--muted);
  font-size: 0.75rem;
}

.trash-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.625rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 500;
}

.chip:hover {
  border-color: var(--line-strong);
}

.chip-danger {
  color: #ff6b70;
}

.trash-empty {
  padding: 2rem 1.5rem;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

.trash-foot {
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1.5rem 1.25rem;
  border-top: 1px solid var(--line);
}

/* ---- footer ------------------------------------------------------------ */

.footer {
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  max-width: 112rem;
  margin: 0 auto;
  padding: 1rem var(--gutter);
}

.footer .hint {
  margin: 0;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.footer .ghost {
  text-decoration: none;
}

/* ---- toasts ------------------------------------------------------------ */

.toasts {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: min(34rem, calc(100vw - 2rem));
  padding: 0.625rem 0.875rem;
  background: var(--surface-2);
  border: 1px solid #333;
  border-radius: 0.75rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.875rem;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}

.toast button {
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---- responsive -------------------------------------------------------- */

@media (max-width: 52rem) {
  .topbar {
    position: static;
  }

  .topbar-inner {
    grid-template-columns: 1fr auto;
    gap: 0.625rem 1rem;
  }

  .search {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .hide-small {
    display: none;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .tabs {
    flex: 1 1 100%;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .summary {
    margin-right: auto;
  }

  .sites {
    flex-wrap: nowrap;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sites button {
    flex-shrink: 0;
  }

  .trash-item {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .trash-actions-row {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

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