:root {
  color-scheme: dark;
  --page: #07101f;
  --panel: #101e2f;
  --panel-2: #0b1726;
  --line: rgba(176, 207, 237, 0.12);
  --text: #eaf4ff;
  --muted: #91a8c0;
  --cyan: #25b9ee;
  --cyan-bright: #66d7ff;
  --gold: #ffc44d;
  --danger: #ff7588;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Trebuchet MS", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0, rgba(37,185,238,.1), transparent 32rem),
    var(--page);
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 66px;
  padding: env(safe-area-inset-top, 0px) clamp(18px, 5vw, 64px) 0;
  background: rgba(7,16,31,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; color: white; text-decoration: none; font-size: 21px; font-weight: 900; letter-spacing: -.06em; }
.brand > span:last-child > span { color: var(--cyan); }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: #07101f; background: var(--cyan); font-weight: 1000; box-shadow: 0 0 26px rgba(37,185,238,.22); }
.desktop-nav { display: flex; gap: 30px; align-items: center; }
.desktop-nav a, .desktop-nav button { position: relative; padding: 23px 0 20px; border: 0; color: var(--muted); background: none; text-decoration: none; font-size: 13px; font-weight: 800; cursor: pointer; }
.desktop-nav a:hover, .desktop-nav button:hover, .desktop-nav .active { color: white; }
.desktop-nav .active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--cyan); border-radius: 99px 99px 0 0; }
.connection { justify-self: end; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(255,196,77,.1); }
.connection[data-state="online"] .connection-dot { background: #55e59a; box-shadow: 0 0 0 4px rgba(85,229,154,.1); }
.connection[data-state="offline"] .connection-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(255,117,136,.1); }

.hero { position: relative; min-height: 570px; padding: 150px clamp(18px, 4vw, 54px) 40px; overflow: hidden; }
.hero-art { position: absolute; inset: 0 0 auto; height: 390px; background-image: linear-gradient(to bottom, rgba(7,16,31,.04) 40%, var(--page) 100%), url("/assets/anime-hero.png"); background-position: center 34%; background-size: cover; }
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(7,16,31,.75), transparent 24%, transparent 76%, rgba(7,16,31,.75)); }
.portal-panel { position: relative; z-index: 2; width: min(1040px, 100%); margin: 0 auto; padding: 42px clamp(24px, 6vw, 74px) 36px; text-align: center; background: rgba(16,30,47,.96); border: 1px solid rgba(133,188,226,.12); border-radius: 28px; box-shadow: 0 26px 90px rgba(0,0,0,.42); overflow: hidden; }
.portal-panel::before { content: ""; position: absolute; inset: 0; opacity: .32; pointer-events: none; background: radial-gradient(circle at 20% 10%, rgba(37,185,238,.13), transparent 18rem), repeating-linear-gradient(135deg, transparent 0 46px, rgba(255,255,255,.012) 47px 48px); }
.portal-logo { position: relative; display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 50%; background: var(--cyan); color: var(--page); font-size: 34px; font-weight: 1000; box-shadow: 0 0 0 8px rgba(37,185,238,.08), 0 0 40px rgba(37,185,238,.24); }
.portal-logo::after { content: ""; position: absolute; inset: 9px; border: 2px solid rgba(7,16,31,.5); border-radius: 50%; }
.kicker { position: relative; margin: 0 0 10px; color: var(--cyan-bright); font-size: 10px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
h1 { position: relative; margin: 0 auto 24px; font-size: clamp(34px, 5vw, 58px); line-height: 1.02; letter-spacing: -.055em; }
h1 span { color: #adc8e2; }
.search { position: relative; display: flex; align-items: center; width: min(570px, 100%); margin: 0 auto; padding: 6px; background: #091523; border: 1px solid rgba(151,198,231,.13); border-radius: 10px; box-shadow: 0 14px 34px rgba(0,0,0,.22); }
.search:focus-within { border-color: rgba(37,185,238,.65); box-shadow: 0 0 0 4px rgba(37,185,238,.08); }
.search svg { width: 21px; min-width: 21px; margin: 0 12px; fill: none; stroke: #6886a4; stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; height: 46px; border: 0; outline: 0; color: white; background: transparent; }
.search input::placeholder { color: #647e98; }
.search button, .primary-button { border: 0; border-radius: 8px; padding: 13px 20px; color: #06111d; background: var(--cyan); font-weight: 900; cursor: pointer; }
.search button:hover, .primary-button:hover { background: var(--cyan-bright); }
.quick-links { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px 10px; margin-top: 22px; color: var(--muted); font-size: 12px; }
.quick-links strong { color: #bed2e6; }
.quick-links button { padding: 0; border: 0; background: none; color: var(--cyan-bright); cursor: pointer; }
.quick-links button:hover { text-decoration: underline; }

.catalog { width: min(1220px, calc(100% - 36px)); margin: 0 auto; padding: 10px 0 110px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
h2 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.045em; }
.refresh-button { display: flex; align-items: center; gap: 7px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); color: #a9bfd5; cursor: pointer; }
.refresh-button:hover { color: white; border-color: rgba(37,185,238,.4); }
.refresh-button span { color: var(--cyan); font-size: 18px; }
.filters { display: flex; gap: 7px; padding: 18px 0; overflow-x: auto; scrollbar-width: none; }
.filter { flex: 0 0 auto; padding: 9px 16px; border: 1px solid var(--line); border-radius: 7px; background: #0a1625; color: var(--muted); cursor: pointer; }
.filter.active { border-color: var(--cyan); background: var(--cyan); color: #06111d; font-weight: 900; }
.notice { margin: 0 0 18px; padding: 13px 15px; border: 1px solid rgba(37,185,238,.28); border-radius: 9px; background: rgba(37,185,238,.08); color: #bdeaff; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; }
.media-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); transition: transform .18s ease, border-color .18s ease; }
.media-card:hover { transform: translateY(-4px); border-color: rgba(37,185,238,.45); }
.card-open { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.card-art { position: relative; display: flex; align-items: end; aspect-ratio: 2 / 2.8; padding: 17px; overflow: hidden; background: linear-gradient(155deg, #172b56, #1e8db3); }
.card-art::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(4,10,20,.82), transparent 55%), radial-gradient(circle at 70% 20%, rgba(255,255,255,.2), transparent 4rem); }
.card-art::after { content: ""; position: absolute; width: 170px; height: 170px; top: -50px; right: -70px; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; box-shadow: 0 0 0 27px rgba(255,255,255,.025), 0 0 0 54px rgba(255,255,255,.018); }
.card-art.violet { background: linear-gradient(155deg, #2d1b52, #755ac7); }
.card-art.ocean { background: linear-gradient(155deg, #0b3441, #1791af); }
.card-art.mint { background: linear-gradient(155deg, #113b35, #2ca283); }
.card-art.sunset { background: linear-gradient(155deg, #49233d, #e27655); }
.card-initials { position: relative; z-index: 1; font-family: Georgia, serif; font-size: 48px; line-height: .85; color: white; letter-spacing: -.08em; }
.source-badge { position: absolute; z-index: 2; top: 10px; left: 10px; padding: 5px 8px; border-radius: 5px; background: rgba(5,12,23,.75); color: #dceeff; font-size: 9px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; backdrop-filter: blur(7px); }
.favorite-button { position: absolute; z-index: 3; top: 9px; right: 9px; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(5,12,23,.76); font-size: 19px; cursor: pointer; backdrop-filter: blur(7px); }
.favorite-button.selected { color: #ff7890; }
.card-body { display: block; min-width: 0; padding: 13px; }
.card-title { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; font-weight: 900; }
.card-meta { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; text-transform: capitalize; }
.empty-state { grid-column: 1 / -1; padding: 64px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

dialog { color: var(--text); background: var(--panel); border: 1px solid var(--line); box-shadow: 0 30px 110px rgba(0,0,0,.7); }
dialog::backdrop { background: rgba(2,7,15,.78); backdrop-filter: blur(7px); }
.detail-dialog { width: min(900px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; border-radius: 18px; overflow: auto; }
.detail-dialog article { display: grid; grid-template-columns: minmax(280px,.82fr) 1.18fr; min-height: 510px; }
.detail-art { display: grid; place-items: center; min-height: 420px; background: linear-gradient(155deg, #172b56, #1e8db3); }
.detail-art.violet { background: linear-gradient(155deg, #2d1b52, #755ac7); }
.detail-art.ocean { background: linear-gradient(155deg, #0b3441, #1791af); }
.detail-art.mint { background: linear-gradient(155deg, #113b35, #2ca283); }
.detail-art.sunset { background: linear-gradient(155deg, #49233d, #e27655); }
.detail-art span { font-size: 66px; opacity: .9; }
.detail-content { align-self: center; padding: clamp(28px,5vw,56px); }
.detail-content h2 { font-size: clamp(38px,6vw,60px); }
.detail-meta { color: var(--cyan-bright); text-transform: capitalize; font-weight: 800; }
.detail-description { color: var(--muted); line-height: 1.7; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 26px; }
.secondary-button { padding: 12px 17px; border: 1px solid var(--line); border-radius: 8px; background: #0b1726; cursor: pointer; }
.close-button { position: fixed; z-index: 3; right: max(14px,calc((100vw - 900px)/2)); width: 40px; height: 40px; margin: 14px; border: 0; border-radius: 50%; background: rgba(5,12,23,.8); font-size: 25px; cursor: pointer; }
#videoPlayer { width: 100%; margin-top: 22px; border-radius: 10px; background: black; }
.bottom-nav { display: none; }

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; min-height: 58px; padding-inline: 15px; }
  .desktop-nav { display: none; }
  .connection #connectionText { display: none; }
  .hero { min-height: 545px; padding: 124px 12px 30px; }
  .hero-art { height: 285px; background-position: 52% center; }
  .hero::after { background: linear-gradient(to bottom, transparent 15%, rgba(7,16,31,.22) 45%, var(--page) 88%); }
  .portal-panel { padding: 30px 18px 25px; border-radius: 20px; }
  .portal-logo { width: 52px; height: 52px; font-size: 28px; }
  h1 { font-size: clamp(31px,10vw,43px); }
  .search { padding: 5px; }
  .search button { padding-inline: 14px; }
  .quick-links { line-height: 1.6; }
  .catalog { width: calc(100% - 24px); padding-top: 0; }
  .section-heading { align-items: center; }
  .refresh-button { padding: 9px 10px; font-size: 0; }
  .refresh-button span { font-size: 20px; }
  .media-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .card-body { padding: 11px; }
  .detail-dialog { width: 100%; max-height: 94vh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .detail-dialog article { display: block; }
  .detail-art { min-height: 220px; }
  .detail-content { padding: 25px 20px calc(32px + var(--safe-bottom)); }
  .detail-content h2 { font-size: 38px; }
  .close-button { right: 9px; }
  .bottom-nav { position: fixed; z-index: 19; left: 12px; right: 12px; bottom: calc(9px + var(--safe-bottom)); display: flex; justify-content: space-around; padding: 9px; border: 1px solid var(--line); border-radius: 16px; background: rgba(10,22,37,.94); backdrop-filter: blur(16px); box-shadow: 0 14px 45px rgba(0,0,0,.48); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 68px; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: 10px; }
  .bottom-nav span { font-size: 20px; }
  .bottom-nav .active { color: var(--cyan-bright); }
}

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