* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f6f9;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.10);
  width: 100%;
  max-width: 560px;
  padding: 36px 32px;
  height: fit-content;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.peer-badge {
  background: #1a73e8;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.peer-badge.b { background: #34a853; }

.card-header h1 {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a2e;
}

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; gap: 0; }

.step {
  display: flex;
  gap: 16px;
  position: relative;
}

.step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 36px;
  bottom: -8px;
  width: 2px;
  background: #e0e0e0;
  transition: background 0.3s;
}

.step.done:not(:last-child)::before { background: #34a853; }
.step.active:not(:last-child)::before { background: #1a73e8; }

.step-left { display: flex; flex-direction: column; align-items: center; }

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e0e0e0;
  color: #888;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s;
  z-index: 1;
}

.step.active .step-num {
  background: #1a73e8;
  color: #fff;
  box-shadow: 0 0 0 4px #d2e3fc;
}

.step.done .step-num {
  background: #34a853;
  color: #fff;
}

.step.done .step-num::after { content: '✓'; }
.step.done .step-num span { display: none; }

.step-body {
  padding-bottom: 28px;
  flex: 1;
}

.step-title {
  font-size: 15px;
  font-weight: 600;
  color: #bbb;
  margin-top: 5px;
  margin-bottom: 12px;
  transition: color 0.3s;
}

.step.active .step-title { color: #1a1a2e; }
.step.done .step-title { color: #34a853; }

.step-content { display: none; }
.step.active .step-content { display: block; }

/* tokenSection sits outside .step-content so it stays visible after step is done */
#tokenSection { display: none; }
.step.done #tokenSection,
.step.active #tokenSection { display: block; }

/* ── Buttons ── */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary { background: #1a73e8; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1557b0; }
.btn-primary:disabled { background: #a8c7fa; cursor: not-allowed; }

.btn-secondary {
  background: #f1f3f4;
  color: #444;
  margin-left: 8px;
}
.btn-secondary:hover { background: #e2e5e8; }

.btn-success { background: #34a853; color: #fff; }
.btn-success:hover { background: #1e8e3e; }

/* ── Inputs ── */
textarea, input[type="text"] {
  width: 100%;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  background: #fafafa;
}

textarea:focus, input[type="text"]:focus { border-color: #1a73e8; background: #fff; }

.output-box {
  background: #f8f9fa;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  word-break: break-all;
  max-height: 100px;
  overflow-y: auto;
  color: #333;
  margin-bottom: 10px;
}

.hint {
  font-size: 12px;
  color: #888;
  margin-bottom: 10px;
  line-height: 1.5;
}

.error-msg {
  display: none;
  background: #fce8e6;
  border: 1px solid #f28b82;
  color: #c5221f;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-top: 10px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Chat ── */
.chat-box {
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  height: 220px;
  overflow-y: auto;
  padding: 12px;
  background: #fafafa;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg {
  max-width: 80%;
  padding: 7px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.msg.me {
  background: #1a73e8;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.msg.them {
  background: #e8f0fe;
  color: #1a1a2e;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input-row input {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
}

.connected-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e6f4ea;
  color: #34a853;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.connected-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34a853;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
