/* 九九的专属课桌 · 基础层：令牌、排版、基元、动效 */
:root {
  --paper: #F4F4EF;
  --paper-2: #EDEDE6;
  --surface: #FFFFFF;
  --surface-2: #FAFAF6;
  --ink: #16181C;
  --ink-2: #555B63;
  --ink-3: #8A9099;
  --line: #E5E5DE;
  --line-2: #D7D7CE;
  --accent: #1F6A55;
  --accent-ink: #12463A;
  --accent-soft: #E6F0EB;
  --blue: #2E5C8A;
  --blue-soft: #E8EFF6;
  --warn: #8C6415;
  --warn-soft: #F6EEDC;
  --alert: #9C5A16;
  --alert-soft: #F8EDDF;
  --bad: #A0392B;
  --bad-soft: #F7E8E4;
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 26px;
  --sh-1: 0 1px 2px rgba(20, 22, 26, .05);
  --sh-2: 0 12px 32px -20px rgba(20, 22, 26, .35);
  --sh-3: 0 40px 80px -32px rgba(16, 18, 22, .45);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --spring: cubic-bezier(.34, 1.32, .64, 1);
  --t-fast: 120ms;
  --t-base: 200ms;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

body.no-scroll { overflow: hidden; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-3); font-size: 12.5px; }
.link { color: var(--accent); font-size: 12.5px; font-weight: 500; border-radius: 6px; }
.link:hover { color: var(--accent-ink); }

.icon { width: 18px; height: 18px; flex: none; }

/* ---------- 通用部件 ---------- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 13px; font-weight: 600; letter-spacing: .02em;
}
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }

.btn {
  height: 38px; padding: 0 14px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13.5px; font-weight: 500; letter-spacing: .01em;
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  transition: transform var(--t-fast) var(--ease), background var(--t-base), border-color var(--t-base), color var(--t-base);
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #242730; }
.btn-ghost { border-color: var(--line); background: var(--surface); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--line-2); color: var(--ink); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger-text { color: var(--bad); }
.btn-danger-text:hover { background: var(--bad-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 46px; font-size: 14.5px; border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn .icon { width: 16px; height: 16px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  color: var(--ink-3); transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: rgba(22, 24, 28, .06); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }

.input {
  height: 40px; width: 100%; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 14px; transition: border-color var(--t-base), box-shadow var(--t-base);
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-sm { height: 34px; font-size: 13px; width: 180px; }
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 12px; color: var(--ink-3); letter-spacing: .02em; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 500; letter-spacing: .01em;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.chip::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .7; }
.chip-ok { background: var(--accent-soft); color: var(--accent-ink); }
.chip-info { background: var(--blue-soft); color: var(--blue); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-alert { background: var(--alert-soft); color: var(--alert); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-muted { background: var(--surface-2); color: var(--ink-3); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--sh-1);
}
.card + .card { margin-top: 16px; }
.card-flat { box-shadow: none; background: var(--surface-2); }
.card-note { color: var(--ink-3); font-size: 12.5px; margin: 2px 0 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.section-extra { color: var(--ink-3); font-size: 12.5px; }

.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: var(--r-sm);
  transition: background var(--t-fast); min-width: 0;
}
.list .row + .row { border-top: 1px solid var(--line); }
.list-tight .row { padding: 9px 8px; }
.row-link:hover, .row-lecture:hover { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { font-size: 14px; font-weight: 500; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; align-items: center; gap: 8px; flex: none; }
.row-go { color: var(--line-2); display: grid; place-items: center; transition: transform var(--t-base) var(--ease), color var(--t-base); }
.row-link:hover .row-go, .row-lecture:hover .row-go { color: var(--ink-3); transform: translateX(2px); }
.row-ok { color: var(--accent); }
.row-mark { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; opacity: .55; }
.row-stack { align-items: flex-start; }
.row-side-bar { width: 132px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 34px 20px 30px; }
.empty-icon {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-3); margin-bottom: 14px;
}
.empty-title { font-size: 14px; font-weight: 500; }
.empty-hint { font-size: 12.5px; color: var(--ink-3); max-width: 36ch; margin-top: 6px; }
.empty-action { margin-top: 16px; }
.empty-error .empty-icon { background: var(--bad-soft); color: var(--bad); }

.skeleton { display: flex; flex-direction: column; gap: 14px; padding: 8px 4px; }
.skel-row { display: flex; gap: 12px; align-items: center; animation: fade 400ms var(--ease) both; }
.skel-dot { width: 34px; height: 34px; border-radius: 10px; background: var(--paper-2); flex: none; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skel-lines i { display: block; height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--paper-2) 0%, #F7F7F2 40%, var(--paper-2) 80%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel-lines i:last-child { width: 46%; }

.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring-svg { width: 96px; height: 96px; }
.ring-track { fill: none; stroke: var(--line); stroke-width: 6; }
.ring-arc { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.ring-label b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ring-label span { font-size: 10.5px; color: var(--ink-3); }

.bar { height: 6px; border-radius: 999px; background: var(--paper-2); overflow: hidden; width: 100%; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); width: 0%; }

.form-msg { min-height: 18px; font-size: 12.5px; color: var(--ink-3); }
.form-msg.is-error { color: var(--bad); }

.spinner {
  width: 14px; height: 14px; border-radius: 50%; display: inline-block;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.is-loading { pointer-events: none; }

/* ---------- 分段控件 ---------- */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px;
  background: var(--paper-2); border: 1px solid var(--line); margin-bottom: 16px;
}
.seg {
  height: 30px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 7px;
  transition: color var(--t-base), background var(--t-base), box-shadow var(--t-base), transform var(--t-fast);
}
.seg:active { transform: scale(.97); }
.seg.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); font-weight: 500; }
.seg-count { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.seg.is-active .seg-count { color: var(--accent); }

/* ---------- 轻提示 ---------- */
#toasts {
  position: fixed; z-index: 200; display: flex; flex-direction: column; gap: 8px;
  right: 24px; bottom: 24px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 13px; box-shadow: var(--sh-2);
  opacity: 0; transform: translateY(10px) scale(.98);
  transition: opacity var(--t-base) var(--ease), transform 260ms var(--spring);
  max-width: 320px;
}
.toast.in { opacity: 1; transform: none; }
.toast-mark { display: grid; place-items: center; color: #7ED0B0; }
.toast-err .toast-mark { color: #FF9E8C; }
.toast .icon { width: 16px; height: 16px; }

/* ---------- 覆盖层与面板 ---------- */
#overlay { position: fixed; inset: 0; z-index: 100; display: none; }
#overlay[data-open] { display: grid; place-items: center; }
.overlay-backdrop {
  position: absolute; inset: 0; background: rgba(18, 20, 24, .34);
  backdrop-filter: blur(6px) saturate(120%); -webkit-backdrop-filter: blur(6px) saturate(120%);
  animation: fade 180ms var(--ease) both;
}
.sheet {
  position: relative; width: min(440px, calc(100vw - 32px)); max-height: min(84vh, 720px);
  display: flex; flex-direction: column; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); padding: 18px;
  animation: pop 220ms var(--spring) both;
}
.sheet[data-closing] { animation: fadeOut 180ms var(--ease) both; }
.sheet-grip { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sheet-title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.sheet-body { overflow: auto; padding: 6px 0 2px; }
.sheet-text { font-size: 13.5px; color: var(--ink-2); }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.pick-list { display: flex; flex-direction: column; gap: 4px; }
.pick-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px; border-radius: var(--r-sm);
  border: 1px solid transparent; text-align: left; transition: background var(--t-fast), border-color var(--t-base);
}
.pick-item:hover { background: var(--surface-2); }
.pick-item.is-current { border-color: var(--line); background: var(--surface-2); }
.pick-main { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.pick-main b { font-size: 14px; font-weight: 500; }
.pick-main i { font-size: 12px; color: var(--ink-3); font-style: normal; }
.pick-check { color: var(--accent); }
.pick-go { color: var(--line-2); }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-aside {
  position: relative; overflow: hidden; background: #14161A; color: #F2F2EC;
  padding: 48px 56px; display: flex; flex-direction: column;
}
.login-aside::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .09) 1px, transparent 1px);
  background-size: 22px 22px; opacity: .5; pointer-events: none;
}
.login-aside::after {
  content: ""; position: absolute; left: 56px; right: 56px; top: 0; height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent 70%); opacity: .8;
}
.aside-top { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(242, 242, 236, .72); position: relative; }
.aside-body { margin: auto 0; position: relative; }
.aside-title { font-size: 40px; line-height: 1.28; font-weight: 600; letter-spacing: -.03em; }
.aside-sub { margin-top: 16px; color: rgba(242, 242, 236, .6); font-size: 14px; }
.aside-list { margin-top: 44px; display: flex; flex-direction: column; gap: 22px; }
.aside-list li { display: flex; gap: 16px; align-items: flex-start; }
.aside-list span { font-family: var(--mono); font-size: 11.5px; color: rgba(242, 242, 236, .38); padding-top: 3px; }
.aside-list b { font-size: 14px; font-weight: 500; display: block; }
.aside-list p { font-size: 12.5px; color: rgba(242, 242, 236, .5); margin-top: 3px; }
.aside-foot { position: relative; font-size: 11.5px; color: rgba(242, 242, 236, .34); letter-spacing: .04em; }
.login-main { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(100%, 380px); }
.login-title { font-size: 26px; font-weight: 600; letter-spacing: -.025em; }
.login-sub { color: var(--ink-3); font-size: 13px; margin-top: 6px; }
.login-form { margin-top: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-hint { margin-top: 22px; font-size: 12px; color: var(--ink-3); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; font-size: 13.5px; font-weight: 500; }
.monogram {
  width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 15px; line-height: 1; flex: none;
}
.monogram-lg { width: 34px; height: 34px; font-size: 19px; border-radius: 10px; background: rgba(242, 242, 236, .1); color: #F2F2EC; border: 1px solid rgba(242, 242, 236, .14); }

/* ---------- 动效 ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.965) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 15% { transform: translateX(-3px); } 30% { transform: translateX(3px); } 45% { transform: translateX(-2px); } 60% { transform: translateX(2px); } 100% { transform: none; } }
@keyframes flash { 0%, 100% { box-shadow: var(--sh-1); } 18% { box-shadow: 0 0 0 3px var(--accent-soft); } }

.view-in { animation: fadeUp 240ms var(--ease) both; }
.stagger { animation: fadeUp 280ms var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms); }
.shake { animation: shake 320ms var(--ease); }
.is-flash { animation: flash 1.8s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  transition: background-color 9999s ease-in-out 0s;
}
