:root {
  --bg: #f7f3ea;
  --bg-soft: #fdfbf7;
  --panel: rgba(255, 252, 246, 0.9);
  --card: #ffffff;
  --ink: #173844;
  --ink-soft: #58707a;
  --line: rgba(23, 56, 68, 0.12);
  --blue: #2d6d80;
  --blue-deep: #1f5362;
  --green: #4e7b60;
  --warm: #d3a05d;
  --danger: #b95e54;
  --shadow: 0 18px 48px rgba(29, 47, 53, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --max-width: 820px;
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(78, 123, 96, 0.15), transparent 28%),
    radial-gradient(circle at top right, rgba(45, 109, 128, 0.12), transparent 32%),
    linear-gradient(180deg, #fcfaf5 0%, var(--bg) 100%);
  color: var(--ink);
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(45, 109, 128, 0.45);
  box-shadow: 0 0 0 4px rgba(45, 109, 128, 0.12);
}

textarea {
  resize: vertical;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: "Georgia", "STZhongsong", "Songti SC", serif;
}

.app-shell {
  min-height: 100vh;
  padding: 18px 14px 110px;
}

.app-main {
  width: min(100%, var(--max-width));
  margin: 0 auto;
}

.page-stack {
  display: grid;
  gap: 16px;
}

.panel,
.hero-card,
.metric-card,
.empty-state,
.quiz-card,
.detail-card,
.favorite-card,
.flip-card,
.phonebook-item {
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.hero-card,
.panel,
.quiz-card,
.empty-state {
  padding: 20px;
  border-radius: var(--radius-xl);
}

.hero-card {
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -60px;
  bottom: -80px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(45, 109, 128, 0.18), rgba(78, 123, 96, 0.12));
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-copy,
.subtle,
.panel-copy,
.empty-state p,
.form-hint {
  color: var(--ink-soft);
  line-height: 1.6;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(45, 109, 128, 0.1);
  color: var(--blue-deep);
  font-weight: 700;
  font-size: 0.88rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.search-field label {
  font-size: 0.92rem;
  font-weight: 700;
}

.span-2 {
  grid-column: span 2;
}

.button-row,
.triple-actions,
.stats-actions,
.modal-actions,
.chips,
.status-chip-row,
.sync-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  padding: 14px 18px;
  border-radius: 16px;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.button:hover,
.nav-item:hover,
.phonebook-item:hover,
.favorite-card:hover,
.flip-card:hover,
.chip:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, var(--blue), #478a9f);
  color: #fff;
}

.button-secondary {
  background: rgba(45, 109, 128, 0.1);
  color: var(--blue-deep);
}

.button-danger {
  background: rgba(185, 94, 84, 0.12);
  color: var(--danger);
}

.search-field {
  display: grid;
  gap: 8px;
}

.phonebook {
  display: grid;
  gap: 14px;
}

.letter-group {
  display: grid;
  gap: 10px;
}

.letter-head {
  position: sticky;
  top: 8px;
  z-index: 1;
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(23, 56, 68, 0.9);
  color: #fff;
  font-weight: 700;
}

.phonebook-list,
.favorites-list,
.simple-list {
  display: grid;
  gap: 12px;
}

.phonebook-item,
.favorite-card,
.simple-item {
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  text-align: left;
}

.phonebook-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.item-copy,
.favorite-card p,
.simple-item p {
  margin-top: 6px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.row-meta,
.favorite-head,
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.tag.favorite {
  background: rgba(45, 109, 128, 0.1);
  color: var(--blue-deep);
}

.tag.mastery-未掌握 {
  background: rgba(185, 94, 84, 0.14);
  color: var(--danger);
}

.tag.mastery-模糊 {
  background: rgba(211, 160, 93, 0.2);
  color: #986223;
}

.tag.mastery-已掌握 {
  background: rgba(78, 123, 96, 0.16);
  color: var(--green);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-weight: 600;
}

.flip-card {
  min-height: 360px;
  padding: 0;
  border-radius: 30px;
  perspective: 1200px;
  background: transparent;
}

.flip-inner {
  position: relative;
  min-height: 360px;
  transform-style: preserve-3d;
  transition: transform 0.66s ease;
}

.flip-card.flipped .flip-inner {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  border-radius: 30px;
  box-shadow: var(--shadow);
  backface-visibility: hidden;
}

.flip-front {
  background: linear-gradient(135deg, rgba(45, 109, 128, 0.92), rgba(78, 123, 96, 0.88));
  color: #fff;
}

.flip-front .eyebrow,
.flip-front .subtle {
  color: rgba(255, 255, 255, 0.88);
}

.flip-back {
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.98), rgba(238, 242, 235, 0.98));
  color: var(--ink);
  transform: rotateY(180deg);
  align-content: start;
  justify-items: start;
}

.card-notes {
  display: grid;
  gap: 10px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.quiz-card {
  display: grid;
  gap: 16px;
}

.answer-box {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(45, 109, 128, 0.08);
  line-height: 1.65;
}

.answer-box.hidden-answer {
  border: 1px dashed rgba(45, 109, 128, 0.26);
  background: rgba(255, 255, 255, 0.6);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: var(--radius-lg);
}

.metric-card strong {
  font-size: 2rem;
  line-height: 1;
}

.sync-status {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(45, 109, 128, 0.08);
  border: 1px solid rgba(45, 109, 128, 0.12);
}

.sync-status-error {
  background: rgba(185, 94, 84, 0.08);
  border-color: rgba(185, 94, 84, 0.18);
}

.sync-meta {
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.install-tip {
  margin-top: 10px;
}

.account-box,
.space-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
}

.metric-card.blue {
  background: linear-gradient(135deg, rgba(45, 109, 128, 0.14), rgba(255, 255, 255, 0.96));
}

.metric-card.green {
  background: linear-gradient(135deg, rgba(78, 123, 96, 0.14), rgba(255, 255, 255, 0.96));
}

.metric-card.warm {
  background: linear-gradient(135deg, rgba(211, 160, 93, 0.18), rgba(255, 255, 255, 0.96));
}

.metric-card.ink {
  background: linear-gradient(135deg, rgba(23, 56, 68, 0.12), rgba(255, 255, 255, 0.96));
}

.progress-track {
  height: 14px;
  border-radius: 999px;
  background: rgba(23, 56, 68, 0.08);
  overflow: hidden;
  margin: 16px 0 14px;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #78a184);
}

.simple-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.empty-state {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 38px 22px;
}

.empty-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(45, 109, 128, 0.14), rgba(78, 123, 96, 0.14));
  color: var(--blue);
  font-size: 1.4rem;
  font-weight: 700;
  font-family: "Georgia", "STZhongsong", "Songti SC", serif;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 18px), 820px);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 24px;
  background: rgba(247, 243, 234, 0.94);
  border: 1px solid rgba(23, 56, 68, 0.08);
  box-shadow: 0 18px 48px rgba(29, 47, 53, 0.18);
  backdrop-filter: blur(16px);
}

.nav-item {
  min-height: 56px;
  padding: 10px 8px;
  border-radius: 18px;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(45, 109, 128, 0.18), rgba(78, 123, 96, 0.18));
  color: var(--blue-deep);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(15, 29, 36, 0.42);
  z-index: 30;
}

.detail-card {
  width: min(100%, 640px);
  max-height: 88vh;
  overflow: auto;
  padding: 20px;
  border-radius: 30px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.icon-button {
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(45, 109, 128, 0.08);
  color: var(--blue-deep);
  font-weight: 700;
}

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-row {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-row strong {
  font-size: 0.95rem;
}

.detail-row span {
  color: var(--ink-soft);
  line-height: 1.65;
}

.chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(45, 109, 128, 0.08);
  color: var(--blue-deep);
  font-weight: 700;
}

.chip.active {
  background: var(--blue);
  color: #fff;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(23, 56, 68, 0.94);
  color: #fff;
  z-index: 40;
  box-shadow: 0 16px 40px rgba(15, 29, 36, 0.24);
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .form-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .panel-header,
  .phonebook-item,
  .simple-item,
  .detail-header {
    flex-direction: column;
  }

  .bottom-nav {
    gap: 4px;
    padding: 8px;
  }

  .nav-item {
    min-height: 58px;
    font-size: 0.82rem;
  }
}
