:root {
  --blue: #0866ff;
  --blue-ink: #063f9e;
  --ink: #101828;
  --muted: #667085;
  --line: #dde5f1;
  --soft: #f7f8fb;
  --card: #ffffff;
  --good: #12b76a;
  --bad: #f04438;
  --shadow: 0 18px 48px rgba(16, 24, 40, 0.1);
  --tab-height: 64px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

[hidden] { display: none !important; }

.demo-download-dialog { position: fixed; inset: 0; z-index: 100; display: grid; place-items: end center; padding: 18px; }
.demo-download-backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, .52); backdrop-filter: blur(4px); }
.demo-download-sheet { position: relative; width: min(100%, 480px); padding: 25px; border-radius: 26px; background: #fff; box-shadow: 0 24px 70px rgba(16, 24, 40, .28); animation: demo-sheet-in .22s ease-out; }
.demo-download-icon { display: grid; place-items: center; width: 43px; height: 43px; margin-bottom: 14px; border-radius: 14px; color: #fff; background: var(--blue); font-size: 24px; font-weight: 900; }
.demo-download-sheet .eyebrow { margin-bottom: 8px; }
.demo-download-sheet h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.demo-download-sheet > p:not(.eyebrow) { margin: 10px 0 20px; color: var(--muted); line-height: 1.6; }
.demo-download-actions { display: flex; justify-content: flex-end; gap: 10px; }
.demo-download-actions .plain-button { min-height: 44px; padding: 0 15px; }
.demo-download-actions .primary-button { min-height: 44px; padding: 0 17px; }
@keyframes demo-sheet-in { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

input,
select,
textarea {
  font-size: 16px;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  max-width: 1180px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(var(--tab-height) + env(safe-area-inset-bottom) + 12px);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -14px -14px 14px;
  padding: max(14px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(247, 248, 251, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #6da0ff);
  box-shadow: 0 12px 24px rgba(8, 102, 255, 0.28);
  font-weight: 950;
}

.brand-mark.brand-mark-signal {
  position: relative;
  display: grid;
  place-items: start center;
  overflow: hidden;
  border: 3px solid var(--blue);
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 7px 16px rgba(8, 102, 255, 0.16);
}

.brand-monogram {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
}

.brand-signals {
  position: absolute;
  bottom: 5px;
  display: flex;
  gap: 3px;
}

.brand-signals i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ef3e4f;
}

.brand-signals i:nth-child(2) { background: #f7bd35; }
.brand-signals i:nth-child(3) { background: #45ad61; }

.brand strong {
  display: block;
  font-size: 17px;
  line-height: 1.1;
}

.brand small {
  display: block;
  max-width: 190px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

select {
  min-width: 94px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #243047;
  background: rgba(255, 255, 255, 0.96);
  outline: none;
}

.app-main {
  display: grid;
}

.app-view {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.hero-panel,
.tool-panel,
.detail-card,
.sign-card,
.question-card,
.profile-card,
.settings-list {
  min-width: 0;
  border: 1px solid rgba(221, 229, 241, 0.95);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 14px;
  background:
    radial-gradient(circle at 86% 12%, rgba(8, 102, 255, 0.18), transparent 12rem),
    #fff;
}

.daily-tip-card {
  display: grid;
  gap: 10px;
  min-height: 158px;
  background:
    radial-gradient(circle at 94% 0%, rgba(102, 157, 255, 0.3), transparent 10rem),
    linear-gradient(135deg, #ffffff 10%, #f3f7ff 100%);
}

.daily-tip-header,
.daily-tip-footer,
.daily-tip-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.daily-tip-label {
  color: var(--blue-ink);
  font-size: 12px;
  font-weight: 900;
}

.daily-tip-date,
.daily-tip-footer {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.daily-tip-body {
  justify-content: center;
  min-height: 54px;
}

.daily-tip-body blockquote {
  margin: 0;
  max-width: 31ch;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.28;
  text-align: center;
}

.daily-tip-footer {
  justify-content: center;
  padding-top: 9px;
  border-top: 1px solid rgba(205, 221, 247, 0.85);
}

.daily-tip-footer span:first-child {
  color: var(--blue-ink);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 0 0 12px;
  padding: 5px 11px;
  border: 1px solid #cdddf7;
  border-radius: 999px;
  color: var(--blue-ink);
  background: #edf5ff;
  font-size: 11px;
  font-weight: 900;
}

.hero-panel h1,
.section-heading h2,
.quiz-top h2,
.profile-card h2 {
  margin: 0;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero-panel h1 {
  max-width: 720px;
  font-size: 27px;
  line-height: 1.16;
}

.hero-panel p:not(.eyebrow),
.section-heading p,
.profile-card p {
  margin: 12px 0 0;
  color: #526173;
  font-size: 14px;
  line-height: 1.55;
}

.metric-row,
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 18px;
}

.metric-row span,
.profile-stats span {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid #e2e8f3;
  border-radius: 18px;
  background: #fbfdff;
}

.metric-row strong,
.profile-stats strong {
  font-size: 20px;
  line-height: 1;
}

.metric-row small,
.profile-stats small {
  color: var(--muted);
  font-size: 12px;
}

.tool-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  box-shadow: none;
}

.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.search-box input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  background: #fff;
  font-size: 16px;
}

.plain-button,
.primary-button,
.favorite-button,
.save-chip {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 900;
}

.plain-button,
.save-chip {
  color: var(--blue-ink);
  background: #edf5ff;
}

.primary-button,
.favorite-button.active,
.save-chip.active {
  color: #fff;
  background: var(--blue);
}

.category-row {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 1px 1px 7px;
  scrollbar-width: none;
}

.category-row::-webkit-scrollbar {
  display: none;
}

.category-row button {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: max-content;
  white-space: nowrap;
  border: 1px solid #d7e1ee;
  border-radius: 999px;
  padding: 8px 10px 8px 13px;
  color: #344054;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 850;
}

.category-row button small {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #667085;
  background: #f2f6fc;
  font-size: 13px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.category-row button.active {
  border-color: var(--blue);
  color: var(--blue-ink);
  background: #edf5ff;
}

.category-row button.active small {
  color: #fff;
  background: var(--blue);
}

.featured-sign {
  position: sticky;
  top: calc(max(76px, env(safe-area-inset-top) + 54px));
  z-index: 16;
  min-width: 0;
}

.featured-sign.is-resting {
  position: static;
  z-index: auto;
}

.detail-card {
  position: relative;
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 15px;
  align-items: center;
  padding: 15px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(16, 24, 40, 0.1);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.detail-media {
  display: grid;
  gap: 8px;
}

.favorite-button {
  min-height: 34px;
  padding: 7px 12px;
  color: var(--blue-ink);
  background: #edf5ff;
  font-size: 12px;
}

.detail-image,
.question-visual,
.icon-frame {
  display: grid;
  place-items: center;
  border: 1px solid #e5ebf5;
  background: #fbfdff;
}

.detail-image {
  width: 108px;
  height: 108px;
  border-radius: 22px;
}

.detail-image img {
  max-width: 86px;
  max-height: 86px;
}

.detail-chinese-name {
  margin: 0 0 3px;
  font-size: 19px;
  line-height: 1.18;
}

.detail-meta {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-current-name {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.description {
  margin: 0;
  color: #344054;
  font-size: 14px;
  line-height: 1.58;
}

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

.sign-card {
  display: grid;
  gap: 9px;
  padding: 10px;
  box-shadow: none;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.sign-card.active {
  border-color: #9ec0ff;
}

.card-main {
  display: grid;
  gap: 9px;
  width: 100%;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.icon-frame {
  height: 112px;
  border-radius: 18px;
}

.icon-frame img {
  max-width: 92px;
  max-height: 92px;
}

.sign-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.28;
}

.sign-card p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.save-chip {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.section-heading {
  padding: 4px 2px 2px;
}

.section-heading h2,
.quiz-top h2,
.profile-card h2 {
  font-size: 22px;
  line-height: 1.15;
}

.quiz-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.quiz-score {
  min-width: 82px;
  padding: 9px 11px;
  border: 1px solid #e0e7f2;
  border-radius: 18px;
  background: #fff;
  text-align: right;
}

.quiz-score span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.quiz-score strong {
  font-size: 17px;
}

.quiz-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #dde7f5;
  border-radius: 20px;
  color: #526173;
  background: #fff;
  font-size: 13px;
  font-weight: 900;
}

.quiz-status strong {
  color: var(--ink);
  font-size: 16px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid #d7e1ee;
  border-radius: 999px;
  background: #fff;
}

.mode-switch button {
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 9px 10px;
  color: #526173;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.mode-switch button.active {
  color: #fff;
  background: var(--blue);
}

.question-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.question-visual {
  min-height: 156px;
  border-radius: 20px;
  background: #fff;
}

.question-visual img {
  max-width: 138px;
  max-height: 138px;
}

.question-text {
  margin: 0;
  font-size: 18px;
  line-height: 1.38;
  font-weight: 900;
}

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

.option {
  display: grid;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid #dfe7f3;
  border-radius: 16px;
  padding: 11px 12px;
  color: #243047;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 760;
}

.option.with-icon {
  grid-template-columns: 48px 1fr;
}

.option.text-only {
  grid-template-columns: 1fr;
}

.option img {
  max-width: 42px;
  max-height: 42px;
  margin: auto;
}

.option.correct {
  border-color: rgba(18, 183, 106, 0.55);
  background: #ecfdf3;
}

.option.wrong {
  border-color: rgba(240, 68, 56, 0.55);
  background: #fff1f0;
}

.quiz-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.quiz-actions button:disabled {
  cursor: default;
  opacity: 0.48;
}

.result-text {
  min-height: 24px;
  color: var(--muted);
  font-weight: 900;
}

.result-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: end center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(12px);
}

.result-sheet[hidden] {
  display: none !important;
}

.result-card {
  display: grid;
  gap: 14px;
  width: min(100%, 520px);
  padding: 18px;
  border: 1px solid #dde7f5;
  border-radius: 24px;
  background: linear-gradient(145deg, #fff 0%, #eff6ff 100%);
}

.result-card h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.result-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.performance-signal {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid #dce7f5;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
}

.performance-signal > span:last-child {
  display: grid;
  gap: 2px;
}

.performance-signal strong {
  font-size: 16px;
}

.performance-signal small {
  color: var(--muted);
  font-size: 12px;
}

.performance-lights {
  display: grid;
  grid-template-columns: repeat(3, 13px);
  gap: 5px;
  padding: 6px;
  border-radius: 12px;
  background: #172033;
}

.performance-lights i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  opacity: 0.25;
}

.performance-lights .red { background: #ef4456; }
.performance-lights .yellow { background: #f4be39; }
.performance-lights .green { background: #47b36a; }
.performance-signal.improve .performance-lights .red,
.performance-signal.good .performance-lights .yellow,
.performance-signal.excellent .performance-lights .green { opacity: 1; }

.result-stats span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #dce7f5;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
}

.result-stats strong {
  font-size: 20px;
}

.result-stats small,
.analysis-list p {
  color: var(--muted);
  font-size: 12px;
}

.analysis-list {
  display: grid;
  gap: 7px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.profile-card {
  display: grid;
  justify-items: start;
  padding: 22px;
}

.settings-list {
  display: grid;
  padding: 4px 16px;
  box-shadow: none;
}

.history-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #dde7f5;
  border-radius: 22px;
  background: #fff;
}

.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-heading strong {
  font-size: 17px;
}

.history-heading small {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--blue-ink);
  background: #edf5ff;
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 9px;
}

.history-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #edf1f7;
  border-radius: 17px;
  background: #fbfdff;
}

.history-item div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.history-item strong {
  font-size: 14px;
}

.history-item small,
.history-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.history-empty {
  padding: 16px;
}

.settings-list > div {
  display: grid;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid #edf1f7;
}

.settings-list > div:last-child {
  border-bottom: 0;
}

.settings-link-row a {
  color: var(--blue-ink);
  font-weight: 800;
  text-decoration: none;
}

.settings-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.empty {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed #cfd9e8;
  border-radius: 20px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 1180px);
  min-height: calc(var(--tab-height) + env(safe-area-inset-bottom));
  padding: 5px 12px calc(5px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(221, 229, 241, 0.95);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 -18px 42px rgba(16, 24, 40, 0.08);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.bottom-tabs a {
  display: grid;
  place-items: center;
  gap: 2px;
  min-width: 0;
  color: #667085;
  text-decoration: none;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 900;
}

.bottom-tabs a.active {
  color: var(--blue);
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 30px;
  border-radius: 999px;
  line-height: 1;
}

.tab-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.25;
}

.bottom-tabs a.active .tab-icon {
  color: #fff;
  background: var(--blue);
}

[dir="rtl"] .brand,
[dir="rtl"] .detail-card,
[dir="rtl"] .card-main,
[dir="rtl"] .option {
  direction: rtl;
}

[dir="rtl"] .detail-card h2 {
  margin: 0 0 3px;
}

@media (min-width: 760px) {
  .app-shell {
    padding-left: 22px;
    padding-right: 22px;
  }

  .app-header {
    margin-left: -22px;
    margin-right: -22px;
    padding-left: 22px;
    padding-right: 22px;
  }

  .hero-panel h1 {
    font-size: 42px;
  }

  #homeView {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
  }

  .hero-panel,
  .tool-panel,
  .category-row,
  .sign-grid {
    grid-column: 1;
  }

  .featured-sign {
    grid-column: 2;
    grid-row: 1 / span 4;
    top: 86px;
  }

  .featured-sign.is-resting {
    position: sticky;
    z-index: 16;
  }

  .detail-card {
    grid-template-columns: 1fr;
  }

  .detail-image {
    width: 100%;
    height: 220px;
  }

  .detail-image img {
    max-width: 178px;
    max-height: 178px;
  }

  .detail-media {
    gap: 10px;
  }

  .sign-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }

  #quizView,
  #profileView {
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
  }

  #favoritesView {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
    max-width: none;
    margin: 0;
  }
}

@media (max-width: 390px) {
  .hero-panel h1 {
    font-size: 28px;
  }

  .tool-panel {
    grid-template-columns: 1fr;
  }

  .detail-card {
    grid-template-columns: 96px 1fr;
  }

  .detail-image {
    width: 96px;
    height: 96px;
  }

  .detail-image img {
    max-width: 78px;
    max-height: 78px;
  }

  .sign-grid {
    gap: 8px;
  }
}
