:root {
  --bg: #f6f7fb;
  --bg-soft: #eef1f8;
  --card: #ffffff;
  --ink: #1b2030;
  --ink-soft: #5b6478;
  --ink-faint: #8b93a7;
  --line: #e6e9f2;
  --brand: #3b5bdb;
  --brand-soft: #eef2ff;
  --accent: #e03131;
  --ok: #2f9e44;
  --warn: #f08c00;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 25, 50, 0.04), 0 8px 24px rgba(20, 25, 50, 0.06);
  --shadow-lg: 0 12px 40px rgba(20, 25, 50, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(1200px 600px at 80% -10%, #e9edfb 0%, transparent 60%), var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.flag {
  width: 14px;
  height: 38px;
  border-radius: 4px;
  background: linear-gradient(to bottom, #0055a4 0 33%, #ffffff 33% 66%, #ef4135 66% 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.brand-text h1 {
  font-family: "Lora", Georgia, serif;
  font-size: 19px;
  margin: 0;
  letter-spacing: 0.3px;
}

.brand-text p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-faint);
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-soft);
  padding: 5px;
  border-radius: 12px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  background: var(--card);
  color: var(--brand);
  box-shadow: var(--shadow);
}

/* ---------- Layout ---------- */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.panel {
  display: none;
  animation: fade 0.28s ease;
}

.panel.active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hint {
  color: var(--ink-faint);
  font-size: 13px;
  margin: 10px 2px 22px;
}

.section-title {
  font-family: "Lora", Georgia, serif;
  font-size: 24px;
  margin: 4px 0 0;
}

/* ---------- Search ---------- */
.search {
  display: flex;
  gap: 10px;
}

#search-input {
  flex: 1;
  font: inherit;
  font-size: 16px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-color 0.18s, box-shadow 0.18s;
}

#search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

#search-btn {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 0 26px;
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: filter 0.18s, transform 0.05s;
}

#search-btn:hover {
  filter: brightness(1.07);
}

#search-btn:active {
  transform: translateY(1px);
}

#search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------- Word card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  margin-top: 8px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.word-title {
  font-family: "Lora", Georgia, serif;
  font-size: 36px;
  font-weight: 600;
  margin: 0;
  line-height: 1.1;
}

.ipa {
  color: var(--brand);
  font-size: 18px;
  font-weight: 500;
}

.freq {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--warn);
  background: #fff4e6;
  padding: 4px 11px;
  border-radius: 999px;
}

.summary {
  width: 100%;
  color: var(--ink-soft);
  font-size: 15px;
  margin-top: 2px;
}

.audio-row {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}

.audio-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

.audio-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.audio-btn .dot.f {
  background: #e64980;
}

.audio-btn .dot.m {
  background: #4263eb;
}

/* sections */
.block {
  margin-top: 22px;
}

.block-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 10px;
}

.meaning-main {
  font-size: 18px;
  font-weight: 600;
}

.sense {
  margin: 12px 0;
  padding-left: 14px;
  border-left: 3px solid var(--brand-soft);
}

.sense-pos {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 4px;
}

.sense ol {
  margin: 0;
  padding-left: 20px;
}

.sense li {
  margin: 4px 0;
}

.sense .fr-note {
  color: var(--ink-faint);
  font-style: italic;
}

.ex {
  margin: 8px 0;
  padding: 10px 14px;
  background: var(--bg-soft);
  border-radius: 10px;
}

.ex .fr {
  font-weight: 500;
}

.ex .zh,
.ex .en {
  font-size: 14px;
  color: var(--ink-soft);
}

.ex .en {
  font-style: italic;
}

/* conjugation table */
.conj-tenses {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.conj-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.conj-card h4 {
  margin: 0;
  font-size: 13px;
  padding: 8px 12px;
  background: var(--brand-soft);
  color: var(--brand);
}

.conj-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.conj-card td {
  padding: 5px 12px;
  border-top: 1px solid var(--line);
}

.conj-card td.p {
  color: var(--ink-faint);
  width: 42%;
}

.conj-meta {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-soft);
}

.kv {
  margin: 8px 0;
}

.kv b {
  color: var(--ink);
}

.bridge {
  background: linear-gradient(180deg, #f3f6ff, #ffffff);
  border: 1px solid var(--brand-soft);
  border-radius: 12px;
  padding: 16px 18px;
}

.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

@media (max-width: 640px) {
  .cols {
    grid-template-columns: 1fr;
  }
}

/* ---------- spinner / states ---------- */
.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 56px 28px;
  text-align: center;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-card .l-title {
  font-weight: 600;
}

.loading-card .l-sub {
  font-size: 13px;
  color: var(--ink-faint);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge.cached {
  background: #ebfbee;
  color: var(--ok);
}

.badge.fresh {
  background: #fff4e6;
  color: var(--warn);
}

.error-card {
  border-left: 4px solid var(--accent);
}

.error-card .e-title {
  font-weight: 700;
  color: var(--accent);
}

/* ---------- materials ---------- */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.material {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font: inherit;
  color: inherit;
}

.material:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.material .m-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

.material .m-title {
  font-weight: 600;
}

.material .m-desc {
  font-size: 13px;
  color: var(--ink-faint);
}

.empty {
  margin-top: 24px;
  padding: 48px;
  text-align: center;
  color: var(--ink-faint);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- TCF 资料：列表 ---------- */
.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.tip-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font: inherit;
  color: inherit;
  overflow: hidden;
}

.tip-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, #3b5bdb, #e64980);
}

.tip-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.tip-card-badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 11px;
  border-radius: 999px;
}

.tip-card-title {
  font-family: "Lora", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
}

.tip-card-desc {
  font-size: 13px;
  color: var(--ink-soft);
}

.tip-card-credit {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---------- TCF 资料：详情 ---------- */
.tips-back {
  margin-bottom: 16px;
}

.tip-doc {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 30px 36px;
}

.tip-doc-head {
  text-align: center;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--brand-soft);
}

.tip-doc-title {
  font-family: "Lora", Georgia, serif;
  font-size: 26px;
  margin: 0;
  line-height: 1.3;
}

.tip-credit {
  margin-top: 8px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

/* 工具栏 */
.tip-toolbar {
  position: sticky;
  top: 66px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.voice-seg {
  display: inline-flex;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}

.voice-opt {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-soft);
}

.voice-opt.active {
  background: var(--card);
  color: var(--brand);
  box-shadow: var(--shadow);
}

.primary-btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: filter 0.15s;
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.adminkey-input {
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  width: 150px;
}

.adminkey-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.tip-status {
  font-size: 13px;
  color: var(--ink-faint);
}

.tip-status.warn {
  color: var(--warn);
  font-weight: 600;
}

.tip-status.ok {
  color: var(--ok);
  font-weight: 600;
}

/* 主题与分组 */
.tip-theme {
  margin-top: 30px;
}

.tip-theme-name {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 10px;
  padding: 8px 14px;
  border-left: 4px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 8px 8px 0;
}

.tip-callout {
  font-size: 13px;
  color: #8a6d00;
  background: #fff8e1;
  border: 1px solid #ffe39e;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.tip-section {
  margin: 16px 0;
}

.tip-section-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
}

.tip-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tip-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.15s;
}

.tip-item:hover {
  background: var(--bg-soft);
}

.tip-item.playing {
  background: #fff4f8;
  box-shadow: inset 0 0 0 1px #f7c9da;
}

.play-btn {
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--brand);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
}

.play-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.play-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tip-item.playing .play-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tip-item-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  flex: 1;
}

.tip-label {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 1px 9px;
  border-radius: 999px;
}

.tip-fr {
  font-weight: 600;
  color: var(--ink);
}

.tip-fr.fr-sentence {
  font-family: "Lora", Georgia, serif;
  font-weight: 500;
}

.tip-zh {
  font-size: 14px;
  color: var(--ink-soft);
}

.tip-pattern {
  margin: 12px 0;
  padding: 12px 14px;
  background: linear-gradient(180deg, #f3f6ff, #ffffff);
  border: 1px solid var(--brand-soft);
  border-radius: 12px;
}

.tip-pattern-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 6px;
}

@media (max-width: 640px) {
  .tip-toolbar {
    top: 60px;
  }
  .adminkey-input {
    width: 120px;
  }
  .tip-doc {
    padding: 20px 16px 28px;
  }
}

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(15, 20, 40, 0.55);
  padding: 24px;
}

.modal[hidden] {
  display: none;
}

.modal-box {
  width: min(960px, 100%);
  height: min(88vh, 100%);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.ghost-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

.ghost-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

#pdf-frame {
  flex: 1;
  width: 100%;
  border: 0;
}
