:root {
  color-scheme: dark;
  --bg: #0d0d11;
  --bg-soft: #16161c;
  --text: #f6f6f8;
  --hint: #94949f;
  --link: #ff86bd;
  --accent: #ff5c9e;
  --accent-text: #ffffff;
  --danger: #ff5f6d;
  --line: rgba(255, 255, 255, 0.09);
  --glass: rgba(255, 255, 255, 0.055);
  --radius: 24px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 50% -180px, rgba(255, 92, 158, 0.2), transparent 70%),
    radial-gradient(700px 420px at 110% 110%, rgba(120, 90, 255, 0.12), transparent 65%),
    var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app {
  height: 100dvh;
  max-width: 660px;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: #fff;
  background: linear-gradient(135deg, #ff6aa8, #a855f7 70%, #6366f1);
  box-shadow: 0 10px 26px rgba(255, 92, 158, 0.3);
  flex: 0 0 auto;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.brand-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.nsfw-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #ff5f6d, #ff2d55);
  box-shadow: 0 6px 18px rgba(255, 45, 85, 0.35);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--text);
  font-size: 17px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.11);
}

/* ----------------------------------------------------------------- stage */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.stage::-webkit-scrollbar {
  display: none;
}

.card {
  margin: auto 0;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.018));
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: card-in 0.32s cubic-bezier(0.22, 0.85, 0.3, 1);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.media {
  position: relative;
  min-height: 230px;
  max-height: 62dvh;
  background: #07070a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image {
  display: block;
  width: 100%;
  max-height: 62dvh;
  object-fit: contain;
  animation: image-in 0.25s ease;
}

@keyframes image-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    #191920 20%,
    #26262f 40%,
    #191920 60%
  );
  background-size: 220% 100%;
  animation: shimmer 1.25s linear infinite;
}

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

.media-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 5px 9px;
  border-radius: 8px;
  color: #fff;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.card-body {
  padding: 14px 16px 16px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.mini-chip {
  font-size: 11px;
  color: var(--hint);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  min-height: 18px;
}

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

.source {
  font-size: 12px;
  color: var(--link);
  text-decoration: none;
  flex: 0 0 auto;
}

.source:active {
  opacity: 0.7;
}

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

.empty {
  margin: auto;
  text-align: center;
  padding: 32px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-icon {
  font-size: 44px;
  filter: drop-shadow(0 10px 24px rgba(255, 92, 158, 0.25));
}

.empty h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.empty p {
  margin: 0 0 8px;
  color: var(--hint);
  font-size: 14px;
  line-height: 1.45;
  max-width: 320px;
}

/* ------------------------------------------------------------------ dock */

.dock {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 9px;
  padding-top: 2px;
}

.btn {
  height: 52px;
  padding: 0 20px;
  border-radius: 17px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.14s ease, opacity 0.14s ease, background 0.14s ease;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.primary {
  color: var(--accent-text);
  background: linear-gradient(135deg, #ff6aa8, #ff4f8d);
  box-shadow: 0 12px 30px rgba(255, 79, 141, 0.32);
}

.btn.ghost {
  color: var(--text);
  background: var(--glass);
  border-color: var(--line);
}

.btn.danger {
  color: #fff;
  background: linear-gradient(135deg, #ff5f6d, #ff2d55);
  box-shadow: 0 12px 30px rgba(255, 45, 85, 0.3);
}

.btn.grow {
  width: 100%;
}

.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------------------------------------------------------- sheets */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.scrim.visible {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  background: #141419;
  border-top: 1px solid var(--line);
  border-radius: 26px 26px 0 0;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateY(112%);
  transition: transform 0.32s cubic-bezier(0.22, 0.85, 0.3, 1);
  box-shadow: 0 -20px 70px rgba(0, 0, 0, 0.5);
}

.sheet.visible {
  transform: translateY(0);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
  flex: 0 0 auto;
}

.sheet-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.close {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 18px 10px;
  overflow-y: auto;
  align-content: flex-start;
}

.chip {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.chip:active {
  transform: scale(0.95);
}

.chip.active {
  color: var(--accent-text);
  background: linear-gradient(135deg, #ff6aa8, #ff4f8d);
  border-color: transparent;
}

/* -------------------------------------------------------------- settings */

.settings {
  padding: 2px 18px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.row-title {
  font-size: 14px;
  font-weight: 650;
}

.row-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--hint);
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: #33333d;
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s cubic-bezier(0.22, 0.85, 0.3, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(20px);
}

.setting-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.segmented {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.segmented button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--hint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented button.active {
  color: var(--accent-text);
  background: linear-gradient(135deg, #ff6aa8, #ff4f8d);
  border-color: transparent;
}

.hint {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--hint);
  text-align: center;
}

/* ----------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(420px, 100%);
  background: #17171d;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.24s cubic-bezier(0.22, 0.85, 0.3, 1);
}

.modal.visible .modal-card {
  transform: none;
}

.modal-icon {
  font-size: 38px;
  margin-bottom: 6px;
}

.modal-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.modal-card p {
  margin: 0 0 20px;
  color: var(--hint);
  font-size: 13.5px;
  line-height: 1.5;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 70;
  transform: translate(-50%, 14px);
  max-width: min(420px, calc(100vw - 40px));
  padding: 11px 16px;
  border-radius: 13px;
  background: rgba(28, 28, 36, 0.94);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* -------------------------------------------------------------- desktop */

@media (min-width: 720px) {
  .app {
    max-width: 560px;
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .sheet {
    left: 50%;
    right: auto;
    width: min(520px, 100%);
    bottom: 18px;
    border-radius: 26px;
    border: 1px solid var(--line);
    transform: translate(-50%, 120%);
  }

  .sheet.visible {
    transform: translate(-50%, 0);
  }
}
