:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --card: #ffffff;
  --line: #e4e7ef;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #4f46e5;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 24px 28px 14px;
  max-width: 1040px;
  margin: 0 auto;
}

h1 { margin: 0; font-size: 24px; }
.hint { margin: 6px 0 8px; color: var(--muted); font-size: 13px; }
code { background: #eceef7; padding: 1px 5px; border-radius: 4px; }

.addr {
  border: 1px dashed #c9ceda;
  background: #fff;
  color: #4b5563;
  font: 12px ui-monospace, Menlo, monospace;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions { display: flex; gap: 8px; flex-shrink: 0; }

button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  min-height: 42px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover { border-color: #c9ceda; }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #4338ca; }
button.primary:disabled { background: #a5b4fc; border-color: #a5b4fc; }

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 28px 40px;
}

.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 4px 10px;
}

.live { display: inline-flex; align-items: center; gap: 6px; }
.live.active { color: #4338ca; font-weight: 600; }
.live.warn { color: #b45309; }

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  flex: none;
  animation: spin .7s linear infinite;
}

.spinner-light { border-color: #fff; border-right-color: transparent; }

@keyframes spin { to { transform: rotate(360deg); } }

.slots { display: flex; flex-direction: column; gap: 12px; }

.slot {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}

.slot-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.slot-index {
  font: 12px ui-monospace, Menlo, monospace;
  color: #9ca3af;
  flex: none;
}

.slot-email {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef0f6; color: var(--muted); flex-shrink: 0; }
.badge.queued { background: #e0e7ff; color: #4338ca; }
.badge.running { background: #e0e7ff; color: #4338ca; }
.badge.running .spinner { width: 10px; height: 10px; border-width: 2px; margin-right: 5px; vertical-align: -1px; }
.badge.success { background: #dcfce7; color: #15803d; }
.badge.failed { background: #fee2e2; color: #b91c1c; }

.slot-input { display: flex; gap: 8px; }
.slot-input[hidden] { display: none; }

.line {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fafbff;
  outline: none;
}

.line:focus { border-color: #a5b4fc; background: #fff; }

.remove {
  min-width: 40px;
  padding: 0 10px;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
}
.remove[hidden] { display: none; }

.stage { color: var(--muted); font-size: 13px; margin: 10px 0 0; min-height: 18px; word-break: break-all; }
.stage .elapsed { margin-left: 8px; color: #9ca3af; font-size: 12px; }
.stage[hidden] { display: none; }

.progress {
  height: 3px;
  background: #eef0f6;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 0;
}
.progress[hidden] { display: none; }

.progress .bar {
  display: block;
  width: 35%;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

.rt-row { display: flex; gap: 8px; margin-top: 10px; }
.rt-row[hidden] { display: none; }

.rt {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: 12px ui-monospace, Menlo, monospace;
  background: #fafbff;
}

.error { color: #b91c1c; font-size: 12px; margin: 8px 0 0; word-break: break-all; }
.error[hidden] { display: none; }

.slot-actions { margin-top: 10px; }
.slot-actions[hidden] { display: none; }
.slot-actions .reset { min-height: 34px; padding: 6px 14px; font-size: 13px; }

.add-slot {
  width: 100%;
  margin-top: 12px;
  border-style: dashed;
  color: var(--muted);
  background: transparent;
}

.foot-hint {
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
  margin: 12px 0 0;
}

@media (max-width: 760px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 18px 16px 10px;
  }

  h1 { font-size: 20px; }
  .actions { width: 100%; }
  .actions button { flex: 1; }

  main { padding: 0 16px 24px; }

  .slot { padding: 12px 14px; }

  .line { font-size: 16px; }

  .rt { font-size: 16px; }
  .copy { min-width: 68px; }
}
