:root {
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --border: rgba(22, 53, 87, 0.12);
  --text: #122033;
  --muted: #607086;
  --primary: #1d5fd1;
  --primary-strong: #1148a7;
  --success: #1f9d68;
  --success-soft: #dff6eb;
  --danger: #d95a3f;
  --danger-soft: #fde7e1;
  --accent: #0f2b56;
  --shadow: 0 16px 42px rgba(17, 34, 68, 0.14);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(29, 95, 209, 0.18), transparent 32%),
    radial-gradient(circle at bottom right, rgba(31, 157, 104, 0.14), transparent 28%),
    linear-gradient(135deg, #edf3f9 0%, #f7fbff 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(285px, 330px) minmax(0, 1fr);
  gap: 14px;
  height: 100vh;
  padding: 12px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  min-height: 0;
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 14px;
  min-height: 0;
}

.panel-center,
.panel-right {
  padding: 14px;
  min-height: 0;
}

.panel-center {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
}

.panel-right {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 14px;
}

.pool-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}

.brand-block h1 {
  margin: 4px 0;
  font-size: clamp(26px, 2.2vw, 38px);
  line-height: 1.08;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subtle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-head h2,
.pool-header h2 {
  margin: 0;
  font-size: 20px;
}

.auth-card,
.control-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}

.auth-card.logged-in #auth-description,
.auth-card.logged-in #qr-wrap,
.auth-card.logged-in #refresh-qr {
  display: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: #e7edf6;
  color: var(--accent);
}

.status-pill.active {
  background: #dcf6ea;
  color: #0f7a4e;
}

.qr-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 188px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f9fbff 0%, #edf4fc 100%);
  border: 1px dashed rgba(17, 72, 167, 0.18);
}

.qr-code {
  width: 168px;
  height: 168px;
}

.qr-code img,
.qr-code canvas {
  max-width: 100%;
  max-height: 100%;
}

.auth-actions,
.button-stack {
  display: grid;
  gap: 10px;
}

.field-label,
.meta-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(17, 72, 167, 0.18);
  background: #f8fbff;
  color: var(--text);
  font-size: 16px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.meta-item {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 15px;
  background: #f6f9fd;
  border: 1px solid rgba(17, 72, 167, 0.08);
}

.meta-item strong {
  font-size: 17px;
}

.button,
.icon-button,
.move-button,
.history-record {
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background-color 0.18s ease;
  font-family: inherit;
}

.button {
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
}

.button:hover:not(:disabled),
.icon-button:hover,
.move-button:hover,
.history-record:hover {
  transform: translateY(-1px);
}

.button:disabled,
.move-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button.primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fff;
}

.button.secondary,
.move-button {
  background: #eff5fc;
  color: var(--accent);
  border: 1px solid rgba(17, 72, 167, 0.15);
}

.button.success {
  background: linear-gradient(180deg, #28b072 0%, #1f9d68 100%);
  color: #fff;
}

.button.danger {
  background: linear-gradient(180deg, #ea7256 0%, #d95a3f 100%);
  color: #fff;
}

.button.large {
  min-width: 200px;
  min-height: 64px;
  font-size: clamp(22px, 2.2vw, 30px);
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #eef4fc;
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
}

.pool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.count-badge {
  min-width: 50px;
  padding: 6px 11px;
  border-radius: 999px;
  background: #edf3fb;
  color: var(--accent);
  text-align: center;
  font-size: 15px;
  font-weight: 700;
}

.count-badge.success {
  background: var(--success-soft);
  color: var(--success);
}

.count-badge.failure {
  background: var(--danger-soft);
  color: var(--danger);
}

.draw-stage {
  display: grid;
  gap: 8px;
  align-items: center;
  justify-items: center;
  min-height: 140px;
  padding: 16px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(29, 95, 209, 0.1) 0%, rgba(29, 95, 209, 0.03) 100%),
    #ffffff;
  border: 1px solid rgba(17, 72, 167, 0.1);
  overflow: hidden;
}

.draw-stage.drawing .draw-name {
  animation: pulseName 0.22s ease-in-out infinite alternate;
}

.draw-label {
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.draw-name {
  font-size: clamp(36px, 3.5vw, 62px);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-align: center;
}

@keyframes pulseName {
  from {
    transform: scale(0.98);
    opacity: 0.72;
  }
  to {
    transform: scale(1.04);
    opacity: 1;
  }
}

.name-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
  min-height: 0;
}

.name-grid.compact {
  gap: 8px;
}

.name-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 7px 11px;
  border-radius: 13px;
  background: #f7fbff;
  border: 1px solid rgba(17, 72, 167, 0.1);
  font-size: 16px;
  font-weight: 700;
}

.success-card .name-pill {
  background: #f1fbf6;
  border-color: rgba(31, 157, 104, 0.16);
}

.failure-card .name-pill {
  background: #fff6f3;
  border-color: rgba(217, 90, 63, 0.16);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 96px;
  padding: 14px;
  border-radius: 16px;
  background: #f7faff;
  border: 1px dashed rgba(17, 72, 167, 0.12);
  color: var(--muted);
  text-align: center;
}

.modal-backdrop,
.history-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(9, 23, 44, 0.45);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(720px, calc(100vw - 40px));
  padding: 24px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(12, 28, 54, 0.32);
  text-align: center;
}

.action-card {
  width: min(520px, calc(100vw - 40px));
}

.action-title {
  margin: 0;
  font-size: 32px;
}

.action-qr-wrap {
  margin-top: 14px;
}

.modal-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 20px;
  font-weight: 700;
}

.modal-name {
  margin: 0;
  font-size: clamp(56px, 7vw, 92px);
  line-height: 1.08;
}

.modal-result {
  margin: 14px 0 0;
  font-size: 28px;
  font-weight: 800;
}

.modal-result.success {
  color: var(--success);
}

.modal-result.failure {
  color: var(--danger);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
}

.history-panel {
  width: min(1160px, calc(100vw - 40px));
  height: min(84vh, 760px);
  padding: 20px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(12, 28, 54, 0.32);
}

.editor-panel {
  width: min(1240px, calc(100vw - 40px));
}

.history-content {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  height: calc(100% - 52px);
  margin-top: 14px;
}

.history-list,
.history-detail {
  overflow: auto;
  min-height: 0;
}

.history-record {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(17, 72, 167, 0.1);
  background: #f8fbff;
  text-align: left;
}

.history-record + .history-record {
  margin-top: 10px;
}

.history-record.active {
  border-color: rgba(29, 95, 209, 0.26);
  background: rgba(29, 95, 209, 0.08);
}

.history-record h3,
.history-detail h3,
.history-detail h4 {
  margin: 0;
}

.history-record p,
.history-detail p {
  margin: 0;
  color: var(--muted);
}

.history-detail-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(17, 72, 167, 0.1);
  background: #f9fbff;
}

.history-block {
  display: grid;
  gap: 10px;
}

.history-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-name-list .name-pill {
  min-height: 34px;
  font-size: 15px;
}

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

.history-toggle {
  justify-self: start;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  height: calc(100% - 50px);
  margin-top: 14px;
}

.editor-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  padding: 14px;
  border-radius: 18px;
  background: #f8fbff;
  border: 1px solid rgba(17, 72, 167, 0.1);
}

.editor-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  min-height: 0;
}

.editor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(17, 72, 167, 0.08);
}

.editor-item-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-all;
}

.editor-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.move-button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 8px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
}

.hidden {
  display: none !important;
}

@media (max-width: 1360px) {
  .app-shell {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .board {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.1fr) minmax(250px, 0.9fr);
  }

  .panel-right {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .board,
  .panel-right,
  .history-content,
  .editor-grid {
    grid-template-columns: 1fr;
  }
}
