/* ─────────────────────────────────────────────────────────────────────────
   Bo web — styles mirror the iOS Bo tab.
   Nix palette: primary teal, warm off-white surfaces, subtle borders.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --primary: #0E7A6D;
  --primary-light: #D4EDE8;
  --bg-page: #F6F6F3;
  --surface-neutral: #EFEEE9;
  --surface-elevated: #FFFFFF;
  --border-default: #E5E3DC;
  --border-subtle: #EFEEE9;
  --text-primary: #1F1D1A;
  --text-secondary: #4A4842;
  --text-muted: #8A8880;
  --text-on-dark: #FFFFFF;
  --danger: #B0453A;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;
  --radius-xl: 20px;
  --radius-xxl: 24px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro", sans-serif;
  font-feature-settings: "cv11";
  overscroll-behavior-y: contain;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
}

#app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ── Header ─────────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 16px;
}

.header__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-on-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.header__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ── Onboarding ─────────────────────────────────────────────────────── */

.onboarding {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
}

.onboarding__eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary);
  font-weight: 600;
}

.onboarding__title {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text-primary);
}

.onboarding__subtitle {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}

.onboarding__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.onboarding__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}

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

.onboarding__input,
.onboarding__select {
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-m);
  background: var(--surface-elevated);
  color: var(--text-primary);
  width: 100%;
  transition: border-color 0.15s;
}

.onboarding__input:focus,
.onboarding__select:focus {
  outline: none;
  border-color: var(--primary);
}

.onboarding__cta {
  margin-top: 8px;
  background: var(--primary);
  color: var(--text-on-dark);
  font-family: inherit;
  font-weight: 600;
  font-size: 16px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.onboarding__cta:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Message feed ──────────────────────────────────────────────────── */

.feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.day-divider {
  align-self: center;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: var(--surface-elevated);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}

/* Bo (assistant) bubble — matches iOS BoBubble */
.bubble.assistant {
  background: var(--surface-neutral);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xxl);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble__topline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bubble__play {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: var(--text-on-dark);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.bubble__play[disabled] {
  opacity: 0.6;
}

.bubble__wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
  flex: 1;
  max-width: 120px;
}

.bubble__wave span {
  flex: 1;
  min-width: 2px;
  background: var(--primary);
  border-radius: 1px;
  opacity: 0.55;
}

.bubble__timestamp {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

.bubble__text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.bubble__text strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* User bubble — right-aligned pill */
.bubble.user {
  align-self: flex-end;
  max-width: 85%;
  background: #E9E7E0;
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-xxl);
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* Inline suggestion cards — lesson / card / tool tags */
.reco {
  background: var(--surface-elevated);
  border: 1px solid rgba(14, 122, 109, 0.22);
  border-radius: var(--radius-xxl);
  overflow: hidden;
}

.reco__head {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reco__kind {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 600;
}

.reco__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.reco__body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.reco__divider {
  height: 1px;
  background: rgba(14, 122, 109, 0.18);
}

.reco__action {
  padding: 12px 16px;
  display: flex;
  justify-content: flex-end;
}

.reco__cta {
  background: var(--primary);
  color: var(--text-on-dark);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: none;
}

/* ── Input bar ─────────────────────────────────────────────────────── */

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-page);
}

.input-field {
  flex: 1;
  min-height: 44px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.35;
  color: var(--text-primary);
  background: var(--surface-neutral);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-l);
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
}

.input-field::placeholder {
  color: var(--text-muted);
}

.input-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-on-dark);
  border: none;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.input-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Typing indicator ─────────────────────────────────────────────── */

.typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--surface-neutral);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xxl);
  color: var(--text-muted);
  font-size: 14px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-pulse 1.2s infinite;
}
.typing__dot:nth-child(2) { animation-delay: 0.2s; }
.typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-pulse {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

/* ── Per-message feedback ─────────────────────────────────────────── */

.feedback {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: -4px;
}

.feedback__row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.feedback__btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.feedback__btn:hover {
  color: var(--text-primary);
  background: var(--surface-neutral);
}
.feedback__btn.active {
  color: var(--primary);
  background: var(--primary-light);
  border-color: rgba(14, 122, 109, 0.25);
}

.feedback__submitted {
  font-size: 12px;
  color: var(--primary);
  font-style: italic;
}

.feedback__panel {
  background: var(--surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-l);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.feedback__chip {
  background: var(--surface-neutral);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}
.feedback__chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.feedback__comment {
  resize: vertical;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-s);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  background: var(--surface-elevated);
  color: var(--text-primary);
}
.feedback__comment:focus {
  outline: none;
  border-color: var(--primary);
}

.feedback__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.feedback__submit {
  background: var(--primary);
  color: var(--text-on-dark);
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.feedback__submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.feedback__cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

/* ── Reset link (bottom of chat) ───────────────────────────────────── */

.reset-link {
  align-self: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}
