/* ═══════════════════════════════════════════════════════════════
   Components — Chat, Voice, Material, Account
   ═══════════════════════════════════════════════════════════════ */

/* ── Chat Layout ──────────────────────────────────────────── */
.chat-app { display: flex; flex-direction: column; min-height: calc(100vh - var(--nav-h)); }
.chat-app main { flex: 1; display: flex; }

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  padding: 0 24px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 12px;
  flex-shrink: 0;
}

/* ── Mode Toggle ──────────────────────────────────────────── */
.mode-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.mode-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-tertiary);
  transition: all var(--transition);
}
.mode-btn.active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.mode-btn:hover:not(.active):not(:disabled) { color: var(--ink-secondary); }
.mode-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Chat Status ──────────────────────────────────────────── */
.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-quaternary);
  font-weight: 500;
}
.chat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

/* ── Chat Messages ────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding: 16px 0 24px;
  scroll-behavior: smooth;
}

.chat-bubble {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.65;
  animation: bubbleIn 0.3s ease;
}
.chat-bubble.bot {
  background: var(--bg-subtle);
  color: var(--ink);
  border-bottom-left-radius: 6px;
  align-self: flex-start;
}
.chat-bubble.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
  align-self: flex-end;
}

.chat-bubble.bot h3 { font-size: 15px; margin: 10px 0 6px; font-weight: 700; }
.chat-bubble.bot h3:first-child { margin-top: 0; }
.chat-bubble.bot p { margin: 6px 0; color: var(--ink-secondary); }
.chat-bubble.bot ul, .chat-bubble.bot ol { margin: 6px 0 6px 18px; padding: 0; }
.chat-bubble.bot li { margin: 4px 0; }
.chat-bubble.bot strong { font-weight: 700; color: var(--ink); }

@keyframes bubbleIn {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Typing Indicator ─────────────────────────────────────── */
.chat-bubble.typing {
  color: var(--ink-tertiary);
  border-style: dashed;
  border-color: var(--border);
}
.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin-right: 6px;
  vertical-align: middle;
}
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-quaternary);
  animation: typingDot 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-5px); opacity: 1; }
}
.typing-label { font-weight: 600; font-size: 12px; color: var(--ink-quaternary); }

.chat-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  border-radius: 1px;
  transform: translateY(2px);
  animation: cursorBlink 0.6s steps(2) infinite;
}
@keyframes cursorBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* Streaming bot bubble — smooth content reveal */
.chat-bubble.bot p,
.chat-bubble.bot li,
.chat-bubble.bot h3 {
  animation: tokenFadeIn 0.15s ease;
}
@keyframes tokenFadeIn {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

/* ── Chat Input ───────────────────────────────────────────── */
.chat-input-area {
  flex-shrink: 0;
  padding: 12px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 12px);
  background: linear-gradient(to bottom, transparent, var(--bg) 12px);
}
.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 6px 6px 6px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.chat-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.chat-input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 14px;
  outline: none;
  color: var(--ink);
}
.chat-input-wrapper input::placeholder { color: var(--ink-quaternary); }

/* ── Chat Suggestions ─────────────────────────────────────── */
.chat-suggestions { padding: 0 0 8px; }
.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggestion-link {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  color: var(--ink-secondary);
  font-weight: 500;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.suggestion-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ── Mic Button ───────────────────────────────────────────── */
.mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.mic-btn:hover { background: var(--accent-soft); }
.mic-btn.active {
  background: var(--accent);
  animation: micPulse 2s ease-in-out infinite;
}
.mic-btn.active .mic-icon { color: #fff; }
.mic-icon { width: 16px; height: 16px; color: var(--ink-secondary); }
@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.3); }
  70% { box-shadow: 0 0 0 8px rgba(0, 113, 227, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0); }
}

/* ── Send Button ──────────────────────────────────────────── */
.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.send-btn svg { width: 16px; height: 16px; }

/* ── Voice Status ─────────────────────────────────────────── */
.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}
.voice-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-quaternary);
  font-weight: 500;
}
.voice-status.active { color: var(--accent); }
.voice-wave {
  display: inline-block;
  width: 14px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.3;
}
.voice-status.active .voice-wave {
  opacity: 1;
  animation: voicePulse 1.2s ease-in-out infinite;
}
@keyframes voicePulse {
  0% { transform: scaleX(0.6); opacity: 0.4; }
  50% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(0.6); opacity: 0.4; }
}
.chat-voice-note { font-size: 11px; color: var(--ink-quaternary); }

/* ── MaterialWerkstatt ────────────────────────────────────── */
.atelier-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}
.atelier-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
}
.atelier-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.atelier-pill {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
}
.atelier-section-title {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}
.atelier-step {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-tertiary);
  background: var(--bg-subtle);
  margin-top: 16px;
}
.atelier-token-group { margin-top: 8px; }
.atelier-token-title { font-size: 12px; font-weight: 600; color: var(--ink-secondary); margin-bottom: 6px; }

/* ── Chips ────────────────────────────────────────────────── */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.chip.secondary { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.atelier-composition {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--ink-tertiary);
  background: var(--bg-subtle);
}

.atelier-generate {
  margin-top: 16px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: all var(--transition);
}
.atelier-generate:hover { background: var(--accent-hover); }
.atelier-generate:disabled { opacity: 0.4; cursor: not-allowed; }
.atelier-generate-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
}
.atelier-generate-icon svg { width: 14px; height: 14px; }

/* ── Material Preview ─────────────────────────────────────── */
.material-preview {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-subtle);
  min-height: 400px;
}
.material-preview.atelier-preview-empty .material-placeholder {
  background:
    radial-gradient(120% 90% at 20% 10%, rgba(59,130,246,0.08), transparent 55%),
    radial-gradient(100% 80% at 80% 90%, rgba(99,102,241,0.08), transparent 60%),
    linear-gradient(140deg, var(--bg-subtle), var(--bg-wash));
}
.material-progress {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  text-align: center;
  font-size: 12px;
  color: var(--ink-secondary);
  background: rgba(255,255,255,0.82);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}
html[data-theme='dark'] .material-progress {
  background: rgba(17,24,39,0.72);
}
/* ── Generation Animation ────────────────────────────────── */
.material-gen-animation {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 16px;
  padding: 40px 20px;
}
.material-gen-ring {
  width: 80px;
  height: 80px;
  position: relative;
}
.material-gen-ring svg {
  width: 80px;
  height: 80px;
  animation: mat-ring-spin 2s linear infinite;
}
.material-gen-ring circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-dasharray: 180 226;
  stroke-dashoffset: 0;
  stroke-linecap: round;
}
.material-gen-icon {
  margin-top: -60px;
  color: var(--accent);
  animation: mat-icon-pulse 2s ease-in-out infinite;
}
@keyframes mat-ring-spin {
  to { transform: rotate(360deg); }
}
@keyframes mat-icon-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}
.material-gen-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-secondary);
  text-align: center;
  min-height: 20px;
  transition: opacity 0.3s;
}
.material-gen-bar {
  width: 200px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.material-gen-bar-fill {
  height: 100%;
  width: 10%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 1s ease;
}

/* ── Legacy shimmer (keep for other uses) ────────────────── */
.material-placeholder {
  height: 400px;
  background: linear-gradient(135deg, var(--bg-subtle), var(--bg-wash));
}
.material-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Result + Actions ────────────────────────────────────── */
.material-result { position: relative; border-radius: var(--radius-md); overflow: hidden; }
.material-result img { width: 100%; height: auto; object-fit: contain; background: #fff; display: block; cursor: zoom-in; }
.material-actions {
  display: flex;
  gap: 6px;
  padding: 12px 0 0;
  flex-wrap: wrap;
}
.material-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.material-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.material-action-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.material-preview-error {
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 59, 48, 0.15);
  background: rgba(255, 59, 48, 0.05);
  color: var(--error);
  font-size: 13px;
}

/* ── Lightbox ────────────────────────────────────────────── */
.material-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  cursor: zoom-out;
}
.material-lightbox.open { opacity: 1; }
.material-lightbox-inner {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  background: rgba(255,255,255,0.94);
  border-radius: 10px;
}
.material-lightbox-inner img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  background: rgba(255,255,255,0.94);
  border-radius: 8px;
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.25);
}
.material-lightbox-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}
.material-lightbox-close:hover { transform: scale(1.1); }
.material-lightbox-caption {
  margin-top: 8px;
  padding: 2px 2px 0;
  font-size: 12px;
  color: #1f2937;
  text-align: center;
}
.material-lightbox-actions {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.material-lightbox-actions .material-action-btn {
  background: rgba(255,255,255,0.96);
  color: #1f2937;
  border-color: #d7dde8;
}

@media (max-width: 600px) {
  .material-actions { gap: 4px; }
  .material-action-btn span { display: none; }
  .material-action-btn { padding: 8px 10px; }
  .material-lightbox-inner {
    border-radius: 10px;
  }
  .material-lightbox-inner img {
    max-width: 94vw;
    max-height: 94vh;
  }
}

/* ── History ──────────────────────────────────────────────── */
.atelier-history { margin-top: 40px; }
.atelier-history-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.atelier-history-item {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 8px;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}
.atelier-history-item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.atelier-history-item img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; }
.atelier-history-caption { margin-top: 6px; font-size: 11px; color: var(--ink-tertiary); line-height: 1.3; }

/* ── Checkout ─────────────────────────────────────────────── */
.checkout-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}
.checkout-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
}
.checkout-summary .summary-list {
  margin: 16px 0;
  display: grid;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 13px;
}
.checkout-summary .summary-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
  font-weight: 700;
}

/* ── Account Dashboard ────────────────────────────────────── */
.account-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  align-items: start;
}
.account-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
}
.account-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.account-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  transition: all var(--transition);
}
.account-nav a:hover, .account-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.stat-label { font-size: 12px; color: var(--ink-tertiary); font-weight: 500; margin-top: 2px; }
.usage-bar {
  height: 6px;
  background: var(--bg-wash);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
}
.usage-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.usage-bar-fill.warning { background: var(--warning); }
.usage-bar-fill.critical { background: var(--error); }

/* ── Clinical Study ───────────────────────────────────────── */
.study-consent {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 640px;
}
.study-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: rgba(48, 209, 88, 0.08);
  color: #1a7a2e;
  border: 1px solid rgba(48, 209, 88, 0.2);
}
.progress-ring {
  width: 120px;
  height: 120px;
}
.progress-ring circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}
.progress-ring .bg { stroke: var(--bg-wash); }
.progress-ring .fill {
  stroke: var(--accent);
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.6s ease;
}

/* ── Copy / Message Actions ───────────────────────────────── */
.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}
.chat-bubble:hover .msg-actions,
.chat-bubble:focus-within .msg-actions { opacity: 1; }
.msg-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 11px;
  color: var(--ink-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}
.msg-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.msg-action-btn svg { width: 12px; height: 12px; }

/* ── Chat Textarea (replaces input) ──────────────────────── */
.chat-input-wrapper textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 14px;
  outline: none;
  color: var(--ink);
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  min-height: 20px;
}
.chat-input-wrapper textarea,
.chat-input-wrapper textarea::placeholder {
  text-overflow: ellipsis;
}
.chat-input-wrapper textarea::placeholder { color: var(--ink-quaternary); }

/* ── New Chat Button ─────────────────────────────────────── */
.new-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.new-chat-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.new-chat-btn svg { width: 14px; height: 14px; }

/* ── Sidebar Toggle Button ─────────────────────────────── */
.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 5px 8px;
  border-radius: var(--radius-full);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.sidebar-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ── Recent Chats Sidebar ──────────────────────────────── */
.chat-sidebar {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  z-index: 1000;
  transition: right 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
}
.chat-sidebar.open {
  right: 0;
}
.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.sidebar-close-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.sidebar-close-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.sidebar-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--ink-tertiary);
  font-size: 13px;
}
.sidebar-item {
  position: relative;
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 4px;
}
.sidebar-item:hover {
  background: var(--accent-soft);
}
.sidebar-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 24px;
}
.sidebar-item-meta {
  font-size: 11px;
  color: var(--ink-tertiary);
  margin-top: 4px;
}
.sidebar-item-delete {
  position: absolute;
  top: 10px;
  right: 8px;
  background: none;
  border: none;
  color: var(--ink-quaternary);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
}
.sidebar-item:hover .sidebar-item-delete {
  opacity: 1;
}
.sidebar-item-delete:hover {
  color: var(--danger, #e53e3e);
}

@media (max-width: 600px) {
  .chat-sidebar {
    width: 85vw;
    right: -85vw;
  }
}

/* ── Voice Active State Enhancement ──────────────────────── */
.voice-active-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--accent-soft);
  border: 1px solid rgba(41, 151, 255, 0.2);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  animation: voicePulseGlow 2s ease-in-out infinite;
}
.voice-active-indicator.active { display: inline-flex; }
.voice-active-indicator .voice-bars {
  display: flex;
  gap: 2px;
  align-items: center;
  height: 16px;
}
.voice-active-indicator .voice-bars span {
  width: 3px;
  border-radius: 1px;
  background: var(--accent);
  animation: voiceBarAnim 1.2s ease-in-out infinite;
}
.voice-active-indicator .voice-bars span:nth-child(1) { height: 40%; animation-delay: 0s; }
.voice-active-indicator .voice-bars span:nth-child(2) { height: 70%; animation-delay: 0.15s; }
.voice-active-indicator .voice-bars span:nth-child(3) { height: 100%; animation-delay: 0.3s; }
.voice-active-indicator .voice-bars span:nth-child(4) { height: 60%; animation-delay: 0.45s; }
@keyframes voiceBarAnim {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.3); }
}
@keyframes voicePulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(41, 151, 255, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(41, 151, 255, 0); }
}

/* ── Cookie banner ───────────────────────────────────────── */
.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: 0 18px 35px rgba(0,0,0,0.16);
}
.cookie-banner__text { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-secondary); }
.cookie-banner__text strong { color: var(--ink); font-size: 13px; }
.cookie-banner__text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.cookie-banner__actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Hero trust chips (homepage) ─────────────────────────── */
.hero-trust-chips {
  justify-content: center;
  align-items: center;
}
.hero-trust-chips .tag {
  border-color: rgba(41, 151, 255, 0.35);
  background: linear-gradient(180deg, rgba(236, 247, 255, 0.95), rgba(227, 240, 255, 0.92));
  color: #0b4a75;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}
.hero-trust-chips .tag:hover {
  border-color: rgba(0, 113, 227, 0.65);
  background: linear-gradient(180deg, rgba(217, 238, 255, 0.98), rgba(204, 229, 255, 0.95));
  box-shadow: 0 12px 26px rgba(0, 113, 227, 0.20);
}
[data-theme="dark"] .hero-trust-chips .tag {
  border-color: rgba(41, 151, 255, 0.45);
  background: linear-gradient(180deg, rgba(7, 33, 59, 0.92), rgba(8, 45, 81, 0.88));
  color: #8fd0ff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .hero-trust-chips .tag:hover {
  border-color: rgba(80, 175, 255, 0.9);
  background: linear-gradient(180deg, rgba(10, 46, 84, 0.95), rgba(12, 57, 103, 0.92));
  color: #b9e4ff;
}

/* ── Responsive overrides ─────────────────────────────────── */
@media (max-width: 980px) {
  .atelier-grid { grid-template-columns: 1fr; }
  .atelier-history-grid { grid-template-columns: repeat(2, 1fr); }
  .checkout-grid { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
  .account-sidebar { position: static; }
  .account-nav { flex-direction: row; overflow-x: auto; gap: 4px; }
}

@media (max-width: 640px) {
  .cookie-banner {
    left: 10px;
    right: 10px;
    bottom: 10px;
    flex-direction: column;
    align-items: stretch;
  }
  .cookie-banner__actions {
    width: 100%;
    justify-content: stretch;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .cookie-banner__actions .btn {
    width: 100%;
    min-width: 0;
    padding: 8px 6px;
    font-size: 11px;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .chat-header { flex-wrap: wrap; gap: 8px; }
  .chat-container { padding: 0 12px; }
  .chat-bubble { max-width: 92%; padding: 12px 14px; }
  .chat-input-wrapper { padding-left: 14px; }
  .chat-input-wrapper textarea { font-size: 13px; }
  .msg-actions { opacity: 1; }

  .hero-trust-chips {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 6px;
  }
  .hero-trust-chips .tag {
    font-size: 10.5px;
    padding: 6px 8px;
    white-space: nowrap;
    letter-spacing: 0.01em;
  }
}

@media (max-width: 390px) {
  .cookie-banner__actions .btn {
    font-size: 10px;
    padding: 8px 4px;
  }
}
