:root {
  color-scheme: light;
  --bg: #f6efe3;
  --panel: rgba(255, 250, 241, 0.9);
  --card: #fffdf8;
  --ink: #1f1a17;
  --muted: #76695d;
  --line: rgba(67, 46, 28, 0.14);
  --accent: #b44b2a;
  --accent-deep: #7e2f17;
  --shadow: 0 18px 40px rgba(73, 46, 18, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Serif SC", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(213, 148, 104, 0.16), transparent 34%),
    linear-gradient(180deg, #f9f4eb 0%, #f3eadb 100%);
  min-height: 100vh;
}

.page {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.toolbar-panel {
  display: none;
}

.toolbar-back {
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.92);
  color: var(--accent-deep);
  border-radius: 999px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.toolbar-home {
  border: 1px solid rgba(180, 75, 42, 0.12);
  background: rgba(180, 75, 42, 0.08);
  color: var(--accent-deep);
  border-radius: 999px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

/* 返回小白学园主页（固定悬浮，与其他游戏页 home-pill 同风格） */
.site-home-fab {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--panel);
  border: 1.5px solid var(--line);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(73, 46, 18, 0.12);
  transition: all 0.18s ease;
}
.site-home-fab:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}
@media (max-width: 768px) {
  .site-home-fab { top: 10px; right: 10px; padding: 6px 12px; font-size: 12.5px; }
}

.toolbar-title {
  display: none;
}

/* 搜索栏 */
.search-bar {
  padding: 0 0 16px;
}
.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
}
.search-input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
  padding: 0 18px;
  outline: none;
  box-shadow: var(--shadow);
  -webkit-appearance: none;
  appearance: none;
}
.search-input::placeholder { color: var(--muted); opacity: 0.7; }
.search-input:focus { border-color: var(--accent); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  min-height: 48px;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.2s;
}
.search-btn:hover { background: var(--accent-deep); }
@media (max-width: 420px) {
  .search-btn { padding: 0 16px; font-size: 14px; }
}

.panel,
.char-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.status-panel {
  min-height: 24px;
  padding: 0 4px 12px;
  color: var(--muted);
  font-size: 14px;
}

.summary-panel {
  display: none;
  margin-bottom: 18px;
}

.summary-panel.is-visible {
  display: block;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 22px 20px 18px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(180, 75, 42, 0.18), transparent 34%),
    linear-gradient(135deg, rgba(255, 250, 241, 0.96), rgba(249, 240, 228, 0.92));
  border: 1px solid rgba(126, 47, 23, 0.12);
  box-shadow: 0 20px 44px rgba(73, 46, 18, 0.12);
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -34px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(180, 75, 42, 0.08);
}

.hero-title {
  position: relative;
  margin: 0;
  font-size: 36px;
  line-height: 1.06;
  color: var(--ink);
}

.hero-subtitle {
  position: relative;
  margin: 10px 0 0;
  font-size: 18px;
  line-height: 1.5;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.hero-empty {
  padding: 28px 22px;
  border-radius: 28px;
  background: rgba(255, 250, 241, 0.92);
  border: 1px dashed rgba(126, 47, 23, 0.16);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.hero-empty-title {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
}

.hero-empty-text {
  margin: 10px 0 0;
  line-height: 1.8;
  font-size: 14px;
}

.hero-link-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.hero-link-item {
  display: block;
  padding: 12px 14px;
  border-radius: 16px;
  text-decoration: none;
  color: var(--accent-deep);
  background: var(--card);
  border: 1px solid var(--line);
}

.hero-link-item strong {
  display: block;
  font-size: 15px;
}

.hero-link-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.char-stage {
  margin-top: 4px;
}

.panel {
  display: none;
  margin-top: 16px;
  padding: 20px;
}

.panel.is-visible {
  display: block;
}

.word-header {
  display: grid;
  gap: 8px;
}

.panel-label {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.word-title {
  margin: 0;
  font-size: 28px;
}

.word-query {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.meaning-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.word-section + .word-section {
  margin-top: 18px;
}

.section-title {
  margin: 20px 0 0;
  font-size: 17px;
  color: var(--accent-deep);
}

.meaning-item {
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  line-height: 1.7;
}

.extended-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.extended-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
}

.extended-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.extended-title {
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.extended-count {
  font-size: 12px;
  color: var(--muted);
}

.extended-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.extended-items-term {
  gap: 10px;
}

.extended-item {
  width: 100%;
  color: var(--ink);
  line-height: 1.65;
}

.extended-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(180, 75, 42, 0.08);
  border: 1px solid rgba(180, 75, 42, 0.16);
  color: var(--accent-deep);
  font-size: 14px;
}

.extended-card-riddle {
  background:
    radial-gradient(circle at top right, rgba(197, 110, 50, 0.08), transparent 36%),
    var(--card);
}

.extended-card-sentence,
.extended-card-riddle {
  padding-bottom: 16px;
}

.sentence-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.sentence-card {
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
}

.sentence-text {
  line-height: 1.8;
  color: var(--ink);
  font-size: 15px;
}

.sentence-explain {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 13px;
}

.related-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.related-chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--accent-deep);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.related-chip:active {
  transform: scale(0.98);
}

.term-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.term-pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--accent-deep);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.term-pill:hover {
  background: var(--panel);
}

.term-pill:active {
  transform: scale(0.98);
}

.char-card {
  padding: 20px;
}

.char-top {
  display: grid;
  gap: 10px;
}

.char-meta {
  display: inline-grid;
  justify-items: start;
  gap: 8px;
}

.char-glyph {
  font-size: 72px;
  line-height: 1;
  font-weight: 600;
}

.char-pinyin {
  margin: 0;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.writer-shell {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.writer-target {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  background:
    linear-gradient(transparent calc(50% - 0.5px), rgba(180, 75, 42, 0.14) 0, transparent calc(50% + 0.5px)),
    linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(180, 75, 42, 0.14) 0, transparent calc(50% + 0.5px)),
    var(--card);
  border: 1px solid var(--line);
}

.empty-state {
  padding: 24px 10px;
  text-align: center;
  color: var(--muted);
}

.error-card {
  width: 100%;
  padding: 22px 18px;
  border-radius: 22px;
  background: rgba(255, 247, 243, 0.96);
  border: 1px solid rgba(180, 75, 42, 0.16);
  box-shadow: var(--shadow);
  text-align: center;
}

.error-title {
  margin: 0;
  color: var(--accent-deep);
  font-size: 18px;
}

.error-text {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.animations-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
  margin-top: -12px;
  margin-bottom: 24px;
}

.anim-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: calc(50% - 6px); /* 2 items per row, 1 gap of 12px -> 12/2 = 6px */
  min-width: 120px;
}

.anim-header {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.anim-pinyin {
  font-size: 15px;
  color: var(--accent);
  text-align: left;
  letter-spacing: 0.05em;
  min-height: 22px;
  line-height: 22px;
}

.anim-expand {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(180, 75, 42, 0.1);
  color: var(--accent-deep);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.anim-expand:hover {
  background: rgba(180, 75, 42, 0.2);
}

.anim-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.writer-target {
  width: 100%;
  height: 100%;
}

.anim-stage svg {
  width: 100% !important;
  height: 100% !important;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}

.action-row button {
  flex: 1 1 50%;
  padding: 10px 0;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.action-row button:active {
  opacity: 0.8;
}



.details-list {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.details-section-title {
  margin: 0;
  font-size: 17px;
  color: var(--accent-deep);
}

.char-detail-card {
  padding: 20px;
}

.char-detail-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.char-detail-char {
  font-size: 48px;
  font-weight: bold;
  line-height: 1;
}

.query-highlight {
  color: var(--accent);
  font-weight: 600;
}

@media (min-width: 720px) {
  .page {
    padding-top: 32px;
  }
}

@media (max-width: 560px) {
  .hero-title {
    font-size: 30px;
  }

  .word-title {
    font-size: 24px;
  }
}

.writer-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.writer-modal.is-open {
  display: flex;
}

.writer-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 26, 23, 0.78);
  backdrop-filter: blur(6px);
}

.writer-modal-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 480px);
  max-height: 90vh;
  padding: 20px 20px 24px;
  border-radius: 28px;
  background: var(--card);
  box-shadow: 0 24px 60px rgba(31, 26, 23, 0.32);
  box-sizing: border-box;
}

.writer-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(180, 75, 42, 0.1);
  color: var(--accent-deep);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  z-index: 3;
}

.writer-modal-close:hover {
  background: rgba(180, 75, 42, 0.2);
}

.writer-modal-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin-bottom: 14px;
  padding-left: 2px;
}

.writer-modal-char {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.writer-modal-tip {
  font-size: 13px;
  color: var(--muted);
}

.modal-anim-stage {
  position: relative;
  width: 280px;
  height: 280px;
  border-radius: 20px;
  background: var(--panel, #fdfbf7);
  border: 2px solid rgba(180, 75, 42, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  margin: 0 auto;
}

.writer-modal-target {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.writer-modal-target svg {
  display: block;
  margin: 0 auto;
}

.writer-modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 18px;
}

.writer-modal-action {
  flex: 1 1 50%;
  min-height: 44px;
  border: 1px solid rgba(180, 75, 42, 0.14);
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.88);
  color: var(--accent-deep);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.writer-modal-action.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(180, 75, 42, 0.22);
}

.writer-modal-action:active {
  transform: scale(0.98);
}
