:root {
  --ink: #1a2433;
  --muted: #5b6b7c;
  --line: rgba(26, 36, 51, 0.1);
  --bg: #f3f7fb;
  --panel: #ffffff;
  --primary: #2f6fed;
  --danger: #d64545;
  --ok: #1f9d6a;
  --warn: #c98512;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0% 0%, #dceaff 0, transparent 40%),
    radial-gradient(circle at 100% 0%, #dff7ea 0, transparent 36%),
    var(--bg);
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; gap: 8px; align-items: center; font-family: Fredoka, "Noto Sans SC", sans-serif; }
.brand a { color: var(--primary); text-decoration: none; font-weight: 600; }
.link-learn { color: var(--ok); text-decoration: none; font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  min-height: 70vh;
}
.panel.grow { min-width: 0; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.panel-head small { color: var(--muted); font-weight: 400; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
}
.btn:hover { border-color: #9eb6e8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.tiny { padding: 4px 8px; font-size: .85rem; }

.sortable-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fafcfe;
  cursor: grab;
}
.item.active { border-color: var(--primary); background: #eef4ff; }
.item .handle { color: var(--muted); user-select: none; text-align: center; }
.item .meta { min-width: 0; }
.item .meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta span { color: var(--muted); font-size: .82rem; }
.item .ops { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.empty { color: var(--muted); padding: 24px 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1a2433;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 50;
  max-width: 90vw;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 28, .45);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.preview-card { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.icon-btn {
  border: none; background: transparent; font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.preview-body { text-align: center; }
.preview-body img {
  width: 100%;
  max-height: 52vh;
  object-fit: contain;
  background: #eef2f7;
  border-radius: 12px;
}
.preview-body p {
  font-family: Fredoka, "Noto Sans SC", sans-serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 14px 0;
}
.preview-controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.progress {
  height: 10px;
  background: #e8eef6;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0;
}
#uploadBar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #55c2a0);
  transition: width .2s ease;
}
.log {
  max-height: 220px;
  overflow: auto;
  background: #0f1722;
  color: #d7e2f0;
  border-radius: 10px;
  padding: 10px;
  font-size: .8rem;
  white-space: pre-wrap;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .panel { min-height: auto; }
}
