/* Layout: a night-sky "channel" with a sticky system header and a grid of
   floating Star Stream windows; one detail window opens over a dimmed sky.
   Single committed dark look, like the system windows in the webtoon. */
:root {
  --sky: #050914;          /* deep night behind everything */
  --sky-2: #0b1430;
  --pane: rgba(10, 24, 54, 0.78);   /* window glass */
  --pane-solid: #0c1a3a;
  --edge: #6fd3ff;         /* luminous window border */
  --edge-dim: rgba(111, 211, 255, 0.28);
  --ink: #e8f4ff;          /* window text */
  --ink-dim: #93abc9;
  --gold: #ffd76a;         /* constellation / reward highlights */
  --red: #ff6b7d;          /* failure, death */
  --violet: #b99bff;       /* outer gods, hidden */

  --f-display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --f-body: "Noto Sans KR", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --glow: 0 0 0 1px var(--edge-dim), 0 0 18px rgba(80, 180, 255, 0.18), inset 0 0 24px rgba(80, 170, 255, 0.07);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--sky); }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -10%, var(--sky-2), var(--sky) 60%) fixed;
  color: var(--ink);
  font: 15px/1.6 var(--f-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  overflow-x: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; }
#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.top, main, .foot { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; }

/* ---------- header ---------- */
.sys-banner { text-align: center; padding-block: 40px 20px; display: grid; gap: 6px; justify-items: center; }
.sys-line, .sys-sub { margin: 0; font-family: var(--f-display); color: var(--edge); letter-spacing: 0.02em; }
.sys-line { min-height: 1.6em; }
.sys-sub { color: var(--ink-dim); font-size: 13px; font-family: var(--f-mono); }
.brand {
  margin: 0; font-family: var(--f-display); font-weight: 700;
  font-size: clamp(28px, 5vw, 52px); line-height: 1.1; text-wrap: balance;
  text-shadow: 0 0 22px rgba(111, 211, 255, 0.45);
}
.brand .br { color: var(--edge); font-weight: 500; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-block: 10px; }
.tab {
  font: 600 14px var(--f-display); letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-dim); background: transparent; cursor: pointer;
  border: 1px solid var(--edge-dim); padding: 8px 14px; border-radius: 2px;
  display: inline-flex; gap: 8px; align-items: baseline; transition: color .15s, border-color .15s, background .15s;
}
.tab .n { font: 400 12px var(--f-mono); color: inherit; opacity: .7; }
.tab:hover { color: var(--ink); border-color: var(--edge); }
.tab[aria-selected="true"] { color: var(--sky); background: var(--edge); border-color: var(--edge); box-shadow: 0 0 16px rgba(111,211,255,.5); }
.tab:focus-visible, .chip:focus-visible, .card:focus-visible, .x:focus-visible, .link:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.controls { display: grid; gap: 12px; padding-block: 8px 18px; }
.search {
  display: flex; align-items: stretch; max-width: 640px; width: 100%; margin: 0 auto;
  border: 1px solid var(--edge); background: var(--pane); box-shadow: var(--glow);
}
.search-tag {
  font: 600 12px var(--f-display); text-transform: uppercase; letter-spacing: .08em;
  background: var(--edge); color: var(--sky); padding: 0 12px; display: flex; align-items: center;
}
.search input {
  flex: 1; min-width: 0; background: transparent; border: 0; color: var(--ink);
  font: 15px var(--f-body); padding: 11px 12px; outline: none;
}
.search input::placeholder { color: var(--ink-dim); opacity: .7; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip {
  font: 500 12px var(--f-mono); color: var(--ink-dim); background: rgba(10,24,54,.5);
  border: 1px solid var(--edge-dim); padding: 4px 10px; border-radius: 999px; cursor: pointer;
}
.chip:hover { color: var(--ink); border-color: var(--edge); }
.chip[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); background: rgba(255,215,106,.08); }

/* ---------- grid of windows ---------- */
.result-count { font: 12px var(--f-mono); color: var(--ink-dim); margin: 0 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 14px; padding-bottom: 40px; }

.window {
  position: relative; background: var(--pane); color: var(--ink);
  border: 1px solid var(--edge); box-shadow: var(--glow);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
/* corner brackets, the signature of the system windows */
.window::before, .window::after {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border: 2px solid var(--edge); filter: drop-shadow(0 0 4px var(--edge));
}
.window::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; }
.window::after { bottom: -3px; right: -3px; border-left: 0; border-top: 0; }

.card {
  text-align: left; font: inherit; cursor: pointer; padding: 14px 16px 14px;
  display: grid; gap: 8px; align-content: start; min-width: 0;
  transition: transform .15s, box-shadow .15s;
  animation: rise .35s ease both;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--edge), 0 0 26px rgba(80,180,255,.35), inset 0 0 24px rgba(80,170,255,.1); }
.card-kind { font: 600 11px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--edge); display: flex; justify-content: space-between; gap: 8px; }
.card-kind .idx { font-family: var(--f-mono); color: var(--ink-dim); letter-spacing: 0; }
.card-title { font: 600 17px/1.3 var(--f-display); margin: 0; overflow-wrap: anywhere; }
.card-title .br { color: var(--edge); }
.card-line { margin: 0; color: var(--ink-dim); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge { font: 500 11px var(--f-mono); padding: 1px 7px; border: 1px solid var(--edge-dim); color: var(--ink-dim); border-radius: 2px; }
.badge.gold { color: var(--gold); border-color: rgba(255,215,106,.45); }
.badge.red { color: var(--red); border-color: rgba(255,107,125,.45); }
.badge.violet { color: var(--violet); border-color: rgba(185,155,255,.45); }
.empty { grid-column: 1 / -1; text-align: center; padding: 40px 16px; font-family: var(--f-display); color: var(--ink-dim); }

@keyframes rise { from { transform: translateY(6px); } to { transform: none; } }

/* ---------- detail window ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(2, 5, 14, 0.72);
  display: grid; place-items: center; overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.window-detail { width: min(720px, 100%); background: rgba(9, 22, 50, 0.93); animation: open .28s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes open { from { transform: scaleY(.04); opacity: .4; } to { transform: none; opacity: 1; } }
.wd-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--edge-dim); padding: 10px 16px; background: linear-gradient(90deg, rgba(111,211,255,.16), transparent);
}
.wd-kind { font: 600 12px var(--f-display); letter-spacing: .12em; text-transform: uppercase; color: var(--edge); }
.x { background: none; border: 1px solid var(--edge-dim); color: var(--ink); width: 30px; height: 30px; cursor: pointer; font: 600 16px var(--f-mono); }
.x:hover { border-color: var(--edge); }
.wd-body { padding: 22px clamp(16px, 4vw, 30px) 26px; display: grid; gap: 18px; }
.wd-title { margin: 0; font: 700 clamp(20px, 3.4vw, 28px)/1.25 var(--f-display); text-align: center; text-wrap: balance; overflow-wrap: anywhere; }
.wd-title .br { color: var(--edge); font-weight: 500; }
.wd-sub { margin: -10px 0 0; text-align: center; color: var(--ink-dim); font: 13px var(--f-mono); }

.fields { margin: 0; display: grid; gap: 0; border-top: 1px dashed var(--edge-dim); }
.field { display: grid; grid-template-columns: 170px 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--edge-dim); }
.field dt { font: 600 13px var(--f-display); text-transform: uppercase; letter-spacing: .06em; color: var(--edge); }
.field dd { margin: 0; min-width: 0; white-space: pre-line; overflow-wrap: anywhere; }
.field.reward dd { color: var(--gold); }
.field.fail dd { color: var(--red); }
.field.empty-val dd { color: var(--ink-dim); opacity: .6; }
@media (max-width: 560px) {
  .field { grid-template-columns: 1fr; gap: 2px; }
}

.modlist { display: flex; flex-wrap: wrap; gap: 6px; }
.mod { font-size: 13px; padding: 2px 9px; border: 1px solid var(--edge-dim); background: rgba(111,211,255,.06); }
.modlist.first-gold .mod:first-child { color: var(--gold); border-color: rgba(255,215,106,.5); }

.link { color: var(--edge); text-decoration: none; border-bottom: 1px dotted var(--edge); cursor: pointer; background: none; padding: 0; font: inherit; }
.link:hover { color: var(--ink); border-bottom-style: solid; }

.related { display: grid; gap: 8px; }
.related h3 { margin: 0; font: 600 13px var(--f-display); text-transform: uppercase; letter-spacing: .1em; color: var(--gold); }

.censored { font-family: var(--f-mono); letter-spacing: .05em; animation: glitch 2.4s steps(1) infinite; }
@keyframes glitch {
  0%, 92%, 100% { text-shadow: none; }
  93% { text-shadow: 2px 0 var(--red), -2px 0 var(--edge); }
  96% { text-shadow: -2px 0 var(--violet), 2px 0 var(--gold); }
}

/* ---------- constellation toasts ---------- */
.toasts {
  position: fixed; z-index: 30; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
  display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  font: 500 13px/1.45 var(--f-display); padding: 10px 14px; pointer-events: auto;
  background: rgba(9, 22, 50, 0.92); border: 1px solid var(--edge-dim); color: var(--ink);
  box-shadow: 0 0 14px rgba(80,180,255,.15); animation: toast-in .4s ease both;
}
.toast b { color: var(--gold); font-weight: 600; }
.toast.out { animation: toast-out .5s ease forwards; }
@keyframes toast-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateX(24px); opacity: 0; } }

.foot { text-align: center; padding-block: 20px 50px; color: var(--ink-dim); font-family: var(--f-display); }
.foot p { margin: 4px 0; }
.foot-small { font: 12px var(--f-mono); opacity: .7; }

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