/* ==========================================================================
   新视线意大利语1 · 单词背诵网站
   样式表 —— 轻量、无依赖、支持明暗主题与移动端
   ========================================================================== */

:root {
  --green: #009a4e;
  --red: #ce2b37;
  --accent: #0b8a4b;
  --accent-soft: #e7f6ee;
  --danger: #d33;
  --warn: #d97706;
  --info: #1f6fd0;

  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #f0f3f1;
  --surface-3: #e6ebe8;
  --text: #16211c;
  --muted: #6b7a73;
  --border: #dde5e0;
  --shadow: 0 1px 2px rgba(16, 40, 28, .06), 0 8px 24px rgba(16, 40, 28, .07);
  --shadow-sm: 0 1px 2px rgba(16, 40, 28, .08);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1120px;
}

html[data-theme="dark"] {
  --accent: #2fbe77;
  --accent-soft: #12281d;
  --bg: #101614;
  --surface: #17201d;
  --surface-2: #1e2925;
  --surface-3: #27332e;
  --text: #e8f1ec;
  --muted: #93a49c;
  --border: #2a3733;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.tight { gap: 6px; }
.spacer { flex: 1 1 auto; }
.hidden { display: none !important; }

.skip {
  position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff;
  padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip:focus { left: 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 10px 18px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt strong { font-size: 1.02rem; letter-spacing: .2px; }
.brand-txt strong i { color: var(--red); font-style: normal; }
.brand-txt small { color: var(--muted); font-size: .72rem; }
.flag {
  width: 30px; height: 20px; border-radius: 4px; flex: none;
  background: linear-gradient(90deg, var(--green) 0 33.3%, #fff 33.3% 66.6%, var(--red) 66.6% 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .12) inset;
}
.nav { display: flex; gap: 2px; flex: 1 1 auto; flex-wrap: wrap; }
.nav a {
  padding: 7px 11px; border-radius: 999px; color: var(--muted);
  font-size: .9rem; font-weight: 600; position: relative; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.badge {
  display: none; margin-left: 5px; background: var(--red); color: #fff;
  border-radius: 999px; font-size: .68rem; padding: 1px 6px; vertical-align: 1px;
}
.badge.on { display: inline-block; }
.topbar-tools { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.menu-btn { display: none; }

.today-bar { border-top: 1px solid var(--border); background: var(--surface-2); font-size: .82rem; }
.today-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 6px 18px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.today-progress {
  flex: 1 1 140px; max-width: 320px; height: 7px; border-radius: 99px;
  background: var(--surface-3); overflow: hidden;
}
.today-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--accent)); transition: width .4s; }
.today-actions { display: flex; gap: 8px; margin-left: auto; }
.mini-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
}
.mini-btn:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* ---------- 主区域 ---------- */
main { display: block; min-height: 60vh; padding: 22px 0 60px; }
main:focus { outline: none; }

.page-head { margin-bottom: 18px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crumb { color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.crumb a { color: var(--muted); }
.lead { color: var(--muted); max-width: 70ch; margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 14px; }
.grid.units { grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 16px; border-radius: 12px; font-size: .92rem; font-weight: 650;
  cursor: pointer; font-family: inherit; transition: transform .06s, background .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: .82rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; font-size: .76rem; color: var(--muted); white-space: nowrap;
}
.chip.pos { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 700; }
.chip.warn { background: #fdf1e0; color: var(--warn); border-color: transparent; }
html[data-theme="dark"] .chip.warn { background: #33260f; }
.chip.ok { background: #e6f7ee; color: #0b7a45; border-color: transparent; }
html[data-theme="dark"] .chip.ok { background: #12281d; color: #4fd08b; }

/* ---------- 单元卡片 ---------- */
.unit-card {
  position: relative; display: block; color: var(--text); padding: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform .12s, box-shadow .12s;
}
.unit-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.unit-card::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--uc, var(--accent));
}
.unit-card .uc-top { display: flex; align-items: flex-start; gap: 10px; }
.unit-card .uc-icon { font-size: 1.5rem; line-height: 1; }
.unit-card .uc-id { font-size: .74rem; font-weight: 800; color: var(--uc, var(--accent)); letter-spacing: .4px; }
.unit-card h3 { margin: 2px 0 2px; font-size: 1rem; }
.unit-card .uc-it { color: var(--muted); font-style: italic; font-size: .85rem; }
.unit-card .uc-topic { color: var(--muted); font-size: .8rem; margin: 8px 0 10px; min-height: 2.4em; }
.unit-card .uc-foot { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); }
.unit-card .uc-bar { flex: 1 1 auto; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.unit-card .uc-bar i { display: block; height: 100%; background: var(--uc, var(--accent)); transition: width .4s; }

/* ---------- 统计块 ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.stat .k { color: var(--muted); font-size: .78rem; }
.stat .v { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat .v small { font-size: .78rem; font-weight: 600; color: var(--muted); }

.ring {
  --p: 0; width: 62px; height: 62px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0);
  display: grid; place-items: center; position: relative;
}
.ring::after {
  content: attr(data-label); width: 48px; height: 48px; border-radius: 50%;
  background: var(--surface); display: grid; place-items: center;
  font-size: .78rem; font-weight: 800;
}

/* ---------- 学习卡片 ---------- */
.learn-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.learn-meta { width: 100%; max-width: 620px; display: flex; align-items: center; gap: 10px; font-size: .82rem; color: var(--muted); }
.learn-meta .lm-bar { flex: 1 1 auto; height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.learn-meta .lm-bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.fc {
  width: 100%; max-width: 620px; min-height: 330px; perspective: 1400px;
  cursor: pointer; user-select: none;
}
.fc-inner {
  position: relative; width: 100%; min-height: 330px;
  transform-style: preserve-3d; transition: transform .5s cubic-bezier(.4, .1, .2, 1);
}
.fc.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow); padding: 26px 24px 74px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  overflow: auto;
}
.fc-back { transform: rotateY(180deg); justify-content: flex-start; padding-top: 30px; }
.fc-word { font-size: clamp(1.8rem, 6vw, 2.7rem); font-weight: 800; letter-spacing: .3px; line-height: 1.15; }
.fc-word .art { color: var(--muted); font-weight: 600; }
.fc-sub { color: var(--muted); margin-top: 8px; font-size: .9rem; }
.fc-zh { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; }
.fc-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; }
.fc-ex {
  margin-top: 18px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px;
  font-size: .95rem; text-align: left; max-width: 520px; width: 100%;
}
.fc-ex .it { font-weight: 600; }
.fc-ex .zh { color: var(--muted); font-size: .86rem; margin-top: 4px; }
.fc-hint { color: var(--muted); font-size: .8rem; margin-top: 14px; }
.fc-sound {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
.speak {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; font-size: .85rem; font-family: inherit;
}
.speak:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; max-width: 620px; }
.grade {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 14px; padding: 12px 8px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-weight: 700;
}
.grade small { font-weight: 500; color: var(--muted); font-size: .72rem; }
.grade:hover { border-color: currentColor; }
.grade.g0 { color: #c62828; } .grade.g1 { color: #d97706; }
.grade.g2 { color: #0b7a45; } .grade.g3 { color: #1f6fd0; }
.grade kbd { font-size: .68rem; }

kbd {
  background: var(--surface-3); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 5px; font-size: .72rem; font-family: inherit;
}

/* ---------- 测验 ---------- */
.quiz-wrap { max-width: 760px; margin: 0 auto; }
.q-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.q-head .q-bar { flex: 1 1 160px; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.q-head .q-bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px; }
.q-type { font-size: .76rem; font-weight: 800; color: var(--accent); letter-spacing: .5px; text-transform: uppercase; }
.q-prompt { font-size: clamp(1.3rem, 4.5vw, 1.9rem); font-weight: 800; margin: 8px 0 4px; word-break: break-word; }
.q-sub { color: var(--muted); font-size: .88rem; margin-bottom: 14px; }
.q-ex { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 1rem; }
.q-ex .blank { color: var(--red); font-weight: 800; letter-spacing: 2px; }

.opts { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 13px 15px; cursor: pointer; font-family: inherit; font-size: 1rem;
  transition: background .12s, border-color .12s;
}
.opt:hover:not([disabled]) { background: var(--surface-2); border-color: var(--accent); }
.opt .k {
  width: 24px; height: 24px; flex: none; border-radius: 7px; background: var(--surface-2);
  display: grid; place-items: center; font-size: .78rem; font-weight: 800; color: var(--muted);
}
.opt.right { border-color: #0b7a45; background: #e6f7ee; }
html[data-theme="dark"] .opt.right { background: #12281d; }
.opt.right .k { background: #0b7a45; color: #fff; }
.opt.wrong { border-color: var(--red); background: #fdeaea; }
html[data-theme="dark"] .opt.wrong { background: #2c1416; }
.opt.wrong .k { background: var(--red); color: #fff; }
.opt[disabled] { cursor: default; }

.input-row { display: flex; gap: 10px; flex-wrap: wrap; }
.input-row input[type="text"] {
  flex: 1 1 220px; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 1.1rem; font-family: inherit;
}
.input-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: .92rem; }
.feedback.ok { background: #e6f7ee; color: #0b6b3f; }
.feedback.no { background: #fdeaea; color: #a01f1f; }
html[data-theme="dark"] .feedback.ok { background: #12281d; color: #6fdfa4; }
html[data-theme="dark"] .feedback.no { background: #2c1416; color: #ff9b9b; }
.feedback .ans { font-weight: 800; }

/* ---------- 词表 ---------- */
.word-list { display: grid; gap: 8px; }
.word-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.word-item .wi-it { font-weight: 700; min-width: 9em; }
.word-item .wi-zh { color: var(--muted); flex: 1 1 auto; }
.word-item .wi-tools { display: flex; gap: 6px; }
.tiny-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font-size: 14px;
  display: grid; place-items: center; font-family: inherit;
}
.tiny-btn:hover { background: var(--surface-2); color: var(--text); }
.tiny-btn.on { color: var(--red); border-color: var(--red); }

/* ---------- 图表 ---------- */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 10px; }
.chart .bar { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.chart .bar i {
  display: block; width: 100%; max-width: 30px; border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--accent), var(--green)); min-height: 3px;
  transition: height .3s;
}
.chart .bar b { font-size: .68rem; color: var(--muted); font-weight: 600; }

/* ---------- 语法 ---------- */
.grammar-item { border-top: 1px solid var(--border); padding: 14px 0; }
.grammar-item:first-child { border-top: 0; }
.grammar-item h4 { margin: 0 0 6px; font-size: 1rem; }
.grammar-item .eg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.grammar-item .eg span {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 9px; font-size: .86rem;
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 650; font-size: .88rem; margin-bottom: 6px; }
.field .desc { color: var(--muted); font-size: .8rem; margin-top: 4px; }
select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: .95rem;
}
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 8px 0; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.seg { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); padding: 4px; border-radius: 12px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; border: 0; background: transparent; color: var(--muted); font-family: inherit;
  padding: 8px 12px; border-radius: 9px; cursor: pointer; font-size: .88rem; font-weight: 650;
}
.seg button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #16211c; color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: .9rem; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 90; max-width: 90vw; text-align: center;
}
html[data-theme="dark"] .toast { background: #e8f1ec; color: #16211c; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.modal {
  position: fixed; inset: 0; background: rgba(10, 20, 15, .5); z-index: 80;
  display: grid; place-items: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal .modal-box {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  max-width: 620px; width: 100%; max-height: 82vh; overflow: auto; box-shadow: var(--shadow);
}

/* ---------- 结果页 ---------- */
.score-ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; margin: 0 auto 10px;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0);
  display: grid; place-items: center; }
.score-ring span { width: 104px; height: 104px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-size: 1.7rem; font-weight: 800; }

.result-list { display: grid; gap: 8px; margin-top: 12px; }
.result-row { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); font-size: .9rem; }
.result-row .r-it { font-weight: 700; }
.result-row .r-zh { color: var(--muted); }
.result-row.no { background: #fdeaea; }
html[data-theme="dark"] .result-row.no { background: #2c1416; }

.foot { border-top: 1px solid var(--border); background: var(--surface); padding: 20px 0 30px; font-size: .82rem; color: var(--muted); }
.foot p { margin: 0 0 6px; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 10px 14px; flex-direction: column; box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav a { padding: 10px 12px; border-radius: 10px; }
  .menu-btn { display: grid; }
  .brand-txt small { display: none; }
}
@media (max-width: 640px) {
  main { padding: 16px 0 44px; }
  .fc, .fc-inner { min-height: 300px; }
  .grade-row { grid-template-columns: repeat(2, 1fr); }
  .word-item { flex-wrap: wrap; }
  .word-item .wi-it { min-width: 0; }
  .today-actions { margin-left: 0; width: 100%; }
  .stat .v { font-size: 1.25rem; }
}
@media print {
  .topbar, .foot, .no-print { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
