/* =========================================================
   Nebula Drop · 星云坞 — Design Tokens & Base
   ========================================================= */

:root {
  /* Surface */
  --bg:          #06080f;
  --bg-elev:     #0a0e1c;
  --panel:       #0f1424;
  --panel-2:     #141a2e;
  --panel-3:     #1a2138;

  /* Lines */
  --line:        var(--ov-4);
  --line-2:      rgba(255, 255, 255, .12);
  --line-3:      rgba(255, 255, 255, .2);

  /* Text */
  --fg:          #e9edfb;
  --fg-2:        #a3accc;
  --fg-3:        #6b7599;
  --fg-4:        #4a5375;

  /* Brand (theme-switchable) */
  --violet:      #7c5cff;
  --violet-soft: #a78bfa;
  --cyan:        #22d3ee;
  --magenta:     #ff4d8d;
  --lime:        #a3e635;
  --amber:       #fbbf24;

  --brand-rgb:   124, 92, 255;
  --on-brand:    #0a0616;
  --brand-text:  #c9bdfd;

  /* White overlays (theme-switchable) */
  --ov-1: rgba(255, 255, 255, .012);
  --ov-2: rgba(255, 255, 255, .022);
  --ov-3: rgba(255, 255, 255, .045);
  --ov-4: rgba(255, 255, 255, .07);
  --ov-5: rgba(255, 255, 255, .1);

  --grad-brand:  linear-gradient(118deg, #a78bfa 0%, #7c5cff 46%, #22d3ee 100%);
  --grad-soft:   linear-gradient(180deg, rgba(var(--brand-rgb),.14), rgba(34,211,238,.05));
  --grad-line:   linear-gradient(90deg, transparent, rgba(var(--brand-rgb),.55), rgba(34,211,238,.55), transparent);
  --panel-sheen: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012));

  /* Solid chrome (theme-switchable) */
  --hdr-stuck:   rgba(6, 8, 15, .78);
  --scrim:       rgba(3, 5, 12, .66);
  --scrim-modal: rgba(3, 5, 12, .72);
  --toast-bg:    rgba(18, 23, 41, .96);
  --input-bg:    rgba(6, 8, 15, .6);
  --input-bg-focus: rgba(10, 14, 28, .85);
  --sel-opt-bg:  #10152a;
  --tbl-head-bg: #12101c;

  /* Glow */
  --glow-v:      0 18px 60px -24px rgba(var(--brand-rgb), .85);
  --glow-c:      0 18px 60px -24px rgba(34, 211, 238, .6);

  /* Radius */
  --r-xs: 6px;
  --r-sm: 9px;
  --r:    13px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-pill: 999px;

  /* Type */
  --font: 'Inter', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI',
          'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --mono: ui-monospace, 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;

  /* Layout */
  --maxw: 1260px;
  --gutter: 24px;

  --ease: cubic-bezier(.4, .16, .2, 1);
  --dur: .22s;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.65;
  letter-spacing: .008em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
h1, h2, h3, h4, h5 { margin: 0; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: rgba(var(--brand-rgb), .38); color: #fff; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .11);
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(var(--brand-rgb), .5); background-clip: content-box; }

/* ---------- Ambient background ---------- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.ambient::before {
  content: '';
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 78vh;
  background:
    radial-gradient(48% 55% at 22% 8%,  rgba(var(--brand-rgb), .30), transparent 70%),
    radial-gradient(42% 48% at 82% 2%,  rgba(34, 211, 238, .18), transparent 70%),
    radial-gradient(38% 40% at 58% 26%, rgba(255, 77, 141, .10), transparent 72%);
  filter: blur(18px);
}
.ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--ov-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--ov-2) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 12%, transparent 78%);
}
.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, rgba(255,255,255,.85), transparent),
    radial-gradient(1.2px 1.2px at 78% 12%, rgba(255,255,255,.6), transparent),
    radial-gradient(1.6px 1.6px at 42% 32%, rgba(199,210,254,.7), transparent),
    radial-gradient(1.1px 1.1px at 88% 42%, rgba(255,255,255,.5), transparent),
    radial-gradient(1.3px 1.3px at 26% 54%, rgba(255,255,255,.45), transparent),
    radial-gradient(1.5px 1.5px at 64% 8%, rgba(255,255,255,.55), transparent);
  opacity: .55;
  animation: twinkle 9s ease-in-out infinite alternate;
}
@keyframes twinkle {
  from { opacity: .3; }
  to   { opacity: .62; }
}

/* ---------- Layout ---------- */
.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- Typography ---------- */
.eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.display {
  font-size: clamp(30px, 4.6vw, 48px);
  font-weight: 720;
  letter-spacing: -.035em;
  line-height: 1.12;
}
.grad-text {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.muted { color: var(--fg-2); }
.dim   { color: var(--fg-3); }
.mono  { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--panel-sheen);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  backdrop-filter: blur(18px);
}
.panel-solid {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: rgba(255, 255, 255, .055);
  --btn-fg: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 13.5px;
  font-weight: 560;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.btn:hover {
  background: var(--ov-5);
  border-color: var(--line-3);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.btn[disabled], .btn.is-busy { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--grad-brand);
  border-color: transparent;
  color: var(--on-brand);
  font-weight: 680;
  box-shadow: var(--glow-v);
}
.btn-primary:hover {
  background: var(--grad-brand);
  filter: brightness(1.09);
  border-color: transparent;
}

.btn-ghost { background: transparent; border-color: var(--line); color: var(--fg-2); }
.btn-ghost:hover { color: var(--fg); background: rgba(255,255,255,.05); }

.btn-danger { color: #ffb4c8; border-color: rgba(255, 77, 141, .3); background: rgba(255, 77, 141, .1); }
.btn-danger:hover { background: rgba(255, 77, 141, .18); border-color: rgba(255, 77, 141, .5); }

.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-lg { height: 46px; padding: 0 24px; font-size: 15px; border-radius: var(--r); }
.btn-icon { width: 38px; padding: 0; }
.btn-block { width: 100%; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label {
  font-size: 12px;
  font-weight: 580;
  letter-spacing: .05em;
  color: var(--fg-3);
  text-transform: uppercase;
}
.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 13px;
  background: var(--input-bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  color: var(--fg);
  font-size: 13.5px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.textarea { height: auto; min-height: 84px; padding: 10px 13px; resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--fg-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: rgba(var(--brand-rgb), .6);
  background: var(--input-bg-focus);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .14);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' stroke='%23a3accc' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.select option { background: var(--sel-opt-bg); color: var(--fg); }

/* ---------- Tags / Badges ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 520;
  color: var(--fg-2);
  white-space: nowrap;
}
.tag-brand {
  background: rgba(var(--brand-rgb), .14);
  border-color: rgba(var(--brand-rgb), .3);
  color: var(--brand-text);
}
.tag-cyan { background: rgba(34, 211, 238, .12); border-color: rgba(34, 211, 238, .28); color: #7dd3fc; }
.tag-lime { background: rgba(163, 230, 53, .1);  border-color: rgba(163, 230, 53, .26); color: #bef264; }

.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 3px rgba(163, 230, 53, .16);
  flex: none;
}

/* ---------- Divider ---------- */
.hr { height: 1px; background: var(--line); border: 0; margin: 0; }
.hr-glow { height: 1px; background: var(--grad-line); border: 0; margin: 0; }

/* ---------- Skeleton ---------- */
.skel {
  background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.085) 37%, rgba(255,255,255,.04) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Empty ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 24px;
  text-align: center;
  color: var(--fg-3);
  font-size: 13.5px;
}
.empty svg { opacity: .4; }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  z-index: 900;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: 380px;
  padding: 11px 15px;
  border-radius: var(--r);
  background: var(--toast-bg);
  border: 1px solid var(--line-2);
  box-shadow: 0 20px 50px -18px #000;
  font-size: 13px;
  color: var(--fg);
  animation: toast-in .3s var(--ease);
  backdrop-filter: blur(14px);
}
.toast.is-out { animation: toast-out .25s var(--ease) forwards; }
.toast-ok   { border-color: rgba(163, 230, 53, .35); }
.toast-err  { border-color: rgba(255, 77, 141, .4); }
.toast-ok .toast-icon  { color: var(--lime); }
.toast-err .toast-icon { color: var(--magenta); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Modal ---------- */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--scrim-modal);
  backdrop-filter: blur(6px);
}
.modal-host.is-open { display: flex; }
.modal {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 40px 100px -30px #000;
  animation: modal-in .26s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-body { padding: 20px 22px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, .18);
}

/* ---------- Utility ---------- */
.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;
}
.fade-in { animation: fade-in .4s var(--ease) both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 720px) {
  :root { --gutter: 16px; }
  body { font-size: 14px; }
}

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

/* hidden attribute must always win over display rules */
[hidden] { display: none !important; }
