* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  background: #fff;
  color: #333;
}

/* ── Error Page Layout ── */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: #fafafa;
}
.error-box {
  max-width: 600px;
  width: 100%;
  text-align: center;
}

/* ── Spinner ── */
.spinner-wrap { margin-bottom: 24px; }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e0e0e0;
  border-top-color: #999;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto;
}
.spinner.stopped {
  animation: none;
  border-top-color: #e74c3c;
  border-color: #f5c6cb;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Connecting Text ── */
.connecting-text {
  font-size: 14px;
  color: #999;
  margin-bottom: 12px;
}
.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* ── Error Title (phase2) ── */
.error-code {
  font-size: 72px;
  font-weight: 200;
  color: #e0e0e0;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -2px;
}
.error-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
}
.error-desc {
  font-size: 13px;
  color: #888;
  line-height: 1.8;
  margin-bottom: 24px;
}

/* ── Detail Box ── */
.error-detail {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 20px 24px;
  text-align: left;
  font-size: 12px;
  color: #666;
  line-height: 2;
  margin-bottom: 20px;
}
.error-detail code {
  font-family: "Consolas", "Courier New", monospace;
  background: #f5f5f5;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: #e67e22;
}
.error-detail code.code-red {
  color: #e74c3c;
  background: #fdf0ef;
}
.error-detail .detail-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #f2f2f2;
  padding: 4px 0;
}
.error-detail .detail-row:last-child { border-bottom: none; }
.detail-label { color: #999; flex-shrink: 0; width: 100px; }
.detail-value { color: #555; text-align: right; word-break: break-all; }

/* ── Progress Bar ── */
.progress-bar-wrap {
  width: 100%;
  max-width: 360px;
  height: 3px;
  background: #eee;
  border-radius: 2px;
  margin: 16px auto 0;
  overflow: hidden;
}
.progress-bar-inner {
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, #ddd, #bbb, #ddd);
  background-size: 200% 100%;
  border-radius: 2px;
  animation: progressSlide 2s ease-in-out infinite;
}
@keyframes progressSlide {
  0%   { width: 10%; margin-left: 0; }
  50%  { width: 45%; margin-left: 30%; }
  100% { width: 10%; margin-left: 90%; }
}

/* ── Timer ── */
.retry-timer {
  font-size: 12px;
  color: #bbb;
  margin-top: 12px;
}
.retry-timer em {
  font-style: normal;
  color: #999;
  font-variant-numeric: tabular-nums;
}

/* ── Fail actions (phase2) ── */
.fail-actions {
  margin-top: 20px;
  padding: 16px 20px;
  background: #fff8f8;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  text-align: left;
}
.fail-tip {
  font-size: 12px;
  color: #888;
  line-height: 2;
}
.fail-tip em {
  font-style: normal;
  color: #e74c3c;
  font-weight: 600;
}

/* ── Footer ── */
.error-footer {
  margin-top: 40px;
  font-size: 11px;
  color: #ccc;
}
.error-footer span { margin: 0 6px; }

/* ── Stutter fade-in ── */
.fade-stutter {
  opacity: 0;
  animation: fadeStutter .8s .1s forwards;
}
@keyframes fadeStutter {
  0%   { opacity: 0; }
  15%  { opacity: .35; }
  30%  { opacity: .1; }
  55%  { opacity: .55; }
  70%  { opacity: .3; }
  85%  { opacity: .8; }
  100% { opacity: 1; }
}

/* ── Phase2 hidden ── */
.phase2-hidden {
  display: none;
}

@media (max-width: 480px) {
  .error-code { font-size: 52px; }
  .error-title { font-size: 16px; }
  .error-detail { padding: 14px 16px; }
  .detail-row { flex-direction: column; }
  .detail-value { text-align: left; }
  .fail-actions { padding: 12px 14px; }
}
