/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg-page); color-scheme: light; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(var(--azure-rgb), .06), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(var(--mint-rgb), .07), transparent 60%),
    var(--bg-page);
  color: var(--text-hi);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: 8px; }
/* text inputs live inside styled boxes that show their own :focus-within ring */
input[type="text"]:focus-visible, input[type="password"]:focus-visible, input[type="search"]:focus-visible, input:not([type]):focus-visible { box-shadow: none; border-radius: 0; }
::selection { background: rgba(var(--blue-rgb), .18); color: #0F1B2D; }
.mono { font-family: var(--font-mono); font-feature-settings: "zero" 0; letter-spacing: .06em; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(15, 27, 45, .22) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(15, 27, 45, .18); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(15, 27, 45, .3); }

/* ===== Global layers ===== */
#field { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; display: block; }
.fx-layer { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.fx-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(37, 99, 235, .065) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, .065) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: -1px -1px;
  -webkit-mask-image: radial-gradient(ellipse 70% 55% at 50% 30%, #000 10%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 55% at 50% 30%, #000 10%, transparent 75%);
  transition: opacity .8s var(--ease);
}
.fx-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse 120% 90% at 50% 45%, transparent 55%, rgba(206, 218, 232, .3) 100%); }
.fx-grain {
  position: absolute; inset: -50%;
  opacity: .055;
  background-image: url("../assets/fx/grain.svg");
  background-size: 160px 160px;
}
body[data-screen="workspace"] .fx-grid { opacity: .55; }

#app { position: relative; z-index: 2; }
#panel-root { position: relative; z-index: 40; }
#layer-app { position: relative; z-index: 50; }
#modal-root { position: relative; z-index: 80; }
#toasts {
  position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none;
  width: min(92vw, 520px);
}

/* ===== HUD bits ===== */
.hud-corner { position: absolute; width: 12px; height: 12px; pointer-events: none; border-color: rgba(var(--mint-rgb), .9); border-style: solid; border-width: 0; }
.hud-corner.tl { top: -1px; left: -1px; border-top-width: 1.5px; border-left-width: 1.5px; border-top-left-radius: 4px; }
.hud-corner.tr { top: -1px; right: -1px; border-top-width: 1.5px; border-right-width: 1.5px; border-top-right-radius: 4px; }
.hud-corner.bl { bottom: -1px; left: -1px; border-bottom-width: 1.5px; border-left-width: 1.5px; border-bottom-left-radius: 4px; }
.hud-corner.br { bottom: -1px; right: -1px; border-bottom-width: 1.5px; border-right-width: 1.5px; border-bottom-right-radius: 4px; }
.eyebrow-sm { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--mint-700); line-height: 1.4; }
kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-md);
  border: 1px solid var(--hairline-2); border-bottom-width: 2px; border-radius: 6px; background: rgba(255, 255, 255, 1);
}
.sep { display: inline-block; width: 1px; height: 12px; background: var(--hairline-2); margin: 0 12px; vertical-align: middle; }

/* ===== Icons ===== */
.ico { flex: none; display: block; }
.ico-fallback {
  width: var(--s); height: var(--s); display: inline-flex; align-items: center; justify-content: center;
  border-radius: 30%; border: 1.5px solid currentColor; font-size: calc(var(--s) * .52); font-weight: 700; line-height: 1;
}

/* ===== Buttons ===== */
.btn {
  --bh: 42px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--bh); padding: 0 18px; border-radius: 12px;
  font-size: 15px; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), background-color var(--t-mid) var(--ease), border-color var(--t-mid) var(--ease), box-shadow var(--t-mid) var(--ease), color var(--t-mid) var(--ease), opacity var(--t-mid);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.is-busy { opacity: .78; cursor: progress; }
.btn.is-busy::after { content: ''; width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: btn-spin .7s linear infinite; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.btn .go { transition: transform var(--t-mid) var(--ease); }
.btn:hover:not(:disabled) .go { transform: translateX(3px); }
.btn--sm { --bh: 36px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn--lg { --bh: 48px; padding: 0 22px; font-size: 16px; border-radius: 13px; }
.btn--xl { --bh: 56px; padding: 0 28px; font-size: 17px; border-radius: 15px; gap: 12px; }
.btn--block { width: 100%; }
.btn--primary {
  color: var(--text-on-brand);
  background: linear-gradient(180deg, #2F6DEE 0%, var(--blue-600) 55%, #1E57D8 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .26) inset, 0 -1px 0 rgba(8, 30, 92, .2) inset, 0 8px 24px -8px rgba(var(--blue-rgb), .5), 0 0 0 1px rgba(29, 78, 216, .6);
}
.btn--primary:hover:not(:disabled) { box-shadow: 0 1px 0 rgba(255, 255, 255, .3) inset, 0 -1px 0 rgba(8, 30, 92, .2) inset, 0 12px 34px -8px rgba(var(--blue-rgb), .62), 0 0 0 1px rgba(29, 78, 216, .78); }
.btn--primary:focus-visible { box-shadow: var(--focus), 0 8px 24px -8px rgba(var(--blue-rgb), .5); }
.btn--ghost { color: var(--text-hi); background: rgba(255, 255, 255, .92); box-shadow: 0 0 0 1px var(--hairline-2) inset; }
.btn--ghost:hover:not(:disabled) { background: rgba(var(--blue-rgb), .06); box-shadow: 0 0 0 1px rgba(var(--blue-rgb), .45) inset; }
.btn--glass { color: var(--text-hi); background: rgba(255, 255, 255, .86); box-shadow: 0 0 0 1px var(--hairline-2) inset, 0 6px 20px -10px rgba(16, 24, 40, .2); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.btn--glass:hover:not(:disabled) { background: rgba(255, 255, 255, 1); box-shadow: 0 0 0 1px rgba(var(--blue-rgb), .45) inset; }
.btn--text { color: var(--text-md); padding: 0 10px; font-weight: 500; }
.btn--text:hover:not(:disabled) { color: var(--text-hi); background: rgba(15, 27, 45, .05); }
.btn--danger { color: #FFFFFF; background: linear-gradient(180deg, #E5493D, var(--coral-400)); box-shadow: 0 1px 0 rgba(255, 255, 255, .24) inset, 0 8px 22px -8px rgba(var(--coral-rgb), .45); }
.btn--danger:hover:not(:disabled) { box-shadow: 0 1px 0 rgba(255, 255, 255, .28) inset, 0 12px 30px -8px rgba(var(--coral-rgb), .6); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-md); transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease);
}
.icon-btn:hover { color: var(--text-hi); background: rgba(15, 27, 45, .06); }
.icon-btn:active { transform: scale(.94); }
.btn-mini {
  height: 26px; padding: 0 10px; border-radius: 8px; font-size: 12.5px; color: var(--text-md);
  box-shadow: 0 0 0 1px var(--hairline) inset; transition: color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-fast);
}
.btn-mini:hover { color: var(--blue-700); background: rgba(var(--blue-rgb), .06); box-shadow: 0 0 0 1px rgba(var(--blue-rgb), .35) inset; }

/* ===== Form fields ===== */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 600; color: var(--text-md); letter-spacing: .04em; }
.field-label small { font-weight: 400; color: var(--text-lo); margin-left: 6px; letter-spacing: 0; }
.field-box {
  position: relative; display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px;
  border-radius: 13px; background: rgba(255, 255, 255, 1);
  box-shadow: 0 0 0 1px var(--hairline-3) inset, 0 1px 0 rgba(16, 24, 40, .04);
  transition: box-shadow var(--t-mid) var(--ease), background-color var(--t-mid);
}
.field-box:hover { box-shadow: 0 0 0 1px var(--hairline-4) inset; }
.field-box:focus-within { background: rgba(255, 255, 255, 1); box-shadow: 0 0 0 1px rgba(var(--blue-rgb), .9) inset, 0 0 0 4px rgba(var(--blue-rgb), .14); }
.field-box input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font-size: 16px; color: var(--text-hi); }
.field-box input::placeholder { color: var(--placeholder); }
.field-box input:-webkit-autofill { -webkit-text-fill-color: var(--text-hi); transition: background-color 9999s; caret-color: var(--text-hi); }
.field-ico { color: var(--text-lo); transition: color var(--t-mid); }
.field-box:focus-within .field-ico { color: var(--blue-600); }
.field.is-invalid .field-box { box-shadow: 0 0 0 1px rgba(var(--coral-rgb), .8) inset, 0 0 0 4px rgba(var(--coral-rgb), .1); }
.field.is-invalid .field-ico { color: var(--coral-400); }
.field-err { min-height: 0; font-size: 13.5px; color: #B42318; line-height: 1.4; }
.field-err:empty { display: none; }
.field-act {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 8px;
  font-size: 13px; color: var(--blue-700); background: rgba(var(--blue-rgb), .07); box-shadow: 0 0 0 1px rgba(var(--blue-rgb), .25) inset;
  transition: background-color var(--t-fast);
}
.field-act:hover { background: rgba(var(--blue-rgb), .13); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* switch (checkbox) */
.switch-row { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; user-select: none; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch {
  flex: none; position: relative; width: 42px; height: 24px; margin-top: 1px; border-radius: 99px;
  background: rgba(15, 27, 45, .1); box-shadow: 0 0 0 1px var(--hairline-3) inset;
  transition: background-color var(--t-mid) var(--ease), box-shadow var(--t-mid);
}
.switch i {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #FFFFFF; box-shadow: 0 2px 6px rgba(16, 24, 40, .28);
  transition: transform var(--t-mid) var(--ease-out), background-color var(--t-mid);
}
.switch-input:checked + .switch { background: rgba(var(--blue-rgb), 1); box-shadow: 0 0 0 1px rgba(29, 78, 216, .9) inset, 0 0 16px rgba(var(--blue-rgb), .3); }
.switch-input:checked + .switch i { transform: translateX(18px); background: #fff; }
.switch-input:focus-visible + .switch { box-shadow: var(--focus); }
.switch-text { display: flex; flex-direction: column; font-size: 15px; font-weight: 600; line-height: 1.35; }
.switch-text small { font-size: 13px; font-weight: 400; color: var(--text-lo); margin-top: 3px; }

/* toggle button (account status) */
.toggle {
  flex: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 10px; height: 36px; padding: 0 14px 0 6px; border-radius: 99px;
  font-size: 14px; font-weight: 600; color: var(--amber-700);
  background: rgba(var(--amber-rgb), .08); box-shadow: 0 0 0 1px rgba(var(--amber-rgb), .35) inset;
  transition: background-color var(--t-mid), box-shadow var(--t-mid), color var(--t-mid);
}
.toggle i {
  position: relative; width: 38px; height: 24px; border-radius: 99px; background: rgba(15, 27, 45, .14);
  transition: background-color var(--t-mid) var(--ease);
}
.toggle i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #FFFFFF;
  transition: transform var(--t-mid) var(--ease-out), background-color var(--t-mid);
}
.toggle.is-on { color: var(--mint-800); background: rgba(var(--mint-rgb), .1); box-shadow: 0 0 0 1px rgba(var(--mint-rgb), .45) inset; }
.toggle.is-on i { background: rgba(var(--mint-rgb), 1); }
.toggle.is-on i::after { transform: translateX(14px); background: #fff; }
.toggle:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Badges & avatars ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; letter-spacing: .02em;
}
.badge--ok { color: var(--mint-800); background: rgba(var(--mint-rgb), .12); box-shadow: 0 0 0 1px rgba(var(--mint-rgb), .4) inset; }
.badge--off { color: var(--amber-700); background: rgba(var(--amber-rgb), .1); box-shadow: 0 0 0 1px rgba(var(--amber-rgb), .3) inset; }
.badge--admin { color: #1D4ED8; background: rgba(var(--azure-rgb), .08); box-shadow: 0 0 0 1px rgba(var(--azure-rgb), .3) inset; }
.badge--plain { color: var(--text-md); background: rgba(15, 27, 45, .04); box-shadow: 0 0 0 1px var(--hairline) inset; }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--mint-700);
  background: radial-gradient(circle at 30% 25%, rgba(var(--mint-rgb), .15), rgba(var(--mint-rgb), .06) 70%);
  box-shadow: 0 0 0 1px rgba(var(--mint-rgb), .45) inset;
}
.avatar--lg { width: 42px; height: 42px; font-size: 17px; }
.avatar--xl { width: 56px; height: 56px; font-size: 22px; }
.avatar--admin { color: #1D4ED8; background: radial-gradient(circle at 30% 25%, rgba(var(--azure-rgb), .18), rgba(var(--azure-rgb), .06) 70%); box-shadow: 0 0 0 1px rgba(var(--azure-rgb), .4) inset; }

/* ===== Logo ===== */
.logo-mark { display: block; flex: none; overflow: visible; }
.wordmark { display: inline-flex; flex-direction: column; line-height: 1; gap: 6px; }
.wm-en { font-family: var(--font-ui); font-weight: 600; font-size: 15px; letter-spacing: .32em; color: var(--text-hi); }
.wm-cn { font-size: 11.5px; letter-spacing: .42em; color: var(--text-lo); }

/* ===== Toast ===== */
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 100%;
  padding: 11px 16px 11px 12px; border-radius: 14px; font-size: 14.5px; line-height: 1.45;
  background: rgba(255, 255, 255, .97); box-shadow: 0 0 0 1px var(--hairline-2) inset, 0 18px 40px -12px rgba(16, 24, 40, .22);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.toast-ico { flex: none; width: 28px; height: 28px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }
.toast--success .toast-ico { color: var(--mint-700); background: rgba(var(--mint-rgb), .12); }
.toast--info .toast-ico { color: var(--azure-400); background: rgba(var(--azure-rgb), .12); }
.toast--warn .toast-ico { color: var(--amber-400); background: rgba(var(--amber-rgb), .12); }
.toast--error .toast-ico { color: var(--coral-400); background: rgba(var(--coral-rgb), .12); }

/* ===== Dialog ===== */
.dlg-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; }
.dlg-backdrop { position: absolute; inset: 0; background: rgba(15, 27, 45, .3); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dlg {
  position: relative; width: min(100%, var(--w)); max-height: calc(100vh - 40px); overflow: auto;
  border-radius: var(--r-xl); padding: 26px 26px 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .99), rgba(250, 251, 253, .99));
  box-shadow: 0 0 0 1px var(--hairline-2) inset, var(--shadow-2);
}
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.dlg-title { font-size: 20px; font-weight: 700; line-height: 1.35; margin-top: 6px; }
.dlg-x { margin: -6px -8px 0 0; }
.dlg-body { display: flex; flex-direction: column; gap: 16px; }
.dlg-text { font-size: 15px; color: var(--text-md); line-height: 1.7; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.dlg--danger .hud-corner { border-color: rgba(var(--coral-rgb), .8); }
.dlg--danger .eyebrow-sm { color: rgba(var(--coral-rgb), 1); }

/* ===== Screens ===== */
.screen { position: relative; }

/* ===== System notices ===== */
.sys-notice {
  position: fixed; z-index: 200; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 520px);
  padding: 24px 26px; border-radius: 18px; background: #FFFFFF; box-shadow: 0 0 0 1px rgba(var(--amber-rgb), .45) inset, var(--shadow-2);
  font-family: var(--font-cn); color: var(--text-hi);
}
.sys-notice b { display: block; font-size: 18px; margin-bottom: 8px; color: var(--amber-400); }
.sys-notice p { font-size: 15px; color: var(--text-md); line-height: 1.7; }
.sys-notice code { font-family: var(--font-mono); color: var(--mint-700); }

@media (prefers-reduced-motion: reduce) {
  /* keep short fades, drop long / looping motion */
  *, *::before, *::after { animation-duration: 160ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 120ms !important; scroll-behavior: auto !important; }
}

/* ===== Large displays (e.g. 2560×1440 at 100% scaling): scale the content, not the canvas ===== */
@media (min-width: 2200px) and (min-height: 1150px) {
  .splash-body, .hud-top, .hud-bottom, .login-panel, .hud-readout { zoom: 1.28; }
  .ws-top, .ws-main, .ws-foot { zoom: 1.2; }
  .av-top, .av-center { zoom: 1.25; }
  .adm, .dlg, #toasts { zoom: 1.15; }
}
