:root {
  --bg: #0c1222;
  --surface: #141d33;
  --card: #1a2642;
  --accent: #3b9eff;
  --accent-dim: #2563a8;
  --text: #e8eef7;
  --muted: #8fa3c4;
  --warn: #f59e0b;
  --ok: #34d399;
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: linear-gradient(160deg, #0a1020 0%, #12203a 50%, #0d1528 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid rgba(59, 158, 255, 0.2);
  background: rgba(12, 18, 34, 0.85);
  backdrop-filter: blur(8px);
}

.brand { display: flex; gap: 1rem; align-items: center; }
.logo { font-size: 2rem; }
.brand h1 { font-size: 1.35rem; font-weight: 600; }
.brand p { color: var(--muted); font-size: 0.85rem; }

.tabs {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 2rem;
  flex-wrap: wrap;
}

.tab {
  background: var(--surface);
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.tab:hover { color: var(--text); border-color: var(--accent-dim); }
.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.panels { max-width: 960px; margin: 0 auto; padding: 0 1.5rem 3rem; }
.panel { display: none; }
.panel.active { display: block; animation: fade 0.25s ease; }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: var(--card);
  border: 1px solid rgba(59, 158, 255, 0.15);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.card h2 { margin-bottom: 0.5rem; font-size: 1.2rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }

label { display: block; margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}

.check { display: flex; align-items: center; gap: 0.5rem; color: var(--text); }
.check input { width: auto; margin: 0; }

.btn {
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  margin-top: 0.5rem;
  margin-right: 0.5rem;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--accent-dim); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.span-2 { grid-column: span 2; }

.row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: 1rem; }
.row label { flex: 1; min-width: 140px; }

.reply, .report {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
  white-space: pre-wrap;
  font-size: 0.92rem;
}

.report { font-family: ui-monospace, monospace; font-size: 0.85rem; max-height: 420px; overflow: auto; }

.hidden { display: none !important; }

.layer-card {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  background: var(--surface);
  border-radius: 0 8px 8px 0;
}

.layer-card h4 { color: var(--accent); margin-bottom: 0.35rem; }

.quiz .q-item {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
}

.score-bar {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(90deg, rgba(59, 158, 255, 0.2), transparent);
  border-radius: 8px;
  border-left: 4px solid var(--accent);
}

.score-bar strong { font-size: 1.2rem; }

.quiz-review {
  margin-top: 1rem;
  max-height: 520px;
  overflow-y: auto;
}

.quiz-review h3 { margin-bottom: 0.75rem; font-size: 1.05rem; }

.review-item {
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid rgba(59, 158, 255, 0.12);
}

.review-item h4 { margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; }

.tag {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.tag.ok { background: rgba(52, 211, 153, 0.2); color: var(--ok); }
.tag.bad { background: rgba(245, 158, 11, 0.2); color: var(--warn); }

.review-item .explain {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(143, 163, 196, 0.3);
  color: var(--muted);
  line-height: 1.65;
}

.loading-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 0.85rem 1.1rem 0.95rem;
  background: rgba(20, 29, 51, 0.97);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 0.92rem;
  width: min(92vw, 440px);
  max-width: min(92vw, 440px);
}

.loading-toast-inner {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.loading-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.loading-progress-wrap {
  height: 6px;
  border-radius: 999px;
  background: rgba(59, 158, 255, 0.15);
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.12s ease-out;
  box-shadow: 0 0 12px rgba(59, 158, 255, 0.45);
}

.loading-elapsed {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(59, 158, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

body.is-loading .btn.primary,
body.is-loading .btn.secondary {
  opacity: 0.65;
  pointer-events: none;
}

.loading-inline {
  margin-top: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.loading-inline .loading-spinner {
  width: 14px;
  height: 14px;
}

.loading-inline-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.loading-inline .loading-progress-wrap {
  height: 4px;
}

.loading-inline .loading-progress-fill {
  box-shadow: none;
}

.loading-progress-wrap.indeterminate {
  position: relative;
}

.loading-progress-indeterminate {
  position: absolute;
  top: 0;
  left: -42%;
  width: 42%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  animation: loading-indeterminate 1.1s ease-in-out infinite;
}

@keyframes loading-indeterminate {
  0% {
    left: -42%;
  }
  100% {
    left: 100%;
  }
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .header { flex-direction: column; align-items: flex-start; gap: 1rem; }
}
