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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #20243a;
  --border: #2a2d3a;
  --accent: #6366f1;
  --accent-hover: #4f52d9;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --text: #e2e4f0;
  --text-muted: #7c7f9a;
  --error: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --nav-h: 62px;
  --header-h: 58px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
}

/* ── Header ── */
.app-header {
  flex-shrink: 0;
  height: var(--header-h);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.new-conv-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
  min-height: 34px;
}

.new-conv-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.new-conv-btn:active { color: var(--text); border-color: var(--text-muted); }

.feed-divider--new span {
  color: var(--accent);
  font-weight: 600;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, #a5b4fc, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.app-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Body ── */
.app-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Tab panels ── */
.tab-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px 28px;
}

.tab-panel.hidden { display: none; }

/* ── Assistant tab — layout ChatGPT ── */
.tab-chat {
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
}

.input-dock {
  flex-shrink: 0;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* ── Mic button (compact) ── */
.mic-btn {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.mic-btn svg { width: 20px; height: 20px; position: relative; z-index: 1; }
.mic-btn:active { background: var(--surface2); }

.mic-btn.recording {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
  animation: glow-pulse 1.4s ease-in-out infinite;
}

/* ── Chat textarea ── */
.chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 11px 14px;
  resize: none;
  overflow-y: hidden;
  min-height: 44px;
  max-height: 130px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Send button (round) ── */
.send-btn-round {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.send-btn-round svg { width: 18px; height: 18px; }
.send-btn-round:active { transform: scale(0.94); }
.send-btn-round:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Recording status ── */
.status-rec {
  font-size: 0.8rem;
  color: #f87171;
  font-weight: 500;
  text-align: center;
  margin-bottom: 6px;
}

/* ── Inline loading ── */
.loading-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.spinner-sm {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* ── Bottom nav ── */
.bottom-nav {
  flex-shrink: 0;
  display: flex;
  height: var(--nav-h);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.2s;
  padding: 6px;
  -webkit-tap-highlight-color: transparent;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--accent); }

/* ── Recorder ── */
.recorder-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 0 12px;
}

.record-btn {
  position: relative;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.record-btn svg {
  width: 36px;
  height: 36px;
  position: relative;
  z-index: 1;
}

.record-btn:active { transform: scale(0.94); }

.record-btn.recording {
  background: var(--error);
  animation: glow-pulse 1.4s ease-in-out infinite;
}

.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

.recording .pulse-ring::before,
.recording .pulse-ring::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(239, 68, 68, 0.5);
  animation: ring-expand 1.4s ease-out infinite;
}

.recording .pulse-ring::after { animation-delay: 0.7s; }

@keyframes ring-expand {
  0%   { inset: -2px;  opacity: 0.8; }
  100% { inset: -24px; opacity: 0; }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(239,68,68,0.4); }
  50%       { box-shadow: 0 0 0 14px rgba(239,68,68,0); }
}

.status-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  transition: color 0.2s;
}

.status-text.recording { color: #f87171; font-weight: 500; }

/* ── Divider ── */
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 16px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Text input ── */
.text-input-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.text-input-area textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 13px 14px;
  resize: vertical;
  min-height: 76px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.text-input-area textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.send-btn {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s, transform 0.1s;
}

.send-btn svg { width: 16px; height: 16px; }
.send-btn:active { transform: scale(0.97); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Result cards ── */
.result-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px 16px;
}

.user-card { border-left: 3px solid var(--accent); }
.ai-card   { border-left: 3px solid var(--success); }

.card-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.card-label svg { width: 13px; height: 13px; }
.user-card .card-label { color: #818cf8; }
.ai-card   .card-label { color: #4ade80; }

.card p {
  font-size: 0.93rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

.audio-controls { margin-top: 12px; }

audio {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  outline: none;
}

/* ── Loading ── */
.loading-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 36px 0;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loadingText { color: var(--text-muted); font-size: 0.9rem; }

/* ── Error ── */
.error-area {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

#errorText { color: #fca5a5; font-size: 0.9rem; }

.error-area button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  min-height: 44px;
  transition: background 0.2s;
}

/* ── Tasks ── */
.tasks-group { margin-bottom: 12px; }

.tasks-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
  user-select: none;
}

.tasks-group-header:active { background: var(--surface2); }

.tasks-group.open .tasks-group-header {
  border-radius: 14px 14px 0 0;
  border-bottom-color: transparent;
}

.group-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.group-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  color: #fff;
  white-space: nowrap;
}

.group-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.group-progress {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.group-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.tasks-group.open .group-chevron { transform: rotate(180deg); }

.tasks-group-body {
  display: none;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  background: var(--surface);
}

.tasks-group.open .tasks-group-body { display: block; }

.task-category {
  padding: 12px 15px 8px;
  border-bottom: 1px solid var(--border);
}

.task-category:last-child { border-bottom: none; }

.task-category-title {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(42, 45, 58, 0.5);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.task-item:last-child { border-bottom: none; }

.task-checkbox {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  margin-top: 1px;
}

.task-item.checked .task-checkbox {
  background: var(--success);
  border-color: var(--success);
}

.task-checkbox svg {
  width: 13px;
  height: 13px;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}

.task-item.checked .task-checkbox svg { opacity: 1; }

.task-body { flex: 1; min-width: 0; }

.task-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
  transition: color 0.15s;
}

.task-item.checked .task-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.task-dept {
  font-size: 0.7rem;
  color: var(--accent);
  margin-top: 3px;
}

.task-item.checked .task-dept { color: var(--text-muted); }

.task-ref {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
  margin-top: 4px;
  opacity: 0.85;
}

.task-item.checked .task-ref { opacity: 0.5; }

.tasks-group-footer {
  padding: 8px 15px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 17, 23, 0.4);
  border-top: 1px solid var(--border);
}

.reset-period-note {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.reset-btn {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  min-height: 32px;
}

.reset-btn:active { color: var(--text); border-color: var(--text-muted); }

/* ── PIN screen ── */
.pin-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.pin-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: min(340px, 90vw);
}

.pin-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.pin-icon svg { width: 28px; height: 28px; }

.pin-title {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, #a5b4fc, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.pin-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -8px;
}

.pin-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.4rem;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-top: 4px;
}

.pin-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.pin-error {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: -6px;
}

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}

.pin-shake { animation: pin-shake 0.45s ease; }

/* ── Chat feed ── */
.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 8px;
  padding-bottom: 12px;
}

.chat-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feed-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  margin: 4px 0;
}

.feed-divider::before,
.feed-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.response-body {
  font-size: 0.93rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

.msg-actions audio {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  outline: none;
  margin-top: 4px;
}

.play-tts-btn {
  color: var(--accent) !important;
  border-color: rgba(99,102,241,.35) !important;
}

.play-tts-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-time {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
  text-transform: none;
}

/* ── Lembretes ── */
.reminders-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.add-reminder-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: background 0.2s;
}

.add-reminder-btn svg { width: 18px; height: 18px; }
.add-reminder-btn:active { background: var(--accent-hover); }

/* Form */
.reminder-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.r-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.93rem;
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.r-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.r-textarea { resize: vertical; min-height: 68px; line-height: 1.5; }

.r-form-error {
  font-size: 0.8rem;
  color: var(--error);
  min-height: 1em;
}

.r-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.r-btn-cancel {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 8px 16px;
  cursor: pointer;
  min-height: 38px;
  transition: color 0.2s;
}

.r-btn-save {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 20px;
  cursor: pointer;
  min-height: 38px;
  transition: background 0.2s;
}

.r-btn-save:disabled { opacity: 0.45; cursor: not-allowed; }

/* List items */
.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  margin-bottom: 10px;
  transition: opacity 0.2s;
}

.reminder-item.reminder-done { opacity: 0.55; }

.check-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: background 0.15s, border-color 0.15s;
}

.check-btn.checked {
  background: var(--success);
  border-color: var(--success);
}

.check-btn svg { width: 15px; height: 15px; }

.reminder-body { flex: 1; min-width: 0; }

.reminder-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.reminder-title {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.reminder-done .reminder-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.reminder-subject {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 6px;
  white-space: pre-wrap;
}

.reminder-date {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.reminder-date svg { flex-shrink: 0; }

.reminder-del {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
}

.reminder-del:hover { opacity: 1; color: var(--error); }
.reminder-del svg   { width: 18px; height: 18px; }

.reminders-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 40px 0;
}

/* Badges */
.badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pending { background: rgba(99,102,241,.18); color: #a5b4fc; }
.badge-late    { background: rgba(239,68,68,.18);  color: #fca5a5; }
.badge-today   { background: rgba(245,158,11,.18); color: #fcd34d; }
.badge-done    { background: rgba(34,197,94,.15);  color: #4ade80; }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Card de pesquisa ── */
.research-card {
  border-left: 3px solid var(--warning) !important;
}

.research-card .card-label {
  color: var(--warning);
}

.research-card .card-label svg {
  fill: var(--warning);
}

/* ── Header actions ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.icon-btn:hover { color: var(--text); background: var(--surface2); }
.icon-btn svg { width: 18px; height: 18px; display: block; }

/* ── Barra de ações da resposta ── */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.msg-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
  white-space: nowrap;
}

.msg-actions button:hover {
  color: var(--text);
  background: var(--border);
}

.copy-wa-btn:hover  { border-color: #25d366 !important; color: #25d366 !important; }
.copy-wa-btn.copy-ok { border-color: var(--success); color: var(--success); }
.del-msg-btn:hover  { border-color: var(--error) !important; color: var(--error) !important; }

/* ── Painel de histórico ── */
.history-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  max-width: 680px;
  margin: 0 auto;
}

.history-panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.history-panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.close-hist-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.close-hist-btn:hover { color: var(--text); }
.close-hist-btn svg   { width: 22px; height: 22px; display: block; }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.hist-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.hist-item:hover { border-color: var(--accent); }

.hist-item-body {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 14px 4px 14px 14px;
}

.hist-item-body.hist-active .hist-title { color: var(--accent); }

.hist-title {
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.hist-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.hist-del-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 10px;
  opacity: 0.4;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: opacity 0.2s, color 0.2s;
}

.hist-del-btn:hover { opacity: 1; color: var(--error); }
.hist-del-btn svg   { width: 18px; height: 18px; display: block; }

.hist-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 48px 0;
}

/* ══════════════════════════════════════════════════════
   ESTUDO A SENTINELA
   ══════════════════════════════════════════════════════ */

.tab-study {
  padding: 0;
}

/* ── Input area ── */
.study-input-area {
  padding: 24px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.study-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 8px 0 4px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

.study-intro-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.5;
}

.study-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 14px;
  resize: vertical;
  min-height: 180px;
  height: 180px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.study-textarea::placeholder { color: var(--text-muted); }

.study-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.study-start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.02em;
}

.study-start-btn:active { transform: scale(0.98); background: var(--accent-hover); }

/* ── Feed wrap ── */
.study-feed-wrap {
  display: flex;
  flex-direction: column;
}

.study-feed-hdr {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.study-feed-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #a78bfa;
  letter-spacing: 0.04em;
}

.study-new-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
  cursor: pointer;
  min-height: 32px;
  transition: color 0.2s;
}

.study-new-btn:active { color: var(--text); }

.study-feed {
  padding: 14px 12px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ── Study card ── */
.study-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid #7c3aed;
  border-radius: 16px;
  overflow: hidden;
}

.study-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #a78bfa;
  padding: 10px 16px 6px;
}

/* ── Accordion sections ── */
.study-sec {
  border-top: 1px solid var(--border);
}

.study-sec:first-of-type { border-top: none; }

.study-sec-hdr {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.study-sec-hdr:active { background: var(--surface2); }

.study-ico {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
}

.study-lbl {
  flex: 1;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  transition: color 0.15s;
}

.study-sec-hdr.open .study-lbl { color: var(--text); }

.study-arr {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.22s;
}

.study-sec-hdr.open .study-arr { transform: rotate(180deg); }

.study-sec-body {
  padding: 2px 16px 14px;
}

/* Content line types */
.sl { font-size: 0.9rem; line-height: 1.75; color: var(--text); margin: 3px 0; }
.sb { font-size: 0.88rem; line-height: 1.7; color: var(--text); margin: 6px 0; padding-left: 4px; }
.sv { font-size: 0.85rem; line-height: 1.6; color: #f59e0b; font-weight: 600; margin: 10px 0 4px; }
.sh { font-size: 0.85rem; line-height: 1.6; color: #a78bfa; font-weight: 600; margin: 8px 0 4px; }
.sg { height: 6px; }

/* ── Next preview ── */
.study-preview {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.study-preview-lbl {
  font-weight: 600;
  color: var(--accent);
  margin-right: 4px;
}

/* ── Card actions ── */
.study-acts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 11px 14px 13px;
  border-top: 1px solid var(--border);
  background: rgba(124, 58, 237, 0.04);
}

.study-next-btn {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 42px;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.study-next-btn:active { transform: scale(0.97); }
.study-next-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.study-arrow { margin-left: 4px; }

.study-fin {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--success);
  flex: 1;
}

.study-reset-lnk {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 8px 13px;
  cursor: pointer;
  min-height: 36px;
  transition: color 0.2s;
}

.study-reset-lnk:active { color: var(--text); }

/* ── Loading ── */
.study-load {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.study-dots {
  display: flex;
  gap: 7px;
}

.study-dots span {
  width: 9px;
  height: 9px;
  background: #7c3aed;
  border-radius: 50%;
  animation: study-dot 1.2s ease-in-out infinite;
}

.study-dots span:nth-child(2) { animation-delay: 0.2s; }
.study-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes study-dot {
  0%, 80%, 100% { transform: scale(0.55); opacity: 0.35; }
  40%            { transform: scale(1);   opacity: 1;   }
}

/* ── Error ── */
.study-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  color: #fca5a5;
  font-size: 0.88rem;
}

/* ── Desktop ── */
@media (min-width: 600px) {
  .app-header { padding: 0 24px; height: 64px; }
  .app-header h1 { font-size: 1.5rem; }
  .tab-panel { padding: 28px 24px 32px; }
  .recorder-area { padding: 28px 0 16px; }
  .record-btn { width: 96px; height: 96px; }
  .record-btn svg { width: 40px; height: 40px; }
  .nav-item { font-size: 0.78rem; gap: 4px; }
  .nav-item svg { width: 24px; height: 24px; }
}
