:root {
  --bg: #f6f8f5;
  --panel: #ffffff;
  --ink: #172126;
  --muted: #65717a;
  --line: #dde5e2;
  --purple: #5a3fd1;
  --teal: #0d9b8c;
  --amber: #d9932c;
  --rose: #c84b6a;
  --good: #16805f;
  --bad: #bc3b47;
  --shadow: 0 18px 50px rgba(23, 33, 38, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(13, 155, 140, 0.08), transparent 38%),
    linear-gradient(300deg, rgba(217, 147, 44, 0.1), transparent 36%),
    var(--bg);
  font-family:
    "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 22px 16px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand strong {
  display: block;
  font-size: 19px;
}

.brand span,
.eyebrow,
.stats span,
.filters span,
.question-meta span,
.queue-head span,
.source-log small {
  color: var(--muted);
  font-size: 12px;
}

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

.nav-item {
  height: 44px;
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.nav-item span {
  text-align: center;
  font-size: 20px;
}

.nav-item.active {
  border-color: rgba(90, 63, 209, 0.24);
  background: rgba(90, 63, 209, 0.1);
  color: var(--purple);
}

.pete-mini {
  position: relative;
  margin-top: auto;
  height: 170px;
  display: grid;
  place-items: center;
}

.pete-mini img {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  object-fit: cover;
  border: 5px solid #fff;
  box-shadow: var(--shadow);
  animation: float 4s ease-in-out infinite;
}

.pulse-ring {
  position: absolute;
  width: 138px;
  height: 138px;
  border: 2px solid rgba(13, 155, 140, 0.3);
  border-radius: 50%;
  animation: pulse 2.8s ease-out infinite;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 20px;
  line-height: 1.5;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span,
.question-meta span,
.queue-head span {
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.workspace {
  display: none;
}

.workspace.active {
  display: block;
}

.filters {
  display: grid;
  grid-template-columns: 150px 210px minmax(180px, 1fr) 42px;
  gap: 10px;
  margin-bottom: 14px;
}

.filters label {
  display: grid;
  gap: 5px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  outline: none;
}

select,
input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 260px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

.icon-btn,
.primary,
.ghost {
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.icon-btn {
  align-self: end;
  background: var(--panel);
  color: var(--teal);
  font-size: 22px;
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.question-panel,
.queue-panel,
.review-card,
.manage-layout > section {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.question-panel {
  min-height: 620px;
  padding: 22px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.options {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: start;
  gap: 10px;
  min-height: 48px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.option b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(90, 63, 209, 0.1);
  color: var(--purple);
}

.option.selected {
  border-color: var(--purple);
  box-shadow: inset 0 0 0 1px rgba(90, 63, 209, 0.34);
}

.option.correct {
  border-color: rgba(22, 128, 95, 0.55);
  background: rgba(22, 128, 95, 0.07);
}

.option.wrong {
  border-color: rgba(188, 59, 71, 0.55);
  background: rgba(188, 59, 71, 0.07);
}

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

.primary {
  min-width: 96px;
  border-color: var(--purple);
  background: var(--purple);
  color: #fff;
}

.ghost {
  min-width: 86px;
  background: #fff;
  color: var(--ink);
}

.explanation {
  margin-top: 16px;
  padding: 14px;
  border-left: 4px solid var(--teal);
  background: rgba(13, 155, 140, 0.08);
  border-radius: 0 8px 8px 0;
  line-height: 1.7;
}

.queue-panel {
  max-height: calc(100vh - 142px);
  overflow: hidden;
}

.queue-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.question-list {
  max-height: calc(100vh - 198px);
  overflow: auto;
  padding: 8px;
}

.question-chip {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.question-chip.active {
  background: rgba(13, 155, 140, 0.1);
}

.question-chip small {
  color: var(--muted);
  white-space: nowrap;
}

.question-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.review-card {
  min-height: 150px;
  padding: 16px;
  display: grid;
  gap: 10px;
  align-content: start;
}

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

.review-card button {
  justify-self: start;
}

.manage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 14px;
}

.manage-layout > section {
  padding: 18px;
}

.source-log {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.source-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.source-row strong {
  display: block;
  margin-bottom: 4px;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.86);
    opacity: 0.65;
  }
  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 12px;
  }

  .nav {
    grid-auto-flow: column;
    margin-left: auto;
  }

  .nav-item {
    width: 48px;
    grid-template-columns: 1fr;
  }

  .nav-item b,
  .pete-mini {
    display: none;
  }

  .quiz-layout,
  .manage-layout,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .queue-panel {
    max-height: none;
  }

  .question-list {
    max-height: 360px;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

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

  .search-box {
    grid-column: 1 / -1;
  }

  .question-panel {
    min-height: auto;
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }
}
