:root {
  --paper: #fbf6ea;
  --paper-deep: #f2e2c3;
  --ink: #22302d;
  --muted: #65716f;
  --line: #dbcba9;
  --leaf: #2f7d73;
  --leaf-dark: #225e58;
  --coral: #e85d75;
  --sun: #f6a04d;
  --sky: #6b7fd7;
  --mint: #dff3dc;
  --white: #fffdfa;
  --shadow: 0 14px 32px rgba(65, 45, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(47, 125, 115, 0.08) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(0deg, rgba(232, 93, 117, 0.07) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--paper);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  color: var(--white);
  background: var(--leaf);
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--leaf-dark);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--leaf-dark);
}

button.secondary {
  color: var(--ink);
  background: var(--paper-deep);
  box-shadow: 0 4px 0 #cdbb98;
}

button.warn {
  background: var(--coral);
  box-shadow: 0 4px 0 #b94158;
}

button.sun {
  color: var(--ink);
  background: #ffd166;
  box-shadow: 0 4px 0 #c58b19;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(14px, 3vw, 34px);
  background: rgba(251, 246, 234, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

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

.brand img {
  width: 56px;
  height: 42px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(360px, 1fr) minmax(280px, 360px);
  gap: 18px;
  padding: 20px clamp(14px, 3vw, 34px) 34px;
  align-items: start;
}

.pane {
  display: grid;
  gap: 14px;
}

.tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.88);
  box-shadow: var(--shadow);
  padding: 16px;
}

.tool h2,
.tool h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.stack {
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.inline-field button {
  min-width: 76px;
}

.row > * {
  min-width: 0;
}

.row .grow {
  flex: 1;
}

.segment-list,
.kid-list,
.rank-list,
.honor-list,
.gift-list {
  display: grid;
  gap: 8px;
}

.segment {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.segment.done {
  opacity: 0.64;
  background: #f4ecd9;
}

.segment .num,
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--mint);
  color: var(--leaf-dark);
  font-weight: 800;
}

.segment p {
  margin: 0;
  line-height: 1.75;
}

.segment-title,
.section-card h4,
.question-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

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

.kid,
.rank,
.honor,
.gift,
.section-card,
.question-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 10px 12px;
}

.section-card,
.question-card {
  display: grid;
  align-items: start;
}

.section-card label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

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

.section-body {
  max-height: 112px;
  overflow: auto;
  white-space: pre-wrap;
}

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

.question-actions button {
  padding: 7px 9px;
  box-shadow: none;
}

.kid.inactive {
  opacity: 0.48;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.tabs button {
  padding: 8px 6px;
  color: var(--ink);
  background: var(--paper-deep);
  box-shadow: none;
}

.tabs button.active {
  color: var(--white);
  background: var(--leaf);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(34, 48, 45, 0.3);
}

.login-screen.show {
  display: grid;
}

.login-box {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 24px;
}

.display-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.display-main {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(270px, 0.8fr);
  gap: clamp(14px, 3vw, 28px);
  padding: clamp(14px, 3vw, 34px);
}

.stage {
  min-height: 54vh;
  display: grid;
  align-content: center;
  gap: 18px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: clamp(18px, 4vw, 46px);
  box-shadow: var(--shadow);
}

.reader-label {
  color: var(--coral);
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 800;
}

.reader-name {
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(42px, 8vw, 96px);
  line-height: 0.98;
}

.reading-text {
  font-size: clamp(24px, 4vw, 48px);
  line-height: 1.55;
  white-space: pre-wrap;
}

.next-line,
.progress-line {
  color: var(--muted);
  font-size: clamp(16px, 2.2vw, 24px);
}

.progress-bar {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--paper-deep);
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--leaf), var(--sun), var(--coral));
}

.side-stage {
  display: grid;
  gap: 14px;
  align-content: start;
}

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

.gift-toast {
  position: fixed;
  left: 50%;
  top: 20%;
  z-index: 80;
  min-width: min(520px, 86vw);
  transform: translate(-50%, -20%) scale(0.9);
  border: 3px solid var(--sun);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 24px 60px rgba(34, 48, 45, 0.24);
  padding: 22px 26px;
  text-align: center;
  animation: gift-pop 3.2s ease forwards;
}

.gift-toast strong {
  display: block;
  font-size: clamp(26px, 5vw, 50px);
}

.gift-toast span {
  color: var(--coral);
  font-size: clamp(20px, 3vw, 32px);
  font-weight: 800;
}

@keyframes gift-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.8) rotate(-2deg);
  }
  12%,
  82% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1) rotate(0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -34%) scale(0.95) rotate(2deg);
  }
}

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

  .pane.center {
    grid-column: 1 / -1;
    order: -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-grid,
  .display-main {
    grid-template-columns: 1fr;
  }

  .segment {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .segment .actions {
    grid-column: 1 / -1;
  }

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