:root {
  --ink: #17332a;
  --muted: #6c7c76;
  --green: #176b4d;
  --green-dark: #0f4f39;
  --mint: #dff3e8;
  --cream: #f6f3eb;
  --paper: #fffefa;
  --line: #dfe5df;
  --amber: #e7a83e;
  --red: #b74343;
  --shadow: 0 14px 40px rgba(28, 57, 46, .08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(105, 176, 139, .14), transparent 30rem),
    var(--cream);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  position: sticky; top: 0; z-index: 20;
  height: 72px; padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex; align-items: center; gap: 32px;
  background: rgba(246, 243, 235, .88); border-bottom: 1px solid rgba(23, 51, 42, .08);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .04em; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; background: var(--green); color: white; border-radius: 12px; }
.desktop-nav { display: flex; gap: 8px; margin-left: auto; }
.desktop-nav a { padding: 8px 13px; color: #52645d; border-radius: 10px; }
.desktop-nav a:hover { color: var(--green); background: rgba(23, 107, 77, .08); }
.logout-form { margin: 0; }
.text-button { border: 0; background: none; color: var(--muted); padding: 8px; }
.text-button:hover { color: var(--green); }
.page-shell { width: min(1180px, calc(100% - 40px)); min-height: calc(100vh - 72px); margin: 0 auto; padding: 48px 0 80px; }
.mobile-nav { display: none; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-family: Georgia, "Songti SC", serif; font-size: clamp(2rem, 5vw, 3.7rem); line-height: 1.12; letter-spacing: -.035em; margin-bottom: 16px; }
h2 { font-size: 1.5rem; line-height: 1.3; }
h3 { margin-bottom: 4px; }
.muted { color: var(--muted); }
.eyebrow { display: block; margin-bottom: 10px; color: var(--green); font-size: .76rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.card { background: var(--paper); border: 1px solid rgba(26, 64, 50, .09); border-radius: var(--radius); box-shadow: var(--shadow); }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 46px; padding: 0 20px; border: 1px solid transparent; border-radius: 13px; font-weight: 700; transition: transform .18s, box-shadow .18s, background .18s; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--green); color: white; box-shadow: 0 9px 20px rgba(23, 107, 77, .2); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--ink); background: white; border-color: var(--line); }
.button-wide { width: 100%; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 20px; }
.flash { padding: 12px 16px; border-radius: 12px; background: white; border: 1px solid var(--line); }
.flash-error { color: #8f3030; background: #fff0ee; border-color: #f0c5c0; }
.flash-success { color: #15593f; background: #e6f6ed; border-color: #b9dfca; }

.auth-layout { min-height: calc(100vh - 170px); display: grid; grid-template-columns: 1.15fr .85fr; gap: 8vw; align-items: center; }
.auth-intro { max-width: 650px; }
.auth-intro p { max-width: 560px; color: var(--muted); font-size: 1.08rem; }
.feature-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.feature-chips span { padding: 8px 13px; color: var(--green-dark); background: rgba(255,255,255,.65); border: 1px solid rgba(23,107,77,.15); border-radius: 100px; font-size: .87rem; }
.auth-card { max-width: 450px; width: 100%; justify-self: end; padding: 34px; }
.auth-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 28px; background: #eef0eb; border-radius: 12px; }
.auth-switch a { padding: 8px; text-align: center; border-radius: 9px; color: var(--muted); font-weight: 700; }
.auth-switch a.active { background: white; color: var(--green); box-shadow: 0 3px 10px rgba(0,0,0,.05); }
.stack-form { display: grid; gap: 18px; margin-top: 24px; }
.stack-form label { color: #40544c; font-size: .9rem; font-weight: 700; }
input, select { width: 100%; border: 1px solid #ced8d1; background: white; color: var(--ink); border-radius: 12px; outline: none; }
input { height: 48px; padding: 0 14px; }
select { height: 44px; padding: 0 38px 0 12px; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,77,.11); }
.stack-form label input { margin-top: 6px; }

.hero-row { display: flex; justify-content: space-between; gap: 32px; align-items: end; margin-bottom: 34px; }
.hero-row h1 { font-size: clamp(2rem, 4vw, 3.1rem); margin-bottom: 10px; }
.stat-grid { display: grid; grid-template-columns: 1.45fr repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { position: relative; min-height: 148px; padding: 22px; background: rgba(255,255,255,.78); border: 1px solid rgba(26,64,50,.09); border-radius: 19px; }
.stat-card > span { color: var(--muted); font-size: .88rem; }
.stat-card strong { display: block; margin: 8px 0 0; font-family: Georgia, serif; font-size: 2.4rem; line-height: 1; }
.stat-card strong small { color: rgba(255,255,255,.7); font: 500 .9rem Inter, sans-serif; }
.stat-card > small { color: var(--muted); font-size: .78rem; }
.accent-card { color: white; background: var(--green); }
.accent-card > span { color: rgba(255,255,255,.72); }
.warning-card { background: #fff9eb; }
.progress { height: 5px; margin-top: 20px; overflow: hidden; background: rgba(23,51,42,.1); border-radius: 20px; }
.progress i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.accent-card .progress { background: rgba(255,255,255,.22); }
.accent-card .progress i { background: #ffe2a8; }
.content-grid { display: grid; grid-template-columns: 1fr 330px; gap: 18px; }
.content-grid > .card { padding: 28px; }
.section-heading h2 { margin-bottom: 22px; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card { min-height: 112px; display: grid; grid-template-columns: 46px 1fr auto; gap: 14px; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 16px; transition: border .18s, transform .18s, background .18s; }
.mode-card:hover { transform: translateY(-2px); border-color: rgba(23,107,77,.35); background: #fbfdfb; }
.mode-card p { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.mode-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--mint); color: var(--green); font-size: 1.25rem; }
.review .mode-icon { background: #fff0dc; color: #a96a17; }
.library .mode-icon { background: #e9eef7; color: #42618c; }
.side-card { text-align: center; }
.side-card h2 { display: none; }
.ring { --value: 0; width: 132px; height: 132px; display: grid; place-items: center; margin: 4px auto 26px; border-radius: 50%; background: conic-gradient(var(--green) calc(var(--value) * 1%), #e9eee9 0); position: relative; }
.ring::after { content: ""; position: absolute; inset: 11px; background: var(--paper); border-radius: 50%; }
.ring span { z-index: 1; font: 700 2rem Georgia, serif; }
.type-progress { margin-top: 15px; text-align: left; font-size: .82rem; }
.type-progress > b { float: right; }
.type-progress .progress { margin-top: 7px; }
.favorite-note { margin: 24px 0 0; color: #9b6a1f; font-size: .88rem; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding: 21px 28px; }
.settings-row h3, .settings-row p { margin-bottom: 0; }
.inline-form { display: flex; gap: 10px; }
.inline-form input { width: 90px; }

.practice-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.practice-toolbar h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.8rem); }
.filters { display: flex; align-items: center; gap: 12px; }
.filters select { width: 145px; }
.check-filter { display: flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--muted); font-size: .9rem; }
.check-filter input { width: 18px; height: 18px; }
.question-card { max-width: 860px; margin: 0 auto; padding: clamp(22px, 5vw, 46px); }
.question-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.badge { display: inline-block; padding: 4px 10px; color: var(--green); background: var(--mint); border-radius: 50px; font-size: .76rem; font-weight: 800; }
.question-id { margin-left: 10px; color: #9aa59f; font-size: .78rem; }
.favorite-button { border: 0; background: transparent; color: #c9cec9; font-size: 1.6rem; line-height: 1; }
.favorite-button.active, .favorite-button:hover { color: var(--amber); }
.question-stem { font: 600 clamp(1.18rem, 3vw, 1.55rem)/1.65 Inter, "Microsoft YaHei", sans-serif; margin-bottom: 28px; }
.study-options, .quiz-options { display: grid; gap: 11px; margin-bottom: 26px; }
.option-row, .option-choice { display: flex; align-items: center; gap: 14px; min-height: 58px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.option-row > span, .option-letter { flex: 0 0 32px; display: grid; place-items: center; width: 32px; height: 32px; color: var(--green); background: #edf6f1; border-radius: 9px; font-weight: 800; }
.option-row p { margin: 0; }
.option-choice { cursor: pointer; transition: border .15s, background .15s; }
.option-choice:hover { border-color: rgba(23,107,77,.45); background: #fbfdfb; }
.option-choice input { width: 18px; height: 18px; accent-color: var(--green); }
.option-choice.correct { border-color: #83c09f; background: #ebf8f0; }
.option-choice.incorrect { border-color: #e4a19d; background: #fff0ee; }
.hidden { display: none !important; }
.answer-panel { margin-top: 22px; padding: 24px; border-radius: 17px; background: #eef8f2; border: 1px solid #cbe6d5; }
.answer-label { margin-bottom: 8px; color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.correct-answer { display: grid; gap: 5px; color: var(--green-dark); font-weight: 800; }
.rating-prompt { margin: 20px 0 10px; color: var(--muted); font-size: .88rem; }
.rating-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.rating { padding: 12px 8px; border: 1px solid transparent; border-radius: 12px; background: white; }
.rating b, .rating small { display: block; }
.rating small { color: var(--muted); font-size: .72rem; }
.rating.unknown:hover { color: var(--red); border-color: #e2aaa6; }
.rating.fuzzy:hover { color: #946313; border-color: #e7c98f; }
.rating.know:hover { color: var(--green); border-color: #8ec2a5; }
.result-panel { margin: 18px 0; padding: 18px 20px; border-radius: 14px; }
.result-panel p { margin: 4px 0 0; }
.result-correct { color: #15583f; background: #e8f7ee; border: 1px solid #b8dfc7; }
.result-wrong { color: #843d37; background: #fff0ee; border: 1px solid #efc3bf; }
.memory-status { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 18px; color: var(--muted); font-size: .78rem; }
.next-button { margin-top: 10px; }
.empty-state { max-width: 680px; margin: 50px auto; padding: 50px; text-align: center; }
.empty-icon { display: block; color: var(--green); font-size: 3rem; }

.search-hero { max-width: 800px; margin-bottom: 32px; }
.search-hero h1 { font-size: clamp(2rem, 4vw, 3rem); }
.search-form { display: grid; grid-template-columns: 1fr 150px auto; gap: 10px; }
.question-list { display: grid; gap: 11px; }
.list-item { padding: 20px 24px; }
.list-item > p { margin: 12px 0; }
.list-actions { display: flex; align-items: center; gap: 18px; color: var(--green); font-size: .86rem; font-weight: 700; }
.list-actions form { margin-left: auto; }
.favorite-text.active { color: #a56f19; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 28px; color: var(--muted); }

@media (max-width: 860px) {
  .page-shell { width: min(100% - 28px, 680px); padding: 30px 0 100px; }
  .site-header { height: 62px; padding: 0 16px; }
  .desktop-nav, .logout-form { display: none; }
  .mobile-nav { position: fixed; z-index: 30; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px 5px; background: rgba(255,254,250,.94); border: 1px solid rgba(23,51,42,.12); border-radius: 19px; box-shadow: 0 12px 36px rgba(23,51,42,.18); backdrop-filter: blur(18px); }
  .mobile-nav a { display: grid; place-items: center; gap: 1px; color: var(--muted); font-size: .66rem; }
  .mobile-nav a span { color: var(--green); font-size: 1.15rem; line-height: 1.2; }
  .auth-layout { grid-template-columns: 1fr; gap: 28px; }
  .auth-intro { text-align: center; }
  .auth-intro p { margin-inline: auto; }
  .feature-chips { justify-content: center; }
  .auth-card { justify-self: center; }
  .hero-row { display: block; }
  .hero-row .button { width: 100%; margin-top: 8px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .side-card { order: -1; }
  .ring { width: 110px; height: 110px; }
  .practice-toolbar { align-items: stretch; flex-direction: column; }
  .filters { justify-content: space-between; }
}

@media (max-width: 560px) {
  .brand { font-size: .9rem; }
  .auth-intro h1 { font-size: 2.2rem; }
  .auth-card { padding: 24px 20px; }
  .stat-card { min-height: 128px; padding: 18px; }
  .stat-card strong { font-size: 2rem; }
  .content-grid > .card { padding: 20px; }
  .mode-grid { grid-template-columns: 1fr; }
  .settings-row { align-items: stretch; flex-direction: column; }
  .inline-form input { flex: 1; width: auto; }
  .question-card { padding: 22px 16px; border-radius: 18px; }
  .question-stem { font-size: 1.08rem; }
  .rating-grid { grid-template-columns: 1fr; }
  .search-form { grid-template-columns: 1fr; }
  .list-item { padding: 18px; }
  .list-actions { flex-wrap: wrap; gap: 10px 16px; }
  .list-actions form { margin-left: 0; }
  .pagination { justify-content: space-between; gap: 8px; }
  .pagination .button { padding: 0 12px; font-size: .8rem; }
}
