/* ===== RESET & BASE ===== */
[hidden] { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, system-ui, sans-serif;
  background: #0a0a0a; color: #eee;
  max-width: 390px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  font-size: 16px;
  display: flex; flex-direction: column;
}

/* ===== HEADER ===== */
.header {
  padding: 12px 16px; border-bottom: 1px solid #1a1a1a;
  flex-shrink: 0;
}
.header__row {
  display: flex; justify-content: space-between; align-items: center;
}
.header__left {
  display: flex; align-items: center; gap: 8px;
}
.header__back {
  color: #eee; text-decoration: none; font-size: 22px;
  width: 36px; height: 36px; display: flex;
  align-items: center; justify-content: center;
  border-radius: 8px; -webkit-tap-highlight-color: transparent;
}
.header__back:active { background: #222; }
.header__title {
  font-size: 20px; font-weight: 700;
}
.header__tabs {
  display: flex; gap: 4px;
  background: #111; border-radius: 8px; padding: 2px;
}
.tab {
  background: none; border: none; color: #666;
  font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 6px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s;
}
.tab--active {
  background: #2563eb; color: #fff;
}
.tab:active { opacity: 0.8; }

/* ===== CAPTURE MODE ===== */
.capture-view {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}
.capture-input-area {
  padding: 16px; display: flex; gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.capture-input {
  flex: 1; resize: none; border: 1px solid #333;
  background: #111; color: #eee; border-radius: 12px;
  padding: 12px 16px; font-size: 16px;
  font-family: inherit; line-height: 1.4;
  max-height: 120px; overflow-y: auto;
  outline: none;
}
.capture-input:focus { border-color: #555; }
.capture-input::placeholder { color: #555; }
.capture-save {
  min-width: 60px; height: 44px;
  border: none; border-radius: 10px;
  background: #2563eb; color: #fff;
  font-size: 15px; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.capture-save:disabled {
  opacity: 0.3; cursor: default;
}
.capture-save:active:not(:disabled) { background: #1d4ed8; }

/* Capture list */
.capture-list {
  flex: 1; overflow-y: auto; padding: 0 16px 16px;
  -webkit-overflow-scrolling: touch;
}
.capture-card {
  background: #111; border-radius: 12px;
  padding: 12px 16px; margin-bottom: 8px;
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 8px;
}
.capture-card__text {
  font-size: 15px; line-height: 1.4;
  color: #ddd; flex: 1;
  white-space: pre-wrap; word-break: break-word;
}
.capture-card__time {
  font-size: 12px; color: #555;
  white-space: nowrap; margin-top: 2px;
}
.capture-card__keep-going {
  background: none; border: 1px solid #333;
  border-radius: 8px; color: #888;
  font-size: 12px; padding: 4px 10px;
  cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0; margin-top: 2px;
}
.capture-card__keep-going:active { background: #222; color: #ccc; }

/* Empty state */
.empty-state {
  text-align: center; color: #555; padding: 40px 20px;
  font-size: 14px; line-height: 1.6;
}
.empty-state__hint { color: #666; }

/* ===== COACH MODE ===== */
.coach-view {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}
.messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.bubble {
  max-width: 85%; padding: 12px 16px;
  border-radius: 18px; font-size: 15px;
  line-height: 1.45; word-wrap: break-word;
}
.bubble--user {
  align-self: flex-end;
  background: #2563eb; color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble--assistant {
  align-self: flex-start;
  background: #1a1a1a; color: #ddd;
  border-bottom-left-radius: 4px;
}
.bubble--assistant strong { color: #fff; }
.bubble--loading {
  align-self: flex-start;
  background: #1a1a1a; color: #666;
  border-bottom-left-radius: 4px;
  font-style: italic;
}

/* Markdown in assistant bubbles */
.bubble--assistant p { margin-bottom: 8px; }
.bubble--assistant p:last-child { margin-bottom: 0; }
.bubble--assistant code {
  background: #111; padding: 2px 5px; border-radius: 4px;
  font-size: 13px; font-family: 'SF Mono', 'Consolas', monospace;
}
.bubble--assistant pre {
  background: #111; padding: 10px; border-radius: 8px;
  overflow-x: auto; margin: 8px 0; font-size: 13px;
}
.bubble--assistant pre code { background: none; padding: 0; }
.bubble--assistant ul, .bubble--assistant ol {
  margin: 4px 0 8px 20px;
}
.bubble--assistant li { margin-bottom: 4px; }

/* Offline banner */
.offline-banner {
  background: #332200; color: #ffaa33;
  text-align: center; padding: 8px;
  font-size: 13px; flex-shrink: 0;
}

/* ===== INPUT BAR (Coach) ===== */
.input-bar {
  flex-shrink: 0;
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #1a1a1a;
  background: #0a0a0a;
}
.input-bar__textarea {
  flex: 1; resize: none; border: 1px solid #333;
  background: #111; color: #eee; border-radius: 20px;
  padding: 10px 16px; font-size: 16px;
  font-family: inherit; line-height: 1.4;
  max-height: 120px; overflow-y: auto;
  outline: none;
}
.input-bar__textarea:focus { border-color: #555; }
.input-bar__textarea::placeholder { color: #555; }
.input-bar__send {
  width: 44px; height: 44px; min-width: 44px;
  border: none; border-radius: 50%;
  background: #2563eb; color: #fff;
  font-size: 20px; font-weight: 700;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
.input-bar__send:disabled {
  opacity: 0.3; cursor: default;
}
.input-bar__send:active:not(:disabled) { background: #1d4ed8; }

/* Inline edit */
.capture-card__body { flex: 1; min-width: 0; }
.capture-card__actions {
  display: flex; flex-direction: column; gap: 4px;
  align-items: flex-end; flex-shrink: 0;
}
.capture-card__expand {
  background: none; border: none; color: #666;
  font-size: 16px; padding: 4px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.capture-card__expand:active { color: #aaa; }
.capture-card--editing .capture-card__actions { display: none; }
.capture-card__edit-input {
  width: 100%; resize: none; border: 1px solid #444;
  background: #0a0a0a; color: #eee; border-radius: 8px;
  padding: 8px 12px; font-size: 15px; font-family: inherit;
  line-height: 1.4; max-height: 120px; overflow-y: auto; outline: none;
}
.capture-card__edit-input:focus { border-color: #2563eb; }
.capture-card__edit-controls {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px;
}
.capture-card__edit-cancel {
  background: none; border: 1px solid #333; border-radius: 6px;
  color: #888; font-size: 13px; padding: 4px 12px; cursor: pointer;
}
.capture-card__edit-save {
  background: #2563eb; border: none; border-radius: 6px;
  color: #fff; font-size: 13px; padding: 4px 12px; cursor: pointer;
}

/* Capture modal */
.capture-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.capture-modal__backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.6);
}
.capture-modal__panel {
  position: relative; width: 100%; max-width: 390px;
  background: #111; border-radius: 16px 16px 0 0;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.capture-modal__header {
  display: flex; justify-content: space-between; margin-bottom: 12px;
}
.capture-modal__back {
  background: none; border: none; color: #888;
  font-size: 15px; cursor: pointer; padding: 4px 0;
}
.capture-modal__delete {
  background: none; border: none; color: #c53030;
  font-size: 14px; cursor: pointer; padding: 4px 0;
}
.capture-modal__textarea {
  width: 100%; resize: none; border: 1px solid #333;
  background: #0a0a0a; color: #eee; border-radius: 10px;
  padding: 12px 14px; font-size: 16px; font-family: inherit;
  line-height: 1.4; min-height: 80px; max-height: 200px;
  overflow-y: auto; outline: none;
}
.capture-modal__textarea:focus { border-color: #555; }
.capture-modal__footer {
  display: flex; gap: 8px; margin-top: 12px;
}
.capture-modal__save {
  flex: 1; height: 44px; border: none; border-radius: 10px;
  background: #2563eb; color: #fff; font-size: 15px;
  font-weight: 600; cursor: pointer;
}
.capture-modal__keep-going {
  flex: 1; height: 44px; border: 1px solid #333; border-radius: 10px;
  background: none; color: #7bb8f5; font-size: 15px;
  font-weight: 600; cursor: pointer;
}

/* Conversation list */
.messages--list { padding: 16px; }
.conversation-list__new {
  width: 100%; height: 48px; border: none; border-radius: 10px;
  background: #2563eb; color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; margin-bottom: 16px;
  -webkit-tap-highlight-color: transparent;
}
.conversation-list__new:active { background: #1d4ed8; }
.conversation-list__empty {
  text-align: center; color: #555; padding: 20px; font-size: 14px;
}
.conversation-list__row {
  background: #111; border-radius: 10px; padding: 12px 14px;
  margin-bottom: 8px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.conversation-list__row:active { background: #1a1a1a; }
.conversation-list__row--handoff { border-left: 3px solid #22c55e; }
.conversation-list__preview {
  font-size: 15px; color: #ddd; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conversation-list__meta {
  font-size: 12px; color: #555; margin-top: 4px;
}
/* Coach back button */
.coach-list-back {
  padding: 8px 16px; border-bottom: 1px solid #1a1a1a; flex-shrink: 0;
}
.coach-list-back__btn {
  background: none; border: none; color: #888; font-size: 14px;
  cursor: pointer; padding: 4px 0;
}
.coach-list-back__btn:active { color: #ccc; }

/* ===== SEARCH ===== */
.search-container {
  padding: 12px 16px 0;
  flex-shrink: 0;
}
.search-bar {
  display: flex; align-items: center;
  background: #1a1a1a; border-radius: 10px;
  padding: 10px 14px; gap: 8px;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.search-bar:focus-within {
  border-color: var(--accent, #4a9eff);
}
.search-bar__icon {
  font-size: 14px; opacity: 0.4;
}
.search-bar__input {
  flex: 1; background: none; border: none;
  color: #eee; font-size: 14px;
  outline: none;
}
.search-bar__input::placeholder { color: #666; }
.search-bar__clear {
  background: none; border: none; color: #888;
  font-size: 16px; padding: 4px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.search-chips {
  display: flex; gap: 8px; padding: 8px 0;
}
.search-chip {
  padding: 6px 14px; border-radius: 16px;
  font-size: 12px; background: #1a1a1a;
  color: #888; border: 1px solid transparent;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.search-chip--active {
  background: #1a2a4a; color: var(--accent, #4a9eff);
  border-color: var(--accent, #4a9eff);
}
.search-result-count {
  font-size: 12px; color: #666;
  padding: 0 0 8px;
}
.search-highlight {
  background: rgba(74, 158, 255, 0.2);
  color: #9cc0ff; padding: 1px 2px;
  border-radius: 3px;
}
