:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #16181d;
  --sub: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --user-bubble: #2563eb;
  --user-ink: #ffffff;
  --bot-bubble: #f1f2f5;
  --bot-ink: #16181d;
  --card-line: #d8dce3;
  --warn: #b45309;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.masthead {
  text-align: center;
  padding: 20px 0 8px;
}
.masthead h1 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 4px;
}
.masthead p {
  color: var(--sub);
  font-size: 13px;
  margin: 0;
}

.notice {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 12px;
  border-radius: 10px;
  padding: 8px 12px;
  margin: 12px 0;
  text-align: center;
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--sub);
  font-size: 11px;
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
  font-weight: 600;
}
.chip.done::after { content: " ✓"; opacity: .7; }

.phone {
  background: var(--panel);
  border-radius: 22px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 30px rgba(0,0,0,.08);
  overflow: hidden;
}
.phone-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.phone-head .title { font-weight: 700; font-size: 14px; }
.phone-head .sub { font-size: 11px; color: var(--sub); }

.chat {
  height: 480px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: var(--user-ink);
  border-bottom-right-radius: 4px;
}
.msg.bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  color: var(--bot-ink);
  border-bottom-left-radius: 4px;
}
.msg .link {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: underline;
}
.msg .redo {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--sub);
  text-decoration: underline;
}
.msg.typing {
  align-self: flex-start;
  background: var(--bot-bubble);
  color: var(--sub);
  padding: 10px 14px;
}
.dots span {
  display: inline-block;
  width: 5px; height: 5px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--sub);
  animation: blink 1.2s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.card {
  align-self: flex-start;
  max-width: 92%;
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fafbfe;
}
.card .card-title { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.card .card-line { font-size: 13px; color: var(--ink); margin: 2px 0; }
.card .card-line.warn { color: var(--warn); font-weight: 600; }
.card .card-actions { margin-top: 10px; display: flex; gap: 8px; }
.card button {
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: default;
}
.card .btn-run { background: var(--primary); color: #fff; }
.card .btn-cancel { background: #eceef2; color: var(--ink); }
.card .btn-run.clicked, .card .btn-cancel.clicked {
  outline: 3px solid rgba(37,99,235,.35);
  outline-offset: 1px;
}
.card .card-result { margin-top: 8px; font-size: 12px; color: var(--sub); }

.screenshot-wrap { align-self: flex-start; max-width: 92%; }
.screenshot-wrap .cap { font-size: 11px; color: var(--sub); margin: 6px 2px 4px; }
.screenshot-wrap img {
  width: 100%;
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: zoom-in;
}

.controls {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.controls button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
}
.controls button.primary { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.controls .spacer { flex: 1; }
.controls .step-count { font-size: 11px; color: var(--sub); }

.cta {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.cta a {
  flex: 1;
  text-align: center;
  padding: 13px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}
.cta .primary { background: var(--primary); color: #fff; }
.cta .secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }

.cta-note {
  text-align: center;
  color: var(--sub);
  font-size: 11px;
  margin-top: 8px;
}

.footer-note {
  text-align: center;
  color: var(--sub);
  font-size: 11px;
  margin-top: 14px;
}

.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

@media (max-width: 380px) {
  .wrap { padding: 10px 10px 24px; }
  .chat { height: 420px; }
}
