:root {
  --cream: #fff7ec;
  --cream-deep: #f7e9d3;
  --paper: #fffdf8;
  --cocoa: #6a4a35;
  --cocoa-soft: #8f6a50;
  --honey: #f7c86b;
  --honey-deep: #efb44b;
  --rose-milk: #f7d8cf;
  --mint-milk: #d9efdf;
  --blue-milk: #d9e8f4;
  --line: #d7bfa5;
  --shadow: rgba(106, 74, 53, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--cocoa);
  font-family: "Hannotate SC", "Chalkboard SE", "PingFang SC", "Microsoft YaHei",
    sans-serif;
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 10% 15%, rgba(255, 255, 255, 0.8) 0 30px, transparent 31px),
    radial-gradient(circle at 85% 10%, rgba(247, 200, 107, 0.22) 0 60px, transparent 61px),
    radial-gradient(circle at 20% 85%, rgba(247, 216, 207, 0.38) 0 70px, transparent 71px),
    linear-gradient(180deg, #fff9f0 0%, #f7ebdb 100%);
  min-height: 100vh;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 16px 52px;
}

header {
  margin-bottom: 20px;
  background: linear-gradient(145deg, #fff6e8, #fff2df);
  border: 2px solid var(--line);
  border-radius: 24px;
  padding: 18px 20px;
  box-shadow: 0 10px 24px var(--shadow);
}

h1 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.25;
  letter-spacing: 0.5px;
}

.title-with-avatar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-avatar {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #fffdf9;
  outline: 2px solid #b78664;
  box-shadow:
    0 5px 0 rgba(183, 134, 100, 0.45),
    0 8px 16px rgba(86, 55, 35, 0.2);
  filter: saturate(1.15) contrast(1.05);
  transform: rotate(4deg);
}

h2 {
  margin: 0;
  font-size: 22px;
}

h3 {
  margin: 14px 0 8px;
}

p {
  line-height: 1.65;
  margin: 0;
}

.subtitle-text {
  margin-left: 92px;
}

.side-mascots {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 44px;
  pointer-events: none;
}

.side-left {
  left: max(10px, calc((100vw - 1240px) / 2));
}

.side-right {
  right: max(10px, calc((100vw - 1240px) / 2));
}

.sticker {
  width: clamp(82px, 8.4vw, 126px);
  height: clamp(82px, 8.4vw, 126px);
  object-fit: cover;
  border-radius: 38% 44% 41% 47%;
  border: 6px solid #fffdf9;
  outline: 2px solid #b78664;
  background: #fff;
  box-shadow:
    0 8px 0 rgba(183, 134, 100, 0.45),
    0 12px 24px rgba(86, 55, 35, 0.24);
  transform: rotate(-7deg);
  filter: saturate(1.18) contrast(1.06) brightness(1.04);
}

.side-right .sticker {
  transform: rotate(7deg);
}

.sticker-large {
  width: clamp(96px, 10vw, 146px);
  height: clamp(96px, 10vw, 146px);
}

.card {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 12px 24px var(--shadow);
  animation: pop-in 0.45s ease both;
}

.card:nth-of-type(2) {
  animation-delay: 0.06s;
}

.card:nth-of-type(3) {
  animation-delay: 0.12s;
}

.card:nth-of-type(4) {
  animation-delay: 0.18s;
}

.card::after {
  content: "";
  position: absolute;
  top: -18px;
  right: 20px;
  width: 76px;
  height: 32px;
  border-radius: 999px;
  background: rgba(247, 200, 107, 0.6);
  transform: rotate(-8deg);
}

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

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.switcher-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
}

.counter-pill {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #dfc7a8;
  background: #fff7e8;
  color: #6a4a35;
  font-weight: 700;
}

.question-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tab-chip {
  border-radius: 999px;
  padding: 6px 12px;
  border: 2px solid #b78963;
  background: #fff8ea;
  color: #624531;
  font-weight: 700;
  box-shadow: none;
}

.tab-chip.active {
  background: linear-gradient(180deg, #ffd98f 0%, #f8be62 100%);
  border-color: #9e6d43;
}

button {
  border: 2px solid #7d5a43;
  border-radius: 999px;
  padding: 9px 16px;
  background: linear-gradient(180deg, var(--honey) 0%, var(--honey-deep) 100%);
  color: #4a3528;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 0 #c88f32;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow: 0 6px 0 #c88f32;
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 0 #c88f32;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: 0 3px 0 #c1a98f;
}

textarea {
  margin-top: 10px;
  width: 100%;
  border: 2px solid #d7bf9f;
  border-radius: 18px;
  padding: 12px;
  resize: vertical;
  font-size: 14px;
  line-height: 1.6;
  background: #fffefa;
  color: #5b4332;
}

#questionEditor {
  min-height: 82px;
}

#templateEditor {
  min-height: 170px;
}

textarea:focus {
  outline: none;
  border-color: #cfa06e;
  box-shadow: 0 0 0 4px rgba(247, 200, 107, 0.28);
}

label {
  display: inline-block;
  margin-top: 4px;
  font-weight: 600;
}

.question {
  margin: 10px 0 0;
  font-size: 19px;
  background: linear-gradient(180deg, #fffaf2 0%, #fff4e4 100%);
  border: 2px dashed #d6b58f;
  border-radius: 16px;
  padding: 12px 14px;
}

.status {
  margin: 12px 0 8px;
  color: var(--cocoa-soft);
  background: #fff6e6;
  border: 1px solid #e2cba9;
  border-radius: 999px;
  padding: 6px 12px;
  display: inline-block;
}

.muted {
  color: var(--cocoa-soft);
}

.score-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.score-grid div {
  border: 2px solid #d9c1a8;
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff8ee;
}

.score-grid div:nth-child(2n) {
  background: var(--mint-milk);
}

.score-grid div:nth-child(3n) {
  background: var(--rose-milk);
}

.score-grid div:nth-child(5n) {
  background: var(--blue-milk);
}

.score-grid span {
  color: #5e3f2c;
  font-weight: 700;
}

ul {
  margin: 0;
  padding-left: 20px;
}

li {
  margin-bottom: 4px;
}

.xml-box {
  margin-top: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border: 1px solid #d7bf9f;
  border-radius: 12px;
  background: #fffaf2;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
}

.card details {
  margin-top: 8px;
}

.card summary {
  cursor: pointer;
  font-weight: 600;
  color: #7c5235;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.history-item {
  border: 1px solid #dcc5a7;
  border-radius: 12px;
  padding: 10px;
  background: #fff9ef;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.history-head span {
  color: #86644c;
  font-size: 12px;
}

.credit-note {
  margin-top: 8px;
  color: var(--cocoa-soft);
  font-size: 13px;
  line-height: 1.5;
}

.credit-note a {
  color: #7c5235;
  font-weight: 600;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 640px) {
  .container {
    padding-top: 18px;
  }

  h1 {
    font-size: 28px;
  }

  .title-avatar {
    width: 62px;
    height: 62px;
  }

  .subtitle-text {
    margin-left: 72px;
  }

  h2 {
    font-size: 20px;
  }

  .side-mascots {
    display: none;
  }

  button {
    width: 100%;
  }

  .question-tabs .tab-chip {
    width: auto;
  }
}
