:root {
  --portal-primary: #0d9488;
  --portal-primary-dark: #0f766e;
  --portal-primary-light: #2dd4bf;
  --portal-navy: #16324f;
  --portal-gold: #c3923f;
  --portal-ink: #263548;
  --portal-muted: #64748b;
  --portal-bg: #f6fbfa;
  --portal-card: #ffffff;
  --portal-line: #dcece8;
  --portal-shadow-sm: 0 7px 20px rgba(22, 50, 79, .07);
  --portal-shadow-md: 0 18px 46px rgba(22, 50, 79, .11);
  --font-display: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", STSong, serif;
  --font-body: Inter, "Source Han Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ink: var(--portal-ink);
  --muted: var(--portal-muted);
  --paper: var(--portal-card);
  --line: var(--portal-line);
  --green: var(--portal-primary);
  --mint: #e4f7f3;
  --orange: var(--portal-gold);
}

html { color-scheme: light; }

body {
  background: radial-gradient(circle at 88% 8%, rgba(45, 212, 191, .08), transparent 26rem), var(--portal-bg);
  color: var(--portal-ink);
  font-family: var(--font-body);
  font-size: 15px;
  letter-spacing: .012em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font-family: var(--font-body); }
.shell { grid-template-columns: 248px minmax(0, 1fr); }

.side {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, .94);
  border-right-color: var(--portal-line);
  padding: 28px 18px;
  box-shadow: 8px 0 30px rgba(22, 50, 79, .035);
  backdrop-filter: blur(14px);
}

.logo {
  position: relative;
  color: var(--portal-navy);
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 900;
  letter-spacing: .08em;
  padding: 2px 10px 54px;
}

.logo::after {
  content: "明佑司典 · 智能背诵";
  position: absolute;
  left: 59px;
  top: 34px;
  color: #8192a2;
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
  white-space: nowrap;
}

.logo i {
  display: inline-grid;
  width: 39px;
  height: 39px;
  place-items: center;
  padding: 0;
  margin-right: 10px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--portal-navy), var(--portal-primary-dark));
  box-shadow: 0 8px 18px rgba(13, 148, 136, .2);
  font-family: var(--font-display);
  font-size: 20px;
}

.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-group + .nav-group { margin-top: 18px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}

.group-title::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

[data-group="study"] .group-title { color: #0f766e; }
[data-group="review"] .group-title { color: #a4752a; }
[data-group="tool"] .group-title { color: #16324f; }
[data-group="system"] .group-title { color: #64748b; }

.nav {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  color: #607488;
  padding: 8px 11px;
  border-radius: 11px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .035em;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

.nav-ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: #eef2f5;
  color: #7b8d9e;
  font-size: 13px;
  font-weight: 700;
}

[data-group="study"] .nav-ico { background: #ddf5ef; color: #0f766e; }
[data-group="review"] .nav-ico { background: #fbeed6; color: #a4752a; }
[data-group="tool"] .nav-ico { background: #e6edf5; color: #16324f; }
[data-group="system"] .nav-ico { background: #edf1f4; color: #64748b; }

.nav[data-page="materials"] .nav-ico { background: #e3edfd; color: #2563eb; }
.nav[data-page="weakness"] .nav-ico { background: #fde8da; color: #c2410c; }
.nav[data-page="report"] .nav-ico { background: #ece7fd; color: #6d28d9; }
.nav[data-page="anki"] .nav-ico { background: #e4ecf6; color: #16324f; }
.nav[data-page="settings"] .nav-ico { background: #edf1f4; color: #64748b; }

.nav-label { flex: 1; }
.nav-badge {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: #d9f2ec;
  color: var(--portal-primary-dark);
  font-size: 11px;
  font-weight: 800;
}

.nav.sm { padding: 7px 11px 7px 46px; color: #7b8d9e; font-size: 13px; font-weight: 600; }
.nav.sm .nav-ico { display: none; }

.nav:hover, .nav.on {
  color: var(--portal-primary-dark);
  background: linear-gradient(90deg, #def6f1, #eef9f7);
  transform: translateX(3px);
}
.nav.on { box-shadow: inset 3px 0 0 var(--portal-primary); }
.nav.on .nav-badge { background: #fff; }
[data-group="tool"] .nav.on { color: #16324f; background: linear-gradient(90deg, #e6edf5, #f2f6fa); box-shadow: inset 3px 0 0 #16324f; }
[data-group="system"] .nav.on { color: #4b5b6b; background: linear-gradient(90deg, #edf1f4, #f6f8fa); box-shadow: inset 3px 0 0 #64748b; }

.ext-badge {
  flex: none;
  padding: 2px 6px;
  border-radius: 6px;
  background: #16324f;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  white-space: nowrap;
}

.nav-group-ext { margin-top: 20px; padding-top: 16px; border-top: 1px dashed #d3e0ec; }
.group-hint {
  padding: 0 13px;
  margin: 7px 0 0;
  color: #93a4b4;
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: .02em;
}

.nav-group-bottom { margin-top: auto !important; padding-top: 18px; border-top: 1px dashed #e2e8ee; }

.main { max-width: 1460px; padding: 34px 44px 78px; }

.top {
  min-height: 42px;
  margin-bottom: 24px;
  color: #718195;
  font-size: 13px;
  letter-spacing: .06em;
}

.top > span:first-child { color: var(--portal-primary-dark); font-weight: 800; }
.top a { transition: color .2s ease; }
.top a:hover { color: var(--portal-primary) !important; }
.top > span:last-child { display: flex; align-items: center; gap: 12px; }

.btn {
  border-radius: 10px;
  padding: 11px 17px;
  font-size: 13px;
  letter-spacing: .025em;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.btn:hover { transform: translateY(-2px); }

.primary {
  background: linear-gradient(135deg, var(--portal-primary), var(--portal-primary-dark));
  box-shadow: 0 9px 22px rgba(13, 148, 136, .23);
}

.primary:hover { box-shadow: 0 12px 28px rgba(13, 148, 136, .3); }

.soft {
  border-color: var(--portal-line);
  color: var(--portal-navy);
  box-shadow: 0 4px 12px rgba(22, 50, 79, .05);
}

.hero {
  min-height: 350px;
  padding: 58px 62px;
  border: 1px solid rgba(13, 148, 136, .16);
  background:
    radial-gradient(circle at 91% 12%, rgba(45, 212, 191, .28), transparent 15rem),
    radial-gradient(circle at 82% 98%, rgba(195, 146, 63, .16), transparent 14rem),
    linear-gradient(125deg, #edfcf9 0%, #f3fbfb 55%, #eef5fb 100%);
  color: var(--portal-navy);
  box-shadow: var(--portal-shadow-md);
}

.hero::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(var(--portal-primary-light), var(--portal-primary), var(--portal-gold));
}

.hero::after {
  width: 260px;
  height: 260px;
  right: -65px;
  top: -92px;
  background: rgba(255, 255, 255, .34);
  border: 1px solid rgba(255, 255, 255, .56);
}

.eyebrow, .label { color: var(--portal-primary-dark); font-weight: 900; letter-spacing: .12em; }

.hero h1 {
  max-width: 760px;
  margin: 18px 0 20px;
  color: var(--portal-navy);
  font-family: var(--font-body);
  font-size: 52px;
  font-weight: 900;
  letter-spacing: normal;
  line-height: 1.22;
}

.hero h1 em {
  background: linear-gradient(100deg, var(--portal-primary-light), var(--portal-primary-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-style: normal;
}

.hero p { max-width: 650px; color: #526b7c; font-size: 15px; line-height: 1.95; }

.section, .head h1, .card h2, .card h3, .mat h3, .mainreview h1, .qcard h1 {
  color: var(--portal-navy);
  font-family: var(--font-display);
  font-weight: 900;
}

.section { margin: 34px 0 15px; font-size: 23px; letter-spacing: -.01em; }
.head h1 { font-size: 36px; letter-spacing: -.025em; line-height: 1.3; }
.head p, .sub { color: var(--portal-muted); line-height: 1.85; }
.grid { gap: 20px; }

.card, .mat, .panel, .qcard {
  border-color: var(--portal-line);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--portal-shadow-sm);
}

.card { padding: 24px; }
.card h2 { font-size: 22px; line-height: 1.45; }
.card h3 { font-size: 19px; line-height: 1.5; }

.task {
  background: linear-gradient(135deg, #e8f8f4, #f1faf8);
  border: 1px solid #d5eee8;
}

.ring {
  color: var(--portal-navy);
  border-color: #b9e6dc;
  border-right-color: var(--portal-primary);
  font-variant-numeric: tabular-nums;
}

.stats, .cards { gap: 13px; }

.stat { background: #f4faf8; border: 1px solid #e3f0ed; padding: 15px; }

.stat b, .budget b {
  color: var(--portal-navy);
  font-family: Inter, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.mat { padding: 20px; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }

.mat:hover {
  transform: translateY(-3px);
  border-color: rgba(13, 148, 136, .35);
  box-shadow: var(--portal-shadow-md);
}

.tag { color: var(--portal-primary-dark); background: #dcf6f0; letter-spacing: .04em; }
.bar { background: #e5f0ed; }
.bar i { background: linear-gradient(90deg, var(--portal-primary-light), var(--portal-primary)); }
.create { gap: 22px; }
.settings-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 14px; }
.upload-label { cursor: pointer; }
.upload-label input { display: none; }
.consent { display: flex; align-items: flex-start; gap: 9px; margin: 16px 0; color: var(--portal-muted); font-size: 12px; line-height: 1.6; }
.consent input { width: auto; margin-top: 3px; }

.field label { color: var(--portal-navy); font-size: 13px; letter-spacing: .025em; }

input, textarea, select {
  border-color: #d8e7e3;
  background: #fcfefd;
  color: var(--portal-ink);
  line-height: 1.75;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--portal-primary);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, .1);
}

.tab, .choice { color: #52687a; border-color: var(--portal-line); }

.tab.on, .choice.on {
  color: var(--portal-primary-dark);
  border-color: rgba(13, 148, 136, .45);
  background: #e4f7f3;
}

.budget {
  background: linear-gradient(145deg, var(--portal-navy), #214f64);
  box-shadow: 0 14px 30px rgba(22, 50, 79, .18);
}

.budget b { color: #fff; }

.notice { color: #6f6044; background: #fff8e9; border: 1px solid #f1dfb9; }
.review { gap: 16px; }
.review-head, .page-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; }
.review-head .head p { margin-bottom: 0; }
.status-pill { display: inline-block; padding: 8px 12px; border-radius: 999px; color: var(--portal-primary-dark); background: #e2f6f2; font-size: 12px; font-weight: 800; }
.btn:disabled { cursor: not-allowed; opacity: .45; transform: none; box-shadow: none; }
.panel { min-width: 0; padding: 19px; }
.concept { color: #52687a; line-height: 1.55; }
.concept.on { color: var(--portal-primary-dark); background: #e4f7f3; }
.mainreview h1 { font-size: 31px; letter-spacing: -.02em; line-height: 1.35; }
.lead, .source { color: #5d7081; line-height: 1.95; }
.module { border-top-color: var(--portal-line); }

.frame {
  grid-template-columns: 82px 1fr;
  background: #f5faf8;
  border: 1px solid #e5f0ed;
  line-height: 1.7;
}

.frame b { color: var(--portal-primary-dark); }

.anchor {
  color: #8a5d1f;
  background: #fff4dc;
  border: 1px solid #f1ddb2;
}

.memo {
  border-left-color: var(--portal-gold);
  background: #fff9ed;
  color: #5f584b;
  line-height: 1.85;
}
.mnemonic-label { margin-top: 16px; }
.text-action { border: 0; padding: 0; background: transparent; color: var(--portal-primary-dark); font-weight: 800; cursor: pointer; }
.edit-area { min-height: 160px; margin: 10px 0; }
.preview-question { display: flex; gap: 10px; padding: 10px 12px; margin: 8px 0; border-radius: 9px; background: #f6faf9; color: #52687a; font-size: 13px; line-height: 1.6; }
.preview-question b { min-width: 54px; color: var(--portal-primary-dark); }
.evidence { align-self: start; }

.risk { color: #845d24; background: #fff6e5; border: 1px solid #f0dcb4; }
.progress { background: #dcece8; }
.progress i { background: linear-gradient(90deg, var(--portal-primary-light), var(--portal-primary)); }
.qcard { padding: 54px; }
.qcard h1 { letter-spacing: -.02em; line-height: 1.45; }
.answer { border-color: #b8d8d1; background: #f8fcfb; line-height: 1.9; }
.source-drawer { margin-top: 14px; text-align: left; color: var(--portal-muted); font-size: 13px; line-height: 1.8; }
.source-drawer summary { cursor: pointer; color: var(--portal-primary-dark); font-weight: 800; }
.study-answer { height: 150px; margin: 20px 0; text-align: left; }
.study-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.feedback { display: flex; flex-direction: column; gap: 5px; text-align: left; background: #fff3df; color: #87591c; border-radius: 12px; padding: 14px; margin: 18px 0; }
.feedback.good { background: #e9f7f2; color: #08695f; }
.feedback span { font-size: 13px; line-height: 1.6; }
.evidence mark { background: #ffe8a8; color: inherit; border-radius: 3px; padding: 1px 2px; }
.ratings button { color: #52687a; background: #eef5f3; }
.ratings button small { display: block; margin-top: 4px; color: #82909d; font-size: 10px; }
.ratings button:hover { color: var(--portal-primary-dark); background: #dff5f0; }
#toast { background: var(--portal-navy); box-shadow: var(--portal-shadow-md); }
.empty { padding: 54px 28px; border: 1px dashed #bfdad4; border-radius: 18px; background: rgba(255,255,255,.72); text-align: center; }
.empty b { display: block; color: var(--portal-navy); font-family: var(--font-display); font-size: 23px; }
.empty p { color: var(--portal-muted); }
.loading-card { color: var(--portal-muted); text-align: center; }
.report-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 24px 0; }
.metric { padding: 22px; border: 1px solid var(--portal-line); border-radius: 15px; background: #fff; box-shadow: var(--portal-shadow-sm); }
.metric b { display: block; color: var(--portal-navy); font-size: 30px; font-variant-numeric: tabular-nums; }
.metric span { color: var(--portal-muted); font-size: 12px; }
.history { display: grid; gap: 8px; margin-top: 16px; }
.history > div { display: grid; grid-template-columns: 1fr auto 110px; gap: 16px; align-items: center; padding: 11px 13px; border-radius: 10px; background: #f6faf9; }
.history small { color: var(--portal-muted); }
.history b { font-size: 12px; }
.version-list { display: grid; gap: 8px; max-height: 320px; overflow: auto; margin-top: 16px; }
.version-list > div { display: grid; grid-template-columns: 80px 1fr auto; gap: 10px; align-items: center; padding: 11px; border-radius: 10px; background: #f6faf9; }
.version-list span,.version-list small { color: var(--portal-muted); font-size: 12px; }
.rating-again { color: #b45309; }.rating-hard { color: #a16207; }.rating-good { color: var(--portal-primary-dark); }.rating-easy { color: #2563eb; }
.weak-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 22px; }
.membership-shell,.admin-shell{max-width:1180px;margin:0 auto;padding:42px 20px 80px}.membership-card,.admin-card{background:#fff;border:1px solid var(--portal-line);border-radius:18px;padding:25px;box-shadow:var(--portal-shadow-sm)}.membership-card{max-width:520px;margin:35px auto}.membership-card h1,.admin-head h1{font-family:var(--font-display);color:var(--portal-navy)}.membership-card label,.admin-card label{display:block;margin:13px 0;color:var(--portal-navy);font-size:13px;font-weight:800}.membership-card input,.admin-card input,.admin-card select{margin-top:6px}.membership-card .btn{width:100%;margin-top:8px}.back-link{color:var(--portal-primary-dark);font-weight:800;text-decoration:none}.admin-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:20px}.admin-grid{display:grid;grid-template-columns:1.35fr .85fr;gap:18px}.row-between{display:flex;justify-content:space-between;align-items:center}.user-row,.file-row{padding:13px 0;border-top:1px solid var(--portal-line);display:flex;justify-content:space-between;gap:12px;align-items:center}.user-row small,.file-row small{display:block;color:var(--portal-muted);font-size:11px;margin-top:3px}.user-actions{display:flex;gap:6px;align-items:center;flex-wrap:wrap;justify-content:flex-end}.btn.mini{padding:6px 9px;font-size:11px}.btn.danger{color:#9b3427;border-color:#efc2bc}.perm{display:inline-flex!important;align-items:center;gap:3px;margin:0!important;font-size:11px!important;font-weight:600!important}.perm input{width:auto;margin:0}.hide{display:none!important}

:focus-visible { outline: 3px solid rgba(45, 212, 191, .55); outline-offset: 3px; }

@media (max-width: 1180px) and (min-width: 901px) {
  .hero h1 { font-size: 44px; }
  .review { grid-template-columns: 190px minmax(0, 1fr); }
  .review > .panel:last-child { grid-column: 1 / -1; }
  .source { overflow-wrap: anywhere; }
}

@media (max-width: 900px) {
  .side { flex-direction: row; }
  .nav-group { display: contents; }
  .nav-group-ext, .nav-group-bottom { margin-top: 0 !important; padding-top: 0; border-top: 0; }
  .group-title, .group-hint { display: none; }
  .nav { width: auto; justify-content: center; transform: none !important; padding: 10px 8px; gap: 0; }
  .nav-ico { width: auto; height: auto; border-radius: 0; background: transparent !important; font-size: 18px; }
  .nav-label, .nav-badge, .ext-badge { display: none; }
  .nav.sm { padding: 10px 8px; }
  .nav.sm .nav-ico { display: grid; }
  .nav.on { box-shadow: none; background: transparent !important; }
  .main { padding: 22px 17px 88px; }
  .hero { min-height: auto; padding: 42px 30px; }
  .logo::after { display: none; }
  .side { box-shadow: 0 -5px 22px rgba(22, 50, 79, .08); }
  .review-head, .page-head { align-items: flex-start; flex-direction: column; }
  .settings-grid, .report-stats, .weak-list { grid-template-columns: 1fr; }
  .top > span:last-child { gap: 7px; }
  .top a { font-size: 11px; }
}

@media (max-width: 480px) {
  body { font-size: 14px; }
  .hero { padding: 34px 23px; border-radius: 19px; }
  .hero h1 { font-size: 33px; }
  .head h1 { font-size: 30px; }
  .qcard { padding: 34px 20px; }
}
@media (max-width: 820px) {.admin-grid{grid-template-columns:1fr}.admin-head{display:block}.admin-head #logout{margin-top:10px}.user-row{display:block}.user-actions{justify-content:flex-start;margin-top:10px}}
