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

:root {
  --bg: #f5f2ee;
  --surface: #ffffff;
  --border: #e0d8d0;
  --text: #2c2826;
  --text-muted: #8a7f78;
  --accent: #8b5e3c;
  --accent-light: #f0e8df;
  --accent-hover: #7a5033;
  --zone-default: #e8e0d8;
  --zone-hover: #d4c8bc;
  --zone-selected: #8b5e3c;
  --zone-selected-stroke: #6b4a2e;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.brand p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.share-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.share-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Body map card */
.body-map-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Image map */
.body-img-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.body-img-wrap img {
  width: 100%;
  max-width: 400px;
  height: auto;
  border-radius: 8px;
  display: block;
  cursor: crosshair;
}

map area {
  cursor: pointer;
}

/* Quick-tap text buttons */
.zone-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
}

.zone-tag {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.zone-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.zone-tag.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Poses section */
.poses-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.poses-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.poses-empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.pose-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.pose-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.pose-card p {
  font-size: 13px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 10px;
}
.pose-breath {
  font-size: 12px;
  color: var(--accent);
  font-style: italic;
  border-top: 1px solid var(--accent-light);
  padding-top: 10px;
}

/* Streaming state */
.pose-card.streaming pre {
  font-family: inherit;
  font-size: 13px;
  white-space: pre-wrap;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}

/* Loading dots */
.poses-loading {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 24px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* API key prompt */
.api-key-prompt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.api-key-prompt p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.api-key-prompt a { color: var(--accent); }
.key-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.key-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: monospace;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}
.key-row input:focus {
  outline: none;
  border-color: var(--accent);
}
.key-row button {
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.key-note {
  font-size: 11px !important;
  margin-bottom: 0 !important;
}

/* History */
.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.history-card h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.history-card h2 span {
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.history-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #f5f0eb;
  font-size: 13px;
  color: var(--text);
}
.history-item:last-child { border-bottom: none; }
.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.history-item .zone-name { flex: 1; }
.history-item .date {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Poses page ──────────────────────────────────────────────────────────── */
.poses-header-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }
.header-zone-label {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}
.share-btn.small {
  padding: 7px 10px;
  font-size: 13px;
}

.poses-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.poses-hero {
  background: var(--accent);
  border-radius: 12px;
  padding: 24px 20px 20px;
  text-align: center;
  color: white;
}
.zone-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}
.poses-hero h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.poses-subhead {
  font-size: 13px;
  opacity: 0.8;
}

/* Demo notice */
.demo-notice {
  background: var(--accent-light);
  border: 1px solid #e0cfc0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.demo-notice a { color: var(--accent); font-weight: 500; }

/* Pose cards on poses page */
.poses-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pose-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  position: relative;
  animation: slideUp 0.25s ease both;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pose-number {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 26px;
  height: 26px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pose-card h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  padding-right: 36px;
}
.pose-card p {
  font-size: 13px;
  color: #5a5250;
  line-height: 1.65;
  margin-bottom: 12px;
}
.pose-breath {
  font-size: 12px;
  color: var(--accent);
  font-style: italic;
  border-top: 1px solid var(--accent-light);
  padding-top: 10px;
}

/* Streaming card */
.pose-card.streaming pre {
  font-family: inherit;
  font-size: 13px;
  white-space: pre-wrap;
  color: var(--text);
  line-height: 1.65;
  margin: 0;
}

/* Loading dots */
.poses-loading {
  display: flex;
  gap: 7px;
  justify-content: center;
  padding: 40px;
}
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%,80%,100% { opacity:0.2; transform:scale(0.8); }
  40%          { opacity:1;   transform:scale(1);   }
}

/* Retry button */
.retry-btn {
  width: 100%;
  padding: 12px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.retry-btn:hover { border-color: var(--accent); color: var(--accent); }

/* API key prompt on poses page */
.api-key-prompt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.api-key-prompt p { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.api-key-prompt a { color: var(--accent); }
.key-row { display: flex; gap: 8px; margin-bottom: 8px; }
.key-row input {
  flex: 1; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: monospace;
  background: var(--bg); color: var(--text); min-width: 0;
}
.key-row input:focus { outline: none; border-color: var(--accent); }
.key-row button {
  padding: 8px 16px; background: var(--accent); color: white;
  border: none; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.key-note { font-size: 11px !important; margin-bottom: 0 !important; }

/* ── Portfolio live-demo additions ─────────────────────────────────────── */
.portfolio-back {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}
.portfolio-back:hover { color: var(--accent); }

.disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* Human check overlay (lives outside #app so re-renders don't destroy the widget) */
#captcha-box {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(44, 40, 38, 0.45);
  padding: 16px;
  z-index: 50;
}
#captcha-box[hidden] { display: none; }
#captcha-box .captcha-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  max-width: 340px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
#captcha-box p { font-size: 13px; color: var(--text-muted); }
#captcha-box button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}
