:root {
  --bg: #f6efe7;
  --card: #ffffff;
  --text: #2f2a26;
  --muted: #776a61;
  --brand: #ec7f4b;
  --brand-2: #2f8b82;
  --line: #eddccd;
  --danger: #bd4f3f;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 15% 0%, #fff7f1 0%, var(--bg) 48%, #efe6de 100%);
  color: var(--text);
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 14px calc(96px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: rgba(246, 239, 231, 0.88);
  border-bottom: 1px solid var(--line);
  padding: 12px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
}

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

.nav button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  min-height: 38px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.nav button.active {
  background: #fff0e7;
  color: #bc5d31;
  border-color: #f2c8b0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 20px rgba(47, 42, 38, 0.05);
}

.card + .card {
  margin-top: 12px;
}

.title {
  font-size: 24px;
  font-weight: 700;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

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

button.primary,
button.secondary,
button.danger {
  border: none;
  border-radius: 12px;
  min-height: 46px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  background: var(--brand);
  color: #fff;
}

button.secondary {
  border: 1px solid #f2c8b0;
  background: #fff5ef;
  color: #ba5f35;
}

button.danger {
  background: #feecea;
  color: var(--danger);
}

button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.stack > * + * {
  margin-top: 10px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.pill.ok {
  color: #1f7b72;
  background: #e6f6f4;
}

.pill.warn {
  color: #915730;
  background: #f9ede4;
}

.feature-title {
  font-size: 18px;
  font-weight: 700;
}

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

.actions > button {
  flex: 1;
  min-width: 120px;
}

.quiz-progress {
  height: 8px;
  background: #f1e7de;
  border-radius: 999px;
  overflow: hidden;
}

.quiz-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #f4a172, var(--brand));
}

.question {
  margin-top: 14px;
  font-size: 20px;
  line-height: 1.6;
}

.options {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.options button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
}

.options button.active {
  border-color: #eea172;
  background: #fff3eb;
  color: #b85d35;
  font-weight: 700;
}

.score-num {
  font-size: 14px;
  font-weight: 700;
}

.score-label {
  font-size: 11px;
  color: #7a6f66;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px dashed #f0e5db;
}

.kv .k {
  color: var(--muted);
}

.error {
  color: var(--danger);
  background: #fff0ee;
  border: 1px solid #f3cbc3;
  border-radius: 10px;
  padding: 10px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #e8d4c5;
  background: #fff;
  border-radius: 10px;
  min-height: 42px;
  padding: 10px;
  font-size: 14px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.list {
  margin: 0;
  padding-left: 18px;
}

.list li + li {
  margin-top: 6px;
}

.badge {
  font-size: 12px;
  border-radius: 8px;
  padding: 2px 8px;
  border: 1px solid transparent;
}

.badge.good { background: #e6f6f4; color: #1b776f; border-color: #c4ebe7; }
.badge.medium { background: #fff6e6; color: #916b24; border-color: #f1ddaa; }
.badge.low { background: #ffeceb; color: #9d3f32; border-color: #f2c1bb; }
.badge.unknown { background: #f2f2f2; color: #666; border-color: #dedede; }

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

.quiz-actions-sticky {
  position: sticky;
  bottom: calc(70px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 8px 20px rgba(47, 42, 38, 0.08);
}

.mobile-tabbar {
  display: none;
}

@media (max-width: 720px) {
  .app {
    padding: 10px 10px calc(104px + env(safe-area-inset-bottom));
  }

  .topbar {
    padding: 10px 4px;
  }

  .brand {
    font-size: 15px;
  }

  .nav {
    display: none;
  }

  .title {
    font-size: 22px;
  }

  .feature-title {
    font-size: 17px;
  }

  .question {
    font-size: 18px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

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

  .split {
    grid-template-columns: 1fr;
  }

  .options {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .options button {
    min-height: 52px;
    flex-direction: row;
    justify-content: space-between;
    padding: 0 14px;
  }

  .score-label {
    font-size: 13px;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .actions {
    flex-direction: column;
  }

  .actions > button {
    width: 100%;
    min-width: 0;
  }

  .quiz-actions-sticky {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(66px + env(safe-area-inset-bottom));
    z-index: 12;
    margin: 0;
  }

  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--line);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 18px rgba(47, 42, 38, 0.08);
  }

  .mobile-tabbar button {
    min-height: 42px;
    border-radius: 10px;
    border: 1px solid #ead5c5;
    background: #fff6ef;
    color: #9a6a4a;
    font-size: 14px;
    font-weight: 600;
  }

  .mobile-tabbar button.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
  }
}
