:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #fff;
  --surface-subtle: #edf3f5;
  --ink: #13282f;
  --muted: #51656e;
  --line: #dce5e8;
  --line-strong: #728790;
  --primary: #075b72;
  --primary-hover: #064c60;
  --primary-pressed: #063e4f;
  --primary-ink: #fff;
  --primary-soft: #e0f0f2;
  --accent: #d49a40;
  --focus: #075b72;
  --ok-bg: #e7f3ec;
  --ok-ink: #17604c;
  --warn-bg: #fff1d8;
  --warn-ink: #724400;
  --bad-bg: #fff0f0;
  --bad-ink: #983746;
  --rail: #eef4f6;
  --glass-solid: #f8fbfc;
  --glass-bg: rgba(248, 251, 252, .88);
  --glass-line: #dce5e8;
  --glass-filter: blur(16px) saturate(125%);
  --glass-shadow: 0 6px 24px rgb(20 57 70 / .10);
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 28px;
  --s8: 32px;
  --s9: 36px;
  --s10: 40px;
  --s11: 44px;
  --s12: 48px;
  --radius-small: 8px;
  --radius-control: 12px;
  --radius: 12px;
  --radius-group: 16px;
  --radius-large: 24px;
  --radius-pill: 999px;
  --border: 1px solid var(--line);
  --fs-caption: 12px;
  --fs-label: 14px;
  --fs-body: 16px;
  --fs-heading: 20px;
  --fs-title: 32px;
  --fs-display: 36px;
  --rail-width: 224px;
  --topbar-height: 64px;
  --nav-height: 60px;
  --lift: 0 12px 32px rgba(18, 47, 57, .15);
  --easing: 120ms ease-out;
  --font: "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
}

@media (min-resolution: 2dppx) {
  :root { --border: .5px solid var(--line); }
}

@supports (corner-shape: squircle) {
  :where(.panel, .hero, .btn, .field input, .field select, .field textarea, .alert) { corner-shape: squircle; }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  min-height: 100%;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, a, label, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-underline-offset: var(--s1); }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; vertical-align: middle; }
svg { vertical-align: middle; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; text-wrap: balance; }
h1 { font-size: var(--fs-title); font-weight: 700; letter-spacing: -.025em; }
h2 { font-size: var(--fs-heading); font-weight: 700; }
h3, h4 { font-size: var(--fs-body); font-weight: 700; }

.glass { background: var(--glass-solid); }
@supports (backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px)) {
  .glass {
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-filter);
    backdrop-filter: var(--glass-filter);
  }
}
:root[data-transparency=reduce] .glass { background: var(--glass-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more), (forced-colors: active) {
  .glass { background: var(--glass-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: var(--s2);
  left: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-control);
  background: var(--surface);
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.icon { flex: 0 0 auto; }
.number, time, progress, [data-count] { font-variant-numeric: tabular-nums; }
.muted, .meta { color: var(--muted); }
.meta { font-size: var(--fs-label); }
.mobile-only { display: none !important; }

.stack, .grid, .split { display: grid; gap: var(--s4); min-width: 0; }
.stack > *, .grid > *, .split > * { min-width: 0; }
.grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 216px), 1fr)); }
.split { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.row, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--s4);
  margin-bottom: var(--s6);
}
.page-head p { margin-top: var(--s1); color: var(--muted); font-size: var(--fs-label); }
.page-head > .actions { justify-content: flex-end; }
.panel { background: var(--surface); border: var(--border); border-radius: var(--radius-group); padding: var(--s5); }
.empty { display: grid; justify-items: center; gap: var(--s2); text-align: center; padding: var(--s10) var(--s4); color: var(--muted); }
.empty :is(h1, h2, h3) { color: var(--ink); }

.btn, .icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 40px;
  padding: var(--s2) var(--s4);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  text-decoration: none;
  text-align: center;
  font-size: var(--fs-label);
  line-height: 1.4;
  font-weight: 600;
  color: var(--ink);
  transition: color var(--easing), border-color var(--easing), background-color var(--easing), transform var(--easing);
}
.btn:active:not(:disabled), .icon-btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-ink); }
.btn-primary:active { background: var(--primary-pressed); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover, .btn-quiet:hover, .icon-btn:hover { background: var(--surface-subtle); color: var(--primary-pressed); }
.btn-quiet { border-color: transparent; color: var(--primary); }
.btn-danger { background: var(--bad-bg); color: var(--bad-ink); border-color: #e2c1ba; }
.btn-danger:hover { background: #f8e0da; color: var(--bad-ink); }
.btn-sm { min-height: 36px; padding-inline: var(--s3); }
.btn:disabled, .btn[aria-disabled="true"], .icon-btn:disabled {
  transform: none;
  color: var(--muted);
  background: var(--surface-subtle);
  border-color: var(--line);
  cursor: not-allowed;
}
.btn[aria-busy="true"] { pointer-events: none; }
.btn[aria-busy="true"] > .icon { visibility: hidden; }
.btn[aria-busy="true"]::after { position: absolute; right: var(--s3); content: ""; }
.icon-btn { width: 40px; padding: 0; color: var(--muted); }
.spinner, .btn[aria-busy="true"]::after {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: var(--radius-pill);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  min-height: 24px;
  padding-inline: var(--s2);
  border-radius: var(--radius-small);
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: var(--fs-caption);
  font-weight: 600;
  line-height: 1.4;
}
.chip-ok, .chip-success { background: var(--ok-bg); color: var(--ok-ink); }
.chip-warn, .chip-warning { background: var(--warn-bg); color: var(--warn-ink); }
.chip-bad, .chip-danger { background: var(--bad-bg); color: var(--bad-ink); }
.chip-neutral { background: var(--surface-subtle); color: var(--muted); }
.alert {
  display: flex;
  gap: var(--s2);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-radius: var(--radius-control);
  color: var(--primary-pressed);
  background: var(--primary-soft);
  font-size: var(--fs-label);
  overflow-wrap: anywhere;
}
.alert-error { color: var(--bad-ink); background: var(--bad-bg); }
.alert-warn { color: var(--warn-ink); background: var(--warn-bg); }
.alert-success { color: var(--ok-ink); background: var(--ok-bg); }

.field { display: grid; gap: var(--s2); min-width: 0; font-size: var(--fs-label); font-weight: 600; }
.field small { font-weight: 400; font-size: var(--fs-caption); color: var(--muted); }
input:not([type=checkbox], [type=radio], [type=range], [type=file]), select, textarea {
  min-height: 40px;
  max-width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  padding: var(--s2) var(--s3);
  font-size: var(--fs-label);
  font-weight: 400;
}
:is(.field input, .field select, .field textarea):not([type=checkbox], [type=radio], [type=range]) { width: 100%; }
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=radio], input[type=checkbox], progress { accent-color: var(--primary); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-subtle); }
fieldset { min-width: 0; margin: 0; padding: var(--s4); border: var(--border); border-radius: var(--radius-control); }
legend { padding-inline: var(--s1); }

.table-wrap { width: 100%; max-width: 100%; border: var(--border); border-radius: var(--radius); overflow-x: auto; }
.table-wrap > table, table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-label); background: var(--surface); }
.table-wrap :is(th, td), .table :is(th, td) { padding: var(--s3) var(--s4); text-align: start; border-bottom: var(--border); vertical-align: top; }
.table-wrap th, .table th { background: var(--surface-subtle); color: var(--muted); white-space: nowrap; font-weight: 600; }
.table-wrap tbody tr:last-child td, .table tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover td, .table tbody tr:hover td { background: var(--rail); }
.table-wrap .number, .table .number { text-align: end; }

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: var(--s6);
  padding: var(--s8);
  border-radius: var(--radius-large);
  background: #153f38;
  color: #f0f9f3;
}
.hero::before {
  content: "";
  z-index: -1;
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .6;
  background:
    linear-gradient(90deg, #153f38 28%, transparent 75%),
    repeating-radial-gradient(ellipse at 94% 74%, transparent 0 21px, #71a89645 22px 23px, transparent 24px 27px),
    repeating-linear-gradient(0deg, transparent 0 27px, #71a8962c 27px 28px),
    repeating-linear-gradient(90deg, transparent 0 27px, #71a89623 27px 28px);
}
.hero :is(p, .meta, .muted) { color: #d0e9dc; }
.hero .btn-primary { background: #e7f4eb; color: #153f38; }
.hero .btn-primary:hover { background: #cfe8d9; }
.hero .btn-secondary, .hero .btn-quiet { background: transparent; color: #f0f9f3; border-color: #92b5a7; }
.hero .btn-secondary:hover, .hero .btn-quiet:hover { background: #28594c; }
.hero :focus-visible { outline-color: #fff; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  min-height: 48px;
  width: fit-content;
  text-decoration: none;
  color: var(--ink);
}
.brand:hover { color: var(--ink); }
.brand img { flex: 0 0 auto; }
.brand span { display: grid; gap: var(--s1); line-height: 1.1; }
.brand strong { font-size: var(--fs-body); font-weight: 750; letter-spacing: .04em; }
.brand small { font-size: var(--fs-caption); font-weight: 500; color: var(--muted); }

.auth-layout {
  display: grid;
  grid-template-columns: minmax(320px, .92fr) minmax(448px, 1.08fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface);
}
.auth-cover {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, #24446008, #0a27374d 64%, #092b408a),
    var(--auth-cover, url("/static/offshore-blue.webp")) center / cover,
    #103745;
}
.auth-cover::after {
  content: "";
  position: absolute;
  inset: var(--s8);
  border: .5px solid #d9f1e765;
  border-radius: var(--radius-large);
  pointer-events: none;
}
.auth-content {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  padding: var(--s8) clamp(var(--s8), 5vw, 80px);
  min-width: 0;
}
.auth-content > .brand { align-self: start; }
.auth-card { justify-self: center; width: min(100%, 392px); margin-block: var(--s12); }
.auth-heading { margin-bottom: var(--s8); }
.auth-heading h1 { font-size: var(--fs-display); }
.auth-heading p { color: var(--muted); margin-top: var(--s2); font-size: var(--fs-label); }
.auth-heading .actions { margin-top: var(--s6); }
.auth-card .field { gap: var(--s2); }
.auth-card input:not([type=checkbox]) { min-height: 48px; padding-inline: var(--s4); }
.password-field { position: relative; }
.password-field input[type=password], .password-field input[type=text] { padding-inline-end: var(--s12); }
.password-toggle { position: absolute; top: var(--s1); right: var(--s1); }
.auth-submit {
  width: 100%;
  justify-content: space-between;
  min-height: 48px;
  margin-top: var(--s1);
  font-size: var(--fs-body);
}
.auth-footer { margin-top: var(--s5); padding-top: var(--s4); border-top: var(--border); font-size: var(--fs-label); }
.auth-footer a { display: inline-flex; align-items: center; gap: var(--s1); min-height: 44px; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

.start-state { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: var(--s2); color: var(--muted); }
.shell {
  --nav-offset: 0px;
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
}
.shell-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: start;
  padding: var(--s5) var(--s4) var(--s4);
  gap: var(--s8);
  background: var(--rail);
  border-inline-end: var(--border);
}
.shell-rail > .brand { margin-inline-start: var(--s2); }
.rail-nav { display: grid; gap: var(--s1); min-height: 0; max-height: 100%; overflow-y: auto; padding: var(--s1); }
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 44px;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-control);
  text-decoration: none;
  color: var(--muted);
  font-size: var(--fs-label);
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.35;
}
.nav-link:hover { background: var(--surface-subtle); color: var(--ink); }
.nav-link[aria-current=page] { background: var(--primary-soft); color: var(--primary-pressed); font-weight: 700; }
.rail-user {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--s2);
  align-items: center;
  border-top: var(--border);
  padding: var(--s3) var(--s1) 0;
}
.rail-user strong, .rail-user small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--fs-caption); }
.rail-user strong { font-size: var(--fs-label); }
.rail-user small { color: var(--muted); }
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-control);
  background: var(--primary-soft);
  color: var(--primary-pressed);
  font-size: var(--fs-label);
  font-weight: 700;
}
.bar-actions { display: flex; align-items: center; gap: var(--s2); }
.shell-work { min-width: 0; }
.shell-bar {
  position: sticky;
  z-index: 4;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: var(--topbar-height);
  padding: max(0px, env(safe-area-inset-top)) var(--s8) 0;
  border-bottom: var(--border);
}
.bar-context { color: var(--muted); font-size: var(--fs-label); font-weight: 650; }
.mobile-brand, .mobile-nav, .mobile-account, .admin-mobile-menu { display: none; }
.shell-switch { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; font-size: var(--fs-label); }
.shell-switch:hover { text-decoration: underline; }
.shell-main { width: min(100%, 1440px); min-width: 0; margin-inline: auto; padding: var(--s8); }
.notifications { position: fixed; z-index: 15; inset: auto var(--s4) max(var(--s6), env(safe-area-inset-bottom)) auto; display: grid; gap: var(--s2); pointer-events: none; max-width: min(480px, calc(100% - 32px)); }
.toast { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border: var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--lift); font-size: var(--fs-label); overflow-wrap: anywhere; }
.toast-error { color: var(--bad-ink); }
.toast-success { color: var(--ok-ink); }

@media (max-width: 960px) {
  :root { --rail-width: 188px; }
  .shell-bar { padding-inline: var(--s6); }
  .shell-main { padding: var(--s6); }
  .auth-layout { grid-template-columns: minmax(232px, .76fr) minmax(360px, 1.24fr); }
  .auth-cover::after { inset: var(--s5); }
}

@media (max-width: 759px) {
  :root { --topbar-height: 60px; --fs-title: 26px; --fs-display: 28px; }
  .desktop-only { display: none !important; }
  .mobile-only { display: revert !important; }
  .shell { display: block; }
  .shell-rail, .bar-context { display: none; }
  .shell-bar { padding-inline-start: max(var(--s4), env(safe-area-inset-left)); padding-inline-end: max(var(--s4), env(safe-area-inset-right)); }
  .mobile-brand, .mobile-account { display: block; }
  .mobile-brand .brand { gap: var(--s2); }
  .mobile-brand .brand img { width: 36px; }
  .mobile-brand .brand span { gap: 0; }
  .mobile-account { position: relative; }
  .mobile-account > summary { cursor: pointer; width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--radius-control); list-style: none; }
  .mobile-account > summary::-webkit-details-marker { display: none; }
  .mobile-account > div { position: absolute; z-index: 6; inset: calc(100% + 4px) 0 auto auto; display: grid; gap: var(--s2); min-width: 164px; padding: var(--s3); border: var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--lift); }
  .mobile-account > div strong { font-size: var(--fs-label); overflow-wrap: anywhere; padding-inline: var(--s2); }
  .mobile-nav { display: flex; }
  .admin-mobile-menu { position: relative; display: block; }
  .admin-mobile-menu > summary { list-style: none; }
  .admin-mobile-menu > summary::-webkit-details-marker { display: none; }
  .shell-admin .mobile-nav {
    position: absolute;
    z-index: 7;
    top: calc(100% + 4px);
    right: 0;
    display: grid;
    gap: var(--s1);
    width: max-content;
    min-width: 160px;
    max-height: 66vh;
    overflow-y: auto;
    border: var(--border);
    border-radius: var(--radius-group);
    box-shadow: var(--glass-shadow);
    padding: var(--s2);
  }
  .shell-admin .mobile-nav[hidden] { display: none; }
  .shell-admin .mobile-nav .nav-link { min-height: 48px; }
  .shell-learn { --nav-offset: calc(var(--nav-height) + max(var(--s2), env(safe-area-inset-bottom))); }
  .shell-learn .mobile-nav {
    position: fixed;
    z-index: 5;
    inset: auto max(var(--s2), env(safe-area-inset-right)) max(var(--s2), env(safe-area-inset-bottom)) max(var(--s2), env(safe-area-inset-left));
    justify-content: center;
    min-height: var(--nav-height);
    padding: var(--s1) var(--s2);
    border: var(--border);
    border-radius: var(--radius-large);
    box-shadow: var(--glass-shadow);
  }
  .shell-learn .mobile-nav .nav-link { flex: 1 1 0; min-width: 48px; min-height: 52px; padding: var(--s1); gap: var(--s1); justify-content: center; flex-direction: column; font-size: var(--fs-caption); }
  .shell-learn .is-detail, .shell-learn.is-detail { --nav-offset: 0px; }
  .shell-learn.is-detail .mobile-nav { display: none; }
  .shell-main {
    padding: var(--s5) max(var(--s4), env(safe-area-inset-right)) calc(var(--s6) + var(--nav-offset)) max(var(--s4), env(safe-area-inset-left));
  }
  .shell-learn:not(.is-detail) ~ .notifications, #app:has(.shell-learn:not(.is-detail)) + .notifications {
    bottom: calc(var(--nav-height) + max(var(--s4), env(safe-area-inset-bottom)));
  }
  .page-head { align-items: flex-start; flex-direction: column; margin-bottom: var(--s5); }
  .page-head > .actions { justify-content: flex-start; }
  .btn, .btn-sm { min-height: 48px; }
  .icon-btn { width: 48px; min-height: 48px; }
  input:not([type=checkbox], [type=radio], [type=range], [type=file]), select, textarea { min-height: 48px; font-size: var(--fs-body); }
  .auth-layout { display: block; }
  .auth-cover { height: clamp(112px, 26vh, 212px); background-position: center 8%; }
  .auth-cover::after { inset: var(--s3) max(var(--s3), env(safe-area-inset-right)) var(--s3) max(var(--s3), env(safe-area-inset-left)); border-radius: var(--radius); }
  .auth-content { padding: var(--s5) max(var(--s6), env(safe-area-inset-right)) max(var(--s6), env(safe-area-inset-bottom)) max(var(--s6), env(safe-area-inset-left)); }
  .auth-content > .brand { margin-inline: auto; width: min(100%, 392px); }
  .auth-card { margin-block: var(--s6) var(--s3); }
  .auth-heading { margin-bottom: var(--s6); }
  .password-toggle { inset: 0 0 auto auto; }
  .hero { gap: var(--s4); padding: var(--s5); border-radius: var(--radius-group); }
}

@media (max-width: 640px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; scroll-behavior: auto !important; }
  .spinner, .btn[aria-busy="true"]::after { animation-duration: 2s; }
}
:root[data-motion=reduce] *, :root[data-motion=reduce] *::before, :root[data-motion=reduce] *::after {
  transition-duration: 0s !important;
  animation-duration: 0s !important;
  scroll-behavior: auto !important;
}
