/* ============================================================
   WN ESPORTS · shared foundation
   Deep-blue / ice-white sci-fi design system
   ============================================================ */
:root {
  color-scheme: dark;
  --bg: #030811;
  --bg-deep: #02060d;
  --bg-soft: #06101e;
  --panel: rgba(8, 22, 39, 0.78);
  --panel-strong: rgba(9, 25, 45, 0.94);
  --panel-light: rgba(17, 39, 65, 0.65);
  --line: rgba(104, 184, 255, 0.16);
  --line-strong: rgba(104, 196, 255, 0.4);
  --line-bright: rgba(127, 231, 255, 0.7);
  --text: #edf8ff;
  --text-soft: #c4dced;
  --muted: #7894ad;
  --muted-2: #55718a;
  --blue: #2f8dff;
  --blue-deep: #1555d9;
  --cyan: #74eaff;
  --cyan-soft: #b4f5ff;
  --green: #48f0bb;
  --gold: #ffd26e;
  --orange: #ff9e57;
  --danger: #ff6b86;
  --danger-bg: rgba(255, 87, 117, 0.12);
  --success-bg: rgba(72, 240, 187, 0.12);
  --warning-bg: rgba(255, 210, 110, 0.1);
  --glass: rgba(9, 24, 43, 0.7);
  --glass-light: rgba(22, 48, 75, 0.52);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
  --glow: 0 0 30px rgba(47, 141, 255, 0.25);
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --font: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding-left: 1.3em;
}

::selection {
  background: rgba(79, 189, 255, 0.32);
  color: #fff;
}

:focus-visible {
  outline: 2px solid rgba(116, 234, 255, 0.75);
  outline-offset: 2px;
}

/* ---------- ambient background ---------- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% -10%, rgba(24, 89, 200, 0.28), transparent 42%),
    radial-gradient(ellipse at 82% 5%, rgba(20, 122, 167, 0.16), transparent 38%),
    linear-gradient(180deg, #02060d 0%, #040b16 52%, #02060c 100%);
}

.ambient-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.5;
}

.ambient-orb-a {
  width: 38vw;
  height: 38vw;
  min-width: 340px;
  min-height: 340px;
  left: -14%;
  top: 8%;
  background: radial-gradient(circle, rgba(32, 107, 255, 0.35), transparent 68%);
  animation: driftA 18s ease-in-out infinite alternate;
}

.ambient-orb-b {
  width: 42vw;
  height: 42vw;
  min-width: 320px;
  min-height: 320px;
  right: -16%;
  bottom: -12%;
  background: radial-gradient(circle, rgba(55, 220, 255, 0.18), transparent 66%);
  animation: driftB 22s ease-in-out infinite alternate;
}

.ambient-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(122, 197, 255, 0.038) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 197, 255, 0.038) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 70%);
}

.ambient-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 220px;
  top: -240px;
  background: linear-gradient(180deg, transparent, rgba(82, 195, 255, 0.045), transparent);
  animation: scan 11s linear infinite;
}

@keyframes driftA {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(8vw, 6vh, 0) scale(1.12); }
}
@keyframes driftB {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to { transform: translate3d(-6vw, -5vh, 0) scale(0.94); }
}
@keyframes scan {
  0% { transform: translateY(0); opacity: 0; }
  8% { opacity: 1; }
  70% { opacity: 0.5; }
  100% { transform: translateY(130vh); opacity: 0; }
}

/* ---------- boot ---------- */
.boot-screen {
  min-height: 70vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
  letter-spacing: 0.18em;
  font-size: 11px;
}
.boot-logo {
  width: 140px;
  height: auto;
  opacity: 0.9;
  filter: drop-shadow(0 0 26px rgba(65, 166, 255, 0.35));
  animation: bootPulse 2s ease-in-out infinite;
}
.boot-line {
  width: 150px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  position: relative;
  overflow: hidden;
}
.boot-line::after {
  content: "";
  position: absolute;
  width: 42%;
  height: 100%;
  background: #fff;
  box-shadow: 0 0 16px var(--cyan);
  animation: bootLine 1.6s var(--ease) infinite;
}
@keyframes bootLine {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(350%); }
}
@keyframes bootPulse {
  0%, 100% { opacity: 0.62; }
  50% { opacity: 1; }
}

/* ---------- typography ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: 0.85;
}
.text-muted { color: var(--muted); }
.text-soft { color: var(--text-soft); }
.text-cyan { color: var(--cyan); }
.text-green { color: var(--green); }
.text-danger { color: var(--danger); }
.text-gold { color: var(--gold); }
.mono { font-family: var(--mono); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  --btn-height: 46px;
  position: relative;
  height: var(--btn-height);
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  background: rgba(19, 44, 69, 0.7);
  transition: transform 0.18s var(--ease), box-shadow 0.25s, background 0.2s,
    border-color 0.2s, opacity 0.2s;
  user-select: none;
  white-space: nowrap;
}
.btn:hover {
  background: rgba(28, 58, 88, 0.82);
  border-color: var(--line-strong);
}
.btn:active { transform: scale(0.975); }
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary {
  color: #02101f;
  border: 0;
  background: linear-gradient(100deg, #58c6ff 0%, #2d8dff 48%, #7bebff 100%);
  box-shadow: 0 8px 28px rgba(47, 141, 255, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 55%);
  pointer-events: none;
}
.btn-primary:hover {
  background: linear-gradient(100deg, #78d7ff, #419dff 50%, #a0f4ff);
  box-shadow: 0 10px 34px rgba(61, 159, 255, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.btn-ghost {
  background: rgba(9, 26, 45, 0.46);
  border-color: var(--line);
  color: var(--text-soft);
}
.btn-outline {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--cyan-soft);
}
.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(255, 107, 134, 0.35);
  color: #ffa0b0;
}
.btn-danger:hover {
  background: rgba(255, 87, 117, 0.2);
  border-color: rgba(255, 107, 134, 0.6);
}
.btn-light {
  background: rgba(237, 248, 255, 0.95);
  color: #051426;
  border-color: transparent;
}
.btn-sm {
  --btn-height: 34px;
  padding: 0 14px;
  font-size: 12px;
  gap: 6px;
}
.btn-sm svg { width: 15px; height: 15px; }
.btn-xs {
  --btn-height: 28px;
  padding: 0 10px;
  font-size: 11px;
  gap: 4px;
  border-radius: 9px;
}
.btn-xs svg { width: 13px; height: 13px; }
.btn-lg {
  --btn-height: 54px;
  padding: 0 28px;
  font-size: 15px;
}
.btn-block { width: 100%; }
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(7, 20, 35, 0.68);
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { border-color: var(--line-strong); color: var(--cyan); }
.btn-icon svg { width: 19px; height: 19px; }
.btn[data-loading="true"] {
  pointer-events: none;
  color: transparent !important;
}
.btn[data-loading="true"]::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.btn-primary[data-loading="true"]::after {
  border-color: rgba(2, 16, 31, 0.25);
  border-top-color: #02101f;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.icon-btn:hover { color: var(--cyan); background: rgba(96, 190, 255, 0.08); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- form ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.03em;
}
.field-label small { color: var(--muted); font-weight: 400; }
.field-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}
.input,
.textarea,
.select,
.rich-editor {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(4, 14, 26, 0.7);
  color: var(--text);
  border-radius: 13px;
  padding: 13px 15px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  min-height: 48px;
}
.input::placeholder,
.textarea::placeholder { color: var(--muted-2); }
.input:hover,
.textarea:hover,
.select:hover { border-color: rgba(102, 190, 255, 0.3); }
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: rgba(116, 234, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(60, 167, 255, 0.1), inset 0 0 20px rgba(36, 106, 190, 0.08);
  background: rgba(5, 17, 31, 0.9);
}
.textarea { min-height: 104px; resize: vertical; line-height: 1.65; }
.select {
  appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 22px, calc(100% - 14px) 22px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.input:disabled,
.textarea:disabled,
.select:disabled { opacity: 0.55; cursor: not-allowed; }
.input-wrap { position: relative; }
.input-wrap > svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
}
.input-wrap .input { padding-left: 44px; }
.input-action {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  display: grid;
  place-items: center;
}
.input-action:hover { color: var(--cyan); background: rgba(94, 190, 255, 0.08); }
.input-action svg { width: 18px; height: 18px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .span-2 { grid-column: span 2; }
.checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: rgba(5, 15, 27, 0.8);
  display: inline-grid;
  place-content: center;
  flex: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.checkbox::before {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #04121f;
  border-bottom: 2px solid #04121f;
  transform: rotate(-45deg) scale(0);
  transition: transform 0.16s var(--ease);
  margin-top: -2px;
}
.checkbox:checked { background: var(--cyan); border-color: var(--cyan); }
.checkbox:checked::before { transform: rotate(-45deg) scale(1); }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.6;
  cursor: pointer;
}
.switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(6, 18, 31, 0.9);
  transition: background 0.22s, border-color 0.22s;
  flex: none;
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #71899d;
  transition: transform 0.24s var(--ease), background 0.22s, box-shadow 0.22s;
}
.switch[aria-checked="true"] {
  background: linear-gradient(90deg, #1e6bea, #42bff5);
  border-color: rgba(126, 234, 255, 0.65);
}
.switch[aria-checked="true"]::after {
  transform: translateX(20px);
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--line);
  background: rgba(4, 14, 25, 0.62);
  border-radius: 12px;
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 9px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.segmented button.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(39, 108, 219, 0.75), rgba(33, 141, 195, 0.46));
  box-shadow: inset 0 0 0 1px rgba(117, 216, 255, 0.25);
}
.quantity {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(4, 14, 26, 0.72);
}
.quantity button {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  display: grid;
  place-items: center;
  font-size: 18px;
}
.quantity button:hover { color: var(--cyan); background: rgba(91, 182, 255, 0.08); }
.quantity span {
  min-width: 42px;
  text-align: center;
  font-family: var(--mono);
  font-size: 14px;
  border-inline: 1px solid var(--line);
  line-height: 38px;
}

/* ---------- cards, chips, tags ---------- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(10, 27, 48, 0.86), rgba(5, 15, 27, 0.92));
  box-shadow: var(--shadow);
  position: relative;
}
.card-pad { padding: 20px; }
.card-hover {
  transition: border-color 0.25s, transform 0.28s var(--ease), box-shadow 0.3s;
}
.card-hover:hover {
  border-color: rgba(100, 202, 255, 0.36);
  transform: translateY(-3px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.35), 0 0 30px rgba(35, 118, 231, 0.08);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.panel-head h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
}
.panel-head h3 svg { width: 18px; height: 18px; color: var(--cyan); }
.panel-head p { color: var(--muted); font-size: 12px; margin-top: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 22, 38, 0.56);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
button.chip { transition: all 0.2s; }
button.chip:hover { color: var(--text-soft); border-color: var(--line-strong); }
.chip.active {
  color: #02111f;
  border-color: transparent;
  background: linear-gradient(100deg, #67d7ff, #2e8cff);
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(37, 133, 255, 0.22);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  color: var(--cyan-soft);
  background: rgba(46, 142, 255, 0.11);
  border: 1px solid rgba(84, 185, 255, 0.16);
  white-space: nowrap;
}
.tag.gold { color: var(--gold); background: rgba(255, 202, 96, 0.08); border-color: rgba(255, 202, 96, 0.16); }
.tag.green { color: var(--green); background: var(--success-bg); border-color: rgba(72, 240, 187, 0.16); }
.tag.danger { color: #ff9caf; background: var(--danger-bg); border-color: rgba(255, 107, 134, 0.18); }
.tag.muted { color: var(--muted); background: rgba(113, 140, 164, 0.08); border-color: var(--line); }
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  flex: none;
}
.dot.online {
  background: var(--green);
  box-shadow: 0 0 10px rgba(72, 240, 187, 0.75);
}
.dot.pulse { animation: dotPulse 2.4s ease-out infinite; }
@keyframes dotPulse {
  0% { box-shadow: 0 0 0 0 rgba(72, 240, 187, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(72, 240, 187, 0); }
  100% { box-shadow: 0 0 0 0 rgba(72, 240, 187, 0); }
}
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 12px;
}
.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(8, 23, 40, 0.7);
  display: grid;
  place-items: center;
  color: var(--muted-2);
}
.empty-state svg { width: 26px; height: 26px; }
.empty-state strong { color: var(--text-soft); font-size: 14px; font-weight: 500; }
.empty-state p { font-size: 12px; line-height: 1.7; max-width: 260px; }
.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(26, 54, 82, 0.36);
  border-radius: 10px;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(173, 227, 255, 0.07), transparent);
  animation: shimmer 1.4s infinite;
  transform: translateX(-100%);
}
@keyframes shimmer { to { transform: translateX(100%); } }
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(121, 207, 255, 0.2);
  border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block {
  min-height: 160px;
  display: grid;
  place-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(100, 130, 155, 0.08);
  white-space: nowrap;
}
.status-badge.pending_payment { color: var(--gold); border-color: rgba(255, 210, 110, 0.22); background: var(--warning-bg); }
.status-badge.paid { color: var(--cyan); border-color: rgba(116, 234, 255, 0.22); background: rgba(61, 174, 255, 0.09); }
.status-badge.accepted { color: #7bc2ff; border-color: rgba(83, 163, 255, 0.25); background: rgba(38, 105, 235, 0.12); }
.status-badge.submitted { color: var(--gold); border-color: rgba(255, 210, 110, 0.24); background: var(--warning-bg); }
.status-badge.completed { color: var(--green); border-color: rgba(72, 240, 187, 0.22); background: var(--success-bg); }
.status-badge.cancelled { color: var(--muted); }
.status-badge.approved { color: var(--green); border-color: rgba(72, 240, 187, 0.22); background: var(--success-bg); }
.status-badge.rejected { color: var(--danger); border-color: rgba(255, 107, 134, 0.22); background: var(--danger-bg); }
.status-badge.pending { color: var(--gold); border-color: rgba(255, 210, 110, 0.22); background: var(--warning-bg); }
.status-badge.active { color: var(--green); border-color: rgba(72, 240, 187, 0.22); background: var(--success-bg); }
.status-badge.used { color: var(--muted); }
.status-badge.disabled { color: var(--muted); }

/* ---------- rich text ---------- */
.rich-text {
  font-size: 14px;
  line-height: 1.9;
  color: var(--text-soft);
  word-break: break-word;
}
.rich-text > *:first-child { margin-top: 0 !important; }
.rich-text > *:last-child { margin-bottom: 0 !important; }
.rich-text h1, .rich-text h2, .rich-text h3, .rich-text h4 {
  color: var(--text);
  margin: 22px 0 10px;
  line-height: 1.5;
  font-weight: 600;
}
.rich-text h1 { font-size: 22px; }
.rich-text h2 { font-size: 19px; }
.rich-text h3 { font-size: 16px; }
.rich-text h4 { font-size: 14px; }
.rich-text p { margin: 10px 0; }
.rich-text ul, .rich-text ol { margin: 10px 0; padding-left: 1.4em; }
.rich-text li { margin: 5px 0; }
.rich-text strong { color: var(--text); font-weight: 600; }
.rich-text a { color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; }
.rich-text img { border-radius: 12px; margin: 14px 0; max-width: 100%; }
.rich-text blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 2px solid var(--cyan);
  background: rgba(71, 159, 255, 0.07);
  border-radius: 0 10px 10px 0;
  color: var(--text-soft);
}
.rich-text hr { border: 0; height: 1px; background: var(--line); margin: 18px 0; }

/* ---------- modal ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(1, 6, 13, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: auto;
  animation: fadeIn 0.22s var(--ease);
  overflow-y: auto;
}
.modal {
  width: min(520px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(99, 194, 255, 0.24);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(160deg, rgba(15, 36, 61, 0.98), rgba(5, 14, 26, 0.99)),
    var(--bg-deep);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(52, 139, 247, 0.08) inset,
    0 0 80px rgba(24, 94, 184, 0.12);
  position: relative;
  overflow: hidden;
  animation: modalIn 0.3s var(--ease);
  margin: auto;
}
.modal::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-bright), transparent);
  opacity: 0.7;
}
.modal.wide { width: min(760px, 100%); }
.modal.narrow { width: min(400px, 100%); }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 14px;
  flex: none;
}
.modal-header h2 { font-size: 18px; font-weight: 600; letter-spacing: 0.01em; }
.modal-header p { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.6; }
.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(4, 14, 26, 0.6);
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: none;
  transition: all 0.2s;
}
.modal-close:hover { color: #fff; border-color: var(--line-strong); background: rgba(43, 96, 150, 0.25); }
.modal-close svg { width: 17px; height: 17px; }
.modal-body {
  padding: 8px 24px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.75;
}
.modal-footer {
  padding: 16px 24px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex: none;
  background: rgba(4, 13, 24, 0.46);
}
.modal-footer .btn { flex: 1; }
.modal-footer .btn:only-child { flex: none; min-width: 130px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* toast */
.toast-root {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 11px 16px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid rgba(109, 195, 255, 0.22);
  border-radius: 12px;
  background: rgba(8, 24, 43, 0.96);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  animation: toastIn 0.28s var(--ease);
}
.toast.success { border-color: rgba(72, 240, 187, 0.3); }
.toast.error { border-color: rgba(255, 107, 134, 0.34); }
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.success svg { color: var(--green); }
.toast.error svg { color: var(--danger); }
.toast.info svg { color: var(--cyan); }
.toast.leaving { animation: toastOut 0.22s var(--ease) forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(0.97); }
}

/* utility scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(111, 166, 214, 0.22); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: rgba(111, 166, 214, 0.38); }

.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #143b76, #09223f);
  display: inline-grid;
  place-items: center;
  color: var(--cyan);
  font-weight: 600;
  overflow: hidden;
  flex: none;
}
.avatar-fallback {
  background:
    radial-gradient(circle at 70% 20%, rgba(94, 220, 255, 0.34), transparent 40%),
    linear-gradient(135deg, #123563, #06162a);
  border: 1px solid rgba(99, 195, 255, 0.24);
}
.avatar-wrap { position: relative; display: inline-flex; flex: none; }
.avatar-wrap .avatar-status {
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid #0a1a2c;
  background: var(--muted-2);
}
.avatar-wrap .avatar-status.online { background: var(--green); box-shadow: 0 0 8px rgba(72, 240, 187, 0.65); }
.price {
  font-family: var(--mono);
  color: var(--cyan);
  font-weight: 600;
  letter-spacing: -0.03em;
}
.price .currency { font-size: 0.66em; margin-right: 1px; opacity: 0.85; }
.price-original {
  color: var(--muted-2);
  font-size: 11px;
  text-decoration: line-through;
  font-family: var(--mono);
}
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.helptext { font-size: 11px; color: var(--muted); line-height: 1.65; }
.inline-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(53, 149, 243, 0.06);
  border: 1px solid rgba(75, 166, 250, 0.12);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}
.inline-note svg { width: 15px; height: 15px; color: var(--cyan); flex: none; margin-top: 2px; }
.inline-note.danger { background: var(--danger-bg); border-color: rgba(255, 107, 134, 0.16); color: #e6a3ad; }
.inline-note.danger svg { color: var(--danger); }

.hud-corners::before,
.hud-corners::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: rgba(121, 225, 255, 0.4);
  pointer-events: none;
}
.hud-corners::before {
  top: 8px;
  left: 8px;
  border-top: 1px solid;
  border-left: 1px solid;
  border-top-left-radius: 5px;
}
.hud-corners::after {
  right: 8px;
  bottom: 8px;
  border-bottom: 1px solid;
  border-right: 1px solid;
  border-bottom-right-radius: 5px;
}

.cover-fit { width: 100%; height: 100%; object-fit: cover; }
.object-contain { object-fit: contain; }
.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;
}
.no-scroll { overflow: hidden !important; }

@media (max-width: 680px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .modal-footer { padding-inline: 18px; }
  .modal-header { padding-inline: 18px; }
  .modal-body { padding-inline: 18px; }
}
