:root {
  color: #17231d;
  background: #f4f6f2;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; margin: 0; }
html.dialog-open, html.dialog-open body { overflow: hidden; }

body { min-height: 100vh; background: radial-gradient(circle at 50% 0%, #fff 0, #f4f6f2 48%, #e9eee8 100%); }

button, input, textarea { font: inherit; }

[hidden] { display: none !important; }

.center-view {
  min-height: 100vh;
  padding: 32px 20px;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.center-view h1 { margin: 14px 0 8px; font-size: clamp(28px, 5vw, 44px); letter-spacing: -.04em; }
.center-view > p { margin: 0; color: #617067; line-height: 1.7; }

.pulse-mark, .breath-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #4d7660;
  box-shadow: 0 0 0 0 rgba(77, 118, 96, .34);
  animation: pulse 1.8s ease-out infinite;
}

.breath-circle { width: 86px; height: 86px; background: #dce8df; animation-duration: 3s; }

@keyframes pulse {
  0% { transform: scale(.92); box-shadow: 0 0 0 0 rgba(77, 118, 96, .35); }
  70% { transform: scale(1); box-shadow: 0 0 0 24px rgba(77, 118, 96, 0); }
  100% { transform: scale(.92); box-shadow: 0 0 0 0 rgba(77, 118, 96, 0); }
}

.test-view { height: 100vh; overflow: hidden; background: #fff; }

.test-toolbar {
  height: 58px;
  padding: 8px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid #dce3dd;
  background: rgba(250, 252, 249, .96);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.test-toolbar > div:first-child { display: grid; gap: 2px; min-width: 0; }
.test-toolbar strong { font-size: 14px; }
.test-toolbar span { color: #6d7971; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.test-toolbar button {
  border: 1px solid #9aaca0;
  border-radius: 999px;
  padding: 8px 14px;
  color: #315340;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.test-toolbar button:hover { background: #edf4ef; }

.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.test-toolbar .task-info-button {
  border-color: #b8c9bf;
  color: #355846;
  background: #f8fbf8;
}
.debug-timer-badge {
  display: block;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid #d2b36c;
  border-radius: 999px;
  color: #694d16;
  background: #fff9e9;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}
.debug-float-panel {
  position: fixed;
  top: 74px;
  right: 16px;
  z-index: 100;
  width: 172px;
  padding: 10px;
  display: grid;
  gap: 8px;
  border: 1px solid #d9c589;
  border-radius: 14px;
  background: rgba(255, 250, 235, .96);
  box-shadow: 0 14px 34px rgba(67, 49, 10, .16);
}
.debug-float-panel.dragging {
  user-select: none;
  box-shadow: 0 18px 42px rgba(67, 49, 10, .24);
}
.debug-float-title {
  color: #6b4d10;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: move;
  touch-action: none;
  user-select: none;
}
.debug-float-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.debug-menu { position: relative; }
.debug-float-panel button {
  width: 100%;
  border: 1px solid #c9b275;
  border-radius: 9px;
  padding: 7px 8px;
  color: #6b4d10;
  background: #fffdf4;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.debug-float-panel button:hover { background: #fff4d2; }
.debug-float-panel .debug-menu-button {
  border-color: #d2b36c;
  color: #694d16;
  background: #fff9e9;
}
.debug-float-panel .debug-time-button {
  border-color: #c9b275;
  color: #6b4d10;
  background: #fffdf4;
}
.debug-float-panel .debug-exit-button {
  grid-column: 1 / -1;
  border-color: #b88a2f;
  color: #5f3f00;
  background: #fff3c4;
}
.debug-dropdown {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 100;
  width: 180px;
  padding: 8px;
  border: 1px solid #d8dfda;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(31, 43, 36, .18);
}
.debug-dropdown small { display: block; padding: 4px 7px 8px; color: #7b847e; }
.debug-float-panel .debug-dropdown button { display: block; margin-top: 4px; border: 0; border-radius: 8px; text-align: left; }

#testFrame { display: block; width: 100%; height: calc(100vh - 58px); border: 0; background: #fff; }

.dialog-backdrop {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 42%, rgba(91, 126, 255, .16), transparent 34%),
    rgba(15, 23, 42, .56);
  backdrop-filter: blur(8px) saturate(.9);
  -webkit-backdrop-filter: blur(8px) saturate(.9);
  animation: dialog-fade-in .18s ease-out;
}

.confirm-dialog {
  position: relative;
  width: min(460px, 100%);
  margin: auto;
  padding: 28px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 24px;
  background: rgba(255, 255, 255, .98);
  box-shadow:
    0 32px 80px rgba(15, 23, 42, .28),
    0 8px 24px rgba(15, 23, 42, .12);
  color: #182033;
  animation: dialog-card-in .22s cubic-bezier(.2, .8, .2, 1);
}

.confirm-dialog::before {
  content: "";
  position: absolute;
  top: -90px;
  left: -70px;
  width: 220px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(67, 97, 238, .13), transparent 68%);
  pointer-events: none;
}

.dialog-topline {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dialog-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(135deg, #5b7cfa 0%, #315ce7 100%);
  box-shadow: 0 10px 24px rgba(49, 92, 231, .28);
}
.dialog-icon svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.dialog-close {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: #7a8496;
  background: #f3f5f8;
  cursor: pointer;
  transition: color .16s ease, background .16s ease, transform .16s ease;
}
.dialog-close svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.dialog-close:hover { color: #26324a; background: #e9edf3; transform: rotate(3deg); }

.confirm-dialog .dialog-kicker {
  margin: 0 0 7px;
  color: #4263eb;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
}
.confirm-dialog h2 {
  margin: 0;
  color: #182033;
  font-size: clamp(22px, 4vw, 26px);
  line-height: 1.3;
  letter-spacing: -.02em;
}
.confirm-dialog > p {
  margin: 13px 0 0;
  color: #667085;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-line;
}
.confirm-dialog .dialog-error {
  padding: 10px 12px;
  border-radius: 10px;
  color: #b42318;
  background: #fff1f0;
}

.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; }
.dialog-actions button {
  min-height: 46px;
  border-radius: 13px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}
.dialog-actions button:disabled { opacity: .58; cursor: wait; }
.dialog-cancel { border: 1px solid #d9dee8; color: #344054; background: #fff; }
.dialog-confirm {
  border: 1px solid #315ce7;
  color: #fff;
  background: linear-gradient(135deg, #5275f6 0%, #315ce7 100%);
  box-shadow: 0 9px 20px rgba(49, 92, 231, .22);
}
.dialog-cancel:hover { border-color: #c8cfdb; background: #f7f8fa; transform: translateY(-1px); }
.dialog-confirm:hover { box-shadow: 0 12px 26px rgba(49, 92, 231, .3); transform: translateY(-1px); }
.dialog-actions button:focus-visible,
.dialog-close:focus-visible { outline: 3px solid rgba(66, 99, 235, .24); outline-offset: 2px; }
.timer-dialog.forced .dialog-close,
.timer-dialog.forced #continueExploreButton { display: none; }
.timer-dialog.forced .dialog-actions { grid-template-columns: 1fr; }
.timer-dialog.exit-hint #makeChoiceButton { display: none; }
.timer-dialog.exit-hint .dialog-actions { grid-template-columns: 1fr; }
.task-dialog .task-card { margin-top: 18px; box-shadow: none; }
.task-card-compact { padding: 22px 18px; }
.task-muted { margin-top: 8px !important; color: #4b5563 !important; }
.task-hint {
  margin-top: 14px !important;
  padding-top: 12px;
  border-top: 1px solid rgba(79, 70, 229, .2);
}
.task-dialog-actions { grid-template-columns: 1fr; }

@keyframes dialog-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dialog-card-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.eyebrow { margin: 0 !important; color: #4d7660 !important; font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }

.flow-view {
  min-height: 100dvh;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
}

.flow-card {
  width: min(440px, 100%);
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .06), 0 1px 4px rgba(0, 0, 0, .04);
}

.flow-header,
.launch-progress-row {
  padding: 28px 28px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.launch-progress-row .progress-text,
.flow-header .progress-text {
  min-width: 52px;
  margin-left: 0;
  color: #9ca3af;
  font-size: 13px;
  font-weight: 500;
}

.step-dots { display: flex; flex: 1; gap: 6px; }
.step-dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: #e5e7eb;
  transition: background .25s;
}
.step-dot.active { background: #4f46e5; }
.step-dot.done { background: #818cf8; }

.flow-content {
  min-height: 380px;
  padding: 28px;
  animation: flow-fade-in .24s ease-out;
}

.flow-footer {
  padding: 0 28px 28px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.flow-title,
.step-title {
  margin: 0 0 4px;
  color: #111827;
  font-size: 22px;
  font-weight: 700;
}
.flow-subtitle,
.step-subtitle {
  margin: 0 0 28px;
  color: #9ca3af;
  font-size: 14px;
}
.star { color: #4f46e5; margin-right: 6px; }

.field-group { margin-bottom: 18px; }
.field-label {
  display: block;
  margin-bottom: 8px;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
}
.option-row { display: flex; flex-wrap: wrap; gap: 8px; }
.option-btn {
  flex: 1;
  min-width: 80px;
  padding: 10px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  color: #374151;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: border-color .16s, background .16s, color .16s;
}
.option-btn:hover,
.option-btn.selected {
  border-color: #4f46e5;
  color: #4f46e5;
  background: #eef2ff;
}
.option-btn.selected { font-weight: 600; }

.text-input,
.textarea-input {
  width: 100%;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  color: #111827;
  background: #fff;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.text-input {
  padding: 12px 14px;
  font-size: 15px;
}
.textarea-input {
  min-height: 80px;
  padding: 12px 14px;
  resize: vertical;
  font-size: 14px;
  line-height: 1.6;
}
.text-input:focus,
.textarea-input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .08);
}

.question-card {
  padding: 20px;
  margin-bottom: 18px;
  border: 1.5px solid #f3f4f6;
  border-radius: 12px;
  background: #f9fafb;
}
.question-number {
  margin-bottom: 8px;
  color: #4f46e5;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
}
.question-text {
  margin-bottom: 16px;
  color: #1f2937;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}
.question-hint {
  margin-bottom: 12px;
  color: #9ca3af;
  font-size: 12px;
}
.q-options { display: flex; flex-direction: column; gap: 8px; }
.q-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  color: #374151;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color .16s, background .16s, color .16s;
}
.q-option:hover,
.q-option.selected {
  border-color: #4f46e5;
  color: #4f46e5;
  background: #eef2ff;
}
.q-option:disabled {
  cursor: not-allowed;
  opacity: .62;
}
.q-option.selected { font-weight: 600; }
.radio-dot {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
}
.q-option.selected .radio-dot {
  border: 5px solid #4f46e5;
  background: #fff;
}
.task-card {
  padding: 28px 24px;
  border: 1.5px solid #c7d2fe;
  border-radius: 16px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  text-align: center;
}
.task-icon { margin-bottom: 16px; font-size: 36px; }
.task-heading {
  margin-bottom: 16px;
  color: #111827;
  font-size: 18px;
  font-weight: 700;
}
.task-card p {
  margin: 0 0 6px;
  color: #374151;
  font-size: 15px;
  line-height: 1.7;
}
.task-card strong { color: #4f46e5; }
.exit-hint {
  margin: 16px 0 4px;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}
.text-red { color: #dc2626; font-weight: 700; }

.separator {
  margin: 0;
  border: 0;
  border-top: 1.5px dashed #e5e7eb;
}
.separator-spacer { height: 20px; }
.textarea-wrapper { margin-top: 16px; }
.char-count {
  margin-top: 6px;
  color: #9ca3af;
  font-size: 12px;
  text-align: right;
}
.char-count.insufficient,
.flow-error {
  color: #ef4444;
}
.flow-error {
  margin: -6px 28px 18px;
  font-size: 13px;
}
.completion-page {
  min-height: 340px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.completion-icon { margin-bottom: 20px; font-size: 48px; }
.completion-title {
  margin-bottom: 12px;
  color: #1f2937;
  font-size: 20px;
  font-weight: 700;
}
.completion-desc {
  color: #4b5563;
  font-size: 15px;
  line-height: 1.8;
}
.standalone-completion {
  min-height: auto;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .06), 0 1px 4px rgba(0, 0, 0, .04);
}

.btn {
  padding: 14px 32px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.btn-back {
  border-color: #e5e7eb;
  color: #4b5563;
  background: #fff;
}
.btn-primary {
  flex: 1;
  max-width: 240px;
  color: #fff;
  background: #4f46e5;
}
.btn-primary:disabled {
  color: #9ca3af;
  background: #e5e7eb;
  cursor: not-allowed;
}

@keyframes flow-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.done-mark {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #4d7660;
  font-size: 34px;
}

@media (max-width: 820px) {
  .flow-card { max-width: 440px; }
}

@media (max-width: 520px) {
  .test-toolbar { height: 54px; }
  #testFrame { height: calc(100vh - 54px); }
  .test-toolbar span { display: none; }
  .test-toolbar .debug-timer-badge {
    display: block;
    min-width: 92px;
    padding-inline: 8px;
    font-size: 11px;
  }
  .debug-float-panel {
    top: auto;
    right: 10px;
    bottom: 12px;
    width: min(220px, calc(100vw - 20px));
  }
  .debug-float-panel .debug-time-button { overflow: hidden; text-overflow: ellipsis; }
  .test-toolbar button { padding: 7px 11px; font-size: 12px; }
  .flow-view { padding: 0; align-items: stretch; }
  .flow-card { width: 100%; min-height: 100dvh; border-radius: 0; }
  .flow-content, .flow-header, .flow-footer, .launch-progress-row {
    padding-left: 20px;
    padding-right: 20px;
  }
  .flow-title, .step-title { font-size: 20px; }
  .option-btn, .q-option { font-size: 13px; }
  .dialog-backdrop { padding: 18px; }
  .confirm-dialog { padding: 22px; border-radius: 21px; }
  .dialog-actions { grid-template-columns: 1fr; }
  .dialog-confirm { grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .dialog-backdrop, .confirm-dialog { animation: none; }
}
