/* ==========================================================================
   FORAGE v2 — Folio Botanica Design System
   Academic Naturalist aesthetic, precision-cut paper
   ========================================================================== */

:root {
  --primary: #894d0d;
  --primary-container: #a76526;
  --on-primary: #ffffff;
  --on-primary-container: #fffbff;
  --secondary: #52652a;
  --secondary-container: #d4eca2;
  --on-secondary-container: #576b2f;
  --surface: #fff9ed;
  --surface-dim: #e2dabf;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #fcf3d8;
  --surface-container: #f7eed2;
  --surface-container-high: #f1e8cd;
  --surface-container-highest: #ebe2c8;
  --on-surface: #1f1c0b;
  --on-surface-variant: #524439;
  --outline: #857467;
  --outline-variant: #d8c3b4;
  --inverse-surface: #35301e;
  --error: #ba1a1a;
  --primary-fixed: #ffdcc2;
  --on-primary-fixed: #1f1c0b;

  --font-headline: 'Newsreader', 'Georgia', serif;
  --font-body: 'Space Grotesk', system-ui, 'Helvetica Neue', sans-serif;
  --font-mono: 'Space Grotesk', monospace;

  --sidebar-w: 0;
  --right-sidebar-w: 0;
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--on-surface);
  background-color: var(--surface);
  background-image: radial-gradient(var(--outline-variant) 0.5px, transparent 0.5px);
  background-size: 24px 24px;
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  overflow-x: hidden;
}

::selection {
  background: var(--primary-fixed);
  color: var(--on-primary-fixed);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: var(--font-body); cursor: pointer; border: none; background: none; }

/* ==========================================================================
   SCROLLBAR
   ========================================================================== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--outline-variant);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover { background: var(--outline); }

/* ==========================================================================
   SPLASH SCREEN
   ========================================================================== */

#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.6s ease;
}

#splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#splash-screen img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  animation: splashFadeIn 0.8s ease both;
}

@keyframes splashFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   APP SHELL
   ========================================================================== */

#app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#app-shell.visible {
  opacity: 1;
}

/* ==========================================================================
   LEFT SIDEBAR (desktop only)
   ========================================================================== */

#left-sidebar {
  display: none;
  width: auto;
  min-width: min-content;
  max-width: var(--sidebar-w);
  background: var(--surface-container-low);
  height: 100vh;
  position: sticky;
  top: 0;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--outline-variant-border, rgba(216, 195, 180, 0.15));
}

.sidebar-icon-box {
  padding: 0;
  margin: 0;
  line-height: 0;
  overflow: hidden;
}

.sidebar-brand-icon {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  object-position: center;
}

.sidebar-brand {
  padding: 10px 16px 12px;
  border-bottom: 1px solid rgba(216, 195, 180, 0.15);
}

.sidebar-brand h1 {
  font-family: var(--font-headline);
  font-size: 24px;
  font-weight: 700;
  color: var(--on-surface);
}

.sidebar-brand .version-label {
  font-size: 11px;
  color: var(--outline);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 500;
  display: block;
}

/* Sidebar nav */
.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 50ms, color 50ms;
  text-decoration: none;
  border-radius: 0;
}

.sidebar-nav-item:hover {
  background: rgba(216, 195, 180, 0.15);
  color: var(--on-surface);
  text-decoration: none;
}

.sidebar-nav-item.active {
  background: var(--surface-container);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-nav-item .material-symbols-outlined {
  font-size: 20px;
}

/* Sidebar classification */
.sidebar-section {
  padding: 12px 20px;
  border-top: 1px solid rgba(216, 195, 180, 0.15);
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--outline);
  margin-bottom: 10px;
}

.sidebar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(216, 195, 180, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-footer .user-info {
  font-size: 12px;
  color: var(--outline);
}

.sidebar-footer .settings-btn {
  color: var(--outline);
  cursor: pointer;
  transition: color 50ms;
}
.sidebar-footer .settings-btn:hover { color: var(--on-surface); }

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */

#main-content {
  flex: 1;
  min-width: 0;
  min-height: 0; /* allow flex child to shrink for overflow scroll */
  display: flex;
  flex-direction: column;
  /* Parchment texture overlay */
  background: linear-gradient(to bottom, rgba(255,249,237,0.9), rgba(255,249,237,0.95));
}

/* Sticky header with frosted glass */
#main-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 12px 20px 8px;
  background: rgba(255, 249, 237, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(216, 195, 180, 0.15);
}

.header-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

#main-header h2 {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  color: var(--on-surface-variant);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

#main-header h2 .material-symbols-outlined {
  font-size: 20px;
}


.search-bar {
  flex: 1;
  min-width: 0;
  position: relative;
}

.search-bar input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 12px 8px 36px;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  background: transparent;
  color: var(--on-surface);
  outline: none;
  transition: border-color 50ms;
}

.search-bar input::placeholder {
  color: var(--outline);
  font-style: italic;
}

.search-bar input:focus {
  border-bottom-color: var(--primary);
}

.search-bar .material-symbols-outlined {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--outline);
}

.header-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
  transition: color 50ms, background 50ms;
}

.header-btn:hover {
  background: rgba(216, 195, 180, 0.2);
  color: var(--on-surface);
}

.header-btn .material-symbols-outlined {
  font-size: 20px;
}

/* Hide-read toggle */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--outline);
  cursor: pointer;
  margin-top: 6px;
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   MASONRY GRID
   ========================================================================== */

#feed-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  min-height: 0; /* critical: allows flex child to shrink and scroll */
}

.masonry-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.masonry-grid .card {
  flex: 1 1 100%;
  min-width: 0;
}

/* ==========================================================================
   CARDS — Specimen field notes
   ========================================================================== */

.card {
  background: var(--surface-container-lowest);
  border: 1px solid rgba(216, 195, 180, 0.4);
  border-radius: 0;
  position: relative;
  cursor: pointer;
  transition: box-shadow 50ms, border-color 50ms;
  box-shadow: 0 2px 32px rgba(31, 28, 11, 0.04);
}

.card:hover {
  box-shadow: 0 4px 32px rgba(31, 28, 11, 0.08);
  border-color: var(--outline-variant);
}

.card.is-read {
  opacity: 0.5;
}

.card.is-read:hover {
  opacity: 0.8;
}

.card.selected {
  border-color: var(--primary);
  box-shadow: 0 4px 32px rgba(137, 77, 13, 0.12);
}

/* Round score badge (brass rivet) */
.card-score {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
}

/* Card thumbnail */
.card-thumb {
  width: 100%;
  background: var(--surface-dim);
}

.card-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  filter: grayscale(100%);
  transition: filter 500ms;
}

.card:hover .card-image {
  filter: grayscale(0%);
}

/* Play button overlay for video cards */
.card-thumb {
  position: relative;
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

.play-overlay .material-symbols-outlined {
  font-size: 48px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 50ms;
}

.card:hover .play-overlay .material-symbols-outlined {
  transform: scale(1.1);
  color: #fff;
}

/* Video embed in article view */
.video-embed {
  margin-bottom: 20px;
  background: var(--surface-dim);
}

/* Card body */
.card-body {
  padding: 14px 16px 12px;
}

/* Source line */
.card-source {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--outline);
  margin-bottom: 6px;
}

.card-source .material-symbols-outlined {
  font-size: 14px;
}

.card-source .time-ago {
  font-weight: 400;
  letter-spacing: 0.3px;
  text-transform: none;
}

/* Card title */
.card-title {
  font-family: var(--font-headline);
  font-style: italic;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--on-surface);
  margin-bottom: 6px;
}

.card-title .kw-highlight,
.card-excerpt .kw-highlight {
  background: rgba(255, 220, 194, 0.5);
  padding: 0 2px;
  font-weight: 600;
}

/* Card excerpt */
.card-excerpt {
  font-size: 14px;
  line-height: 1.6;
  color: var(--on-surface-variant);
  margin-bottom: 8px;
}

/* Summary box in card */
.card-summary {
  border-left: 2px solid var(--secondary);
  background: rgba(235, 226, 200, 0.5);
  padding: 8px 10px;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--on-surface-variant);
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.card-summary .material-symbols-outlined {
  font-size: 14px;
  color: var(--secondary);
  flex-shrink: 0;
  margin-top: 1px;
}

.card-summary-status {
  font-size: 11px;
  color: var(--outline);
  font-style: italic;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-summary-status .pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--secondary);
  border-radius: 50%;
  animation: pulse 1.5s ease infinite;
}

/* Keyword chips in card */
.card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.card-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-top: 6px;
}

.card-chips-row .chip {
  cursor: pointer;
}

.card-bookmark {
  margin-left: auto;
}

.btn-syndicate {
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 0;
  transition: background 50ms;
}

.btn-syndicate:hover {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-refine {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 5px 12px;
  border: 1px solid rgba(216, 195, 180, 0.4);
  color: var(--on-surface-variant);
  transition: border-color 50ms, color 50ms;
}

.btn-refine:hover {
  border-color: var(--outline);
  color: var(--on-surface);
}

.btn-bookmark {
  margin-left: auto;
  color: var(--outline);
  transition: color 50ms;
  display: flex;
  align-items: center;
}

.btn-bookmark:hover {
  color: var(--primary);
}

.btn-bookmark:active {
  transform: scale(1.2);
}

.btn-bookmark .material-symbols-outlined {
  font-size: 18px;
}

/* ==========================================================================
   CHIPS (global)
   ========================================================================== */

.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 0;
  background: rgba(212, 236, 162, 0.3);
  color: var(--on-secondary-container);
  border: 1px solid rgba(82, 101, 42, 0.15);
}

.filter-chip {
  cursor: pointer;
  transition: background 50ms, color 50ms, border-color 50ms;
}

.filter-chip:hover {
  background: rgba(212, 236, 162, 0.5);
  border-color: var(--secondary);
}

.filter-chip.active {
  background: var(--secondary);
  color: #fff;
  border-color: var(--secondary);
}

/* ==========================================================================
   RIGHT SIDEBAR — Intelligence Metrics (xl only)
   ========================================================================== */

#right-sidebar {
  display: none;
  width: var(--right-sidebar-w);
  min-width: var(--right-sidebar-w);
  background: var(--surface-container-low);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  border-left: 1px solid rgba(216, 195, 180, 0.15);
  padding: 24px 20px;
  flex-direction: column;
  gap: 24px;
}

.metrics-section-title {
  font-family: var(--font-headline);
  font-size: 16px;
  font-style: italic;
  font-weight: 400;
  color: var(--on-surface);
  margin-bottom: 14px;
}

/* Algorithm Health */
.metric-bar {
  margin-bottom: 12px;
}

.metric-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--outline);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.metric-bar-track {
  height: 4px;
  background: var(--surface-container-highest);
  border-radius: 0;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  background: var(--primary-container);
  transition: width 50ms;
}

.metric-bar-fill.green { background: var(--secondary); }
.metric-bar-fill.amber { background: var(--primary-container); }

/* Trending Specimens */
.trending-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(216, 195, 180, 0.15);
  font-size: 13px;
  color: var(--on-surface-variant);
}

.trending-item .rank {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--outline);
  min-width: 18px;
}

.trending-item .term {
  flex: 1;
  font-weight: 500;
}

.trending-item .count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--outline);
}

/* Blockquote */
.metrics-quote {
  font-family: var(--font-headline);
  font-style: italic;
  font-size: 14px;
  line-height: 1.5;
  color: var(--on-surface-variant);
  border-left: 2px solid var(--primary-container);
  padding: 10px 14px;
  background: rgba(247, 238, 210, 0.5);
}

.metrics-quote cite {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  font-style: normal;
  color: var(--outline);
  letter-spacing: 0.3px;
}

/* System Status */
.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--outline);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--secondary);
  animation: pulse 2s ease infinite;
}

.status-dot.error { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ==========================================================================
   ARTICLE OVERLAY (specimen examination page)
   ========================================================================== */

#article-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--surface);
  overflow-y: auto;
  display: none;
  animation: overlayIn 0.15s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(255, 249, 237, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(216, 195, 180, 0.15);
}

.overlay-bar .source-label {
  flex: 1;
  font-size: 11px;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.overlay-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--on-surface-variant);
  transition: color 50ms;
}

.overlay-close-btn:hover { color: var(--on-surface); }

.overlay-close-btn .material-symbols-outlined { font-size: 22px; }

.article-view {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 100px;
}

.article-source-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(216, 195, 180, 0.15);
}

.article-source-bar .source-name {
  font-size: 11px;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.article-source-bar .article-time {
  font-size: 12px;
  color: var(--outline);
  margin-left: auto;
}

.article-title {
  font-family: var(--font-headline);
  font-size: 28px;
  font-weight: 600;
  font-style: italic;
  line-height: 1.3;
  color: var(--on-surface);
  margin-bottom: 16px;
}

.article-title .kw-highlight {
  background: rgba(255, 220, 194, 0.4);
  padding: 0 3px;
}

.article-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
}

.article-summary-box {
  border-left: 2px solid var(--secondary);
  background: rgba(235, 226, 200, 0.5);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--on-surface-variant);
}

.article-summary-box .summary-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.article-summary-box .summary-label .material-symbols-outlined {
  font-size: 14px;
}

.article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.action-btn {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 8px 16px;
  border-radius: 0;
  border: 1px solid rgba(216, 195, 180, 0.4);
  color: var(--on-surface-variant);
  background: transparent;
  transition: all 50ms;
}

.action-btn:hover {
  border-color: var(--outline);
  color: var(--on-surface);
}

.action-btn.primary {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-color: var(--primary-container);
}

.action-btn.primary:hover {
  background: var(--primary);
  color: var(--on-primary);
}

.article-body {
  font-size: 16px;
  line-height: 1.8;
  color: var(--on-surface);
}

.article-body p {
  margin-bottom: 1em;
}

.article-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px 0;
  object-fit: contain;
}

.article-body a {
  color: var(--primary);
  text-decoration: underline;
}

.article-body blockquote {
  border-left: 2px solid var(--primary-container);
  margin: 12px 0;
  padding: 8px 16px;
  color: var(--on-surface-variant);
  font-style: italic;
}

.article-body .kw-highlight {
  background: rgba(255, 220, 194, 0.35);
  padding: 0 2px;
}

/* Repost compose */
.repost-compose {
  margin-top: 12px;
  padding: 16px;
  background: var(--surface-container-low);
  border: 1px solid rgba(216, 195, 180, 0.3);
}

.repost-ref {
  font-size: 12px;
  color: var(--outline);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.repost-ref em {
  color: var(--on-surface-variant);
}

.repost-textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  padding: 10px;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  background: transparent;
  color: var(--on-surface);
  outline: none;
  resize: vertical;
  transition: border-color 50ms;
}

.repost-textarea:focus {
  border-bottom-color: var(--primary);
}

.repost-textarea::placeholder {
  color: var(--outline);
  font-style: italic;
}

.article-bottom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid rgba(216, 195, 180, 0.3);
}

.article-original-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--primary);
  border: 1px solid var(--primary-container);
  text-decoration: none;
  transition: all 50ms;
}

.article-original-link:hover {
  background: var(--primary-container);
  color: var(--on-primary-container);
  text-decoration: none;
}

/* ==========================================================================
   LOADER
   ========================================================================== */

.loader {
  text-align: center;
  padding: 32px;
}

.gear-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface-dim);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: 64px 24px;
  font-family: var(--font-headline);
  font-size: 18px;
  font-style: italic;
  color: var(--outline);
}

/* ==========================================================================
   VIEWS: Keywords, Blog, Archive, Settings
   ========================================================================== */

.view-container {
  padding: 24px;
  max-width: 640px;
  margin: 0 auto;
}

.view-container h2 {
  font-family: var(--font-headline);
  font-size: 22px;
  font-style: italic;
  font-weight: 400;
  margin-bottom: 16px;
  color: var(--on-surface);
}

.keyword-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(216, 195, 180, 0.2);
}

.keyword-term {
  font-family: var(--font-headline);
  font-size: 16px;
  flex: 1;
}

.keyword-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--outline);
}

.kw-delete-btn {
  margin-left: 8px;
  color: var(--outline);
  display: flex;
  align-items: center;
  transition: color 50ms;
}

.kw-delete-btn:hover {
  color: var(--error);
}

.kw-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.kw-add-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  background: transparent;
  color: var(--on-surface);
  outline: none;
  transition: border-color 50ms;
}

.kw-add-input::placeholder {
  color: var(--outline);
  font-style: italic;
}

.kw-add-input:focus {
  border-bottom-color: var(--primary);
}

/* ---------- Sources: compact grouped layout ---------- */
.source-group-header {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--outline);
  padding: 14px 0 6px;
  border-bottom: 1px solid rgba(216, 195, 180, 0.15);
}

.source-group {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  padding: 6px 0 4px;
}

.source-compact-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  min-width: 0;
}

.source-compact-icon {
  cursor: pointer;
  display: flex;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}

.source-compact-icon:hover {
  opacity: 0.7;
}

.source-error-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--error);
}

.source-compact-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--on-surface);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.source-compact-name:hover {
  color: var(--primary);
}

/* ---------- Source edit popup ---------- */
.source-edit-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.source-edit-popup-content {
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  padding: 16px 20px;
  min-width: 280px;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.source-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.source-edit-header strong {
  font-family: var(--font-heading);
  font-size: 15px;
}

.source-edit-close {
  color: var(--outline);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.source-edit-close:hover {
  color: var(--on-surface);
}

.source-edit-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 12px 0;
}

.source-edit-label {
  font-size: 11px;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.source-edit-label select {
  font-size: 12px;
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  color: var(--on-surface);
  padding: 2px 4px;
  border-radius: 4px;
}

.source-edit-label input[type="checkbox"] {
  accent-color: var(--secondary);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.source-edit-delete {
  font-size: 12px;
  color: var(--error);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  margin-top: 4px;
  border-top: 1px solid var(--outline-variant);
  width: 100%;
}

.source-edit-delete:hover {
  opacity: 0.7;
}

/* Legacy (kept for source-detail view) */
.source-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(216, 195, 180, 0.2);
  gap: 8px;
}

.source-delete-btn {
  color: var(--outline);
  display: flex;
  align-items: center;
  transition: color 50ms;
  flex-shrink: 0;
}

.source-delete-btn:hover {
  color: var(--error);
}

.source-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.source-toggle input[type="checkbox"] {
  accent-color: var(--secondary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* AI Agent box */
.agent-box {
  margin-bottom: 20px;
  padding: 12px;
  background: var(--surface-container);
  border: 1px solid rgba(216, 195, 180, 0.3);
}

.agent-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary);
  margin-bottom: 8px;
}

#agent-log {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.agent-msg {
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 10px;
  margin-bottom: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.agent-msg.user {
  background: var(--surface-container-high);
  color: var(--on-surface);
}

.agent-msg.bot {
  background: var(--surface-container-lowest);
  color: var(--on-surface-variant);
  border-left: 2px solid var(--primary-container);
}

.agent-msg.thinking {
  color: var(--outline);
  font-style: italic;
}

.blog-post-card {
  background: var(--surface-container-lowest);
  border: 1px solid rgba(216, 195, 180, 0.4);
  padding: 16px;
  margin-bottom: 12px;
}

.blog-post-card h3 {
  font-family: var(--font-headline);
  font-size: 17px;
  font-style: italic;
  margin-bottom: 6px;
}

.blog-post-card .post-meta {
  font-size: 11px;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.blog-post-card .post-content {
  font-size: 14px;
  line-height: 1.5;
  color: var(--on-surface-variant);
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  font-family: var(--font-headline);
  font-size: 15px;
  font-style: italic;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(216, 195, 180, 0.2);
  color: var(--on-surface-variant);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}

.setting-row .setting-label { color: var(--on-surface-variant); }
.setting-row .setting-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--outline);
}

/* ==========================================================================
   MOBILE HAMBURGER MENU
   ========================================================================== */

#mobile-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
}

#mobile-menu-overlay .menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 28, 11, 0.4);
}

#mobile-menu-overlay .menu-panel {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface-container-low);
  padding: 24px 16px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

#mobile-menu-overlay.open .menu-panel {
  transform: translateX(0);
}

.menu-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  color: var(--on-surface-variant);
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}

.menu-nav-item.active {
  color: var(--primary);
  font-weight: 600;
}

.menu-nav-item .material-symbols-outlined {
  font-size: 20px;
}

/* ==========================================================================
   SOURCE ICON
   ========================================================================== */

.source-icon {
  width: 24px;
  height: 24px;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-headline);
  font-size: 13px;
  font-weight: 700;
  color: var(--on-primary);
  flex-shrink: 0;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Tablet+ : 2 col masonry */
@media (min-width: 768px) {
  #main-content {
    padding-bottom: 0;
  }

  .masonry-grid .card {
    flex: 1 1 calc(50% - 8px);
    max-width: calc(50% - 8px);
  }

}

/* Desktop XL: 3 col masonry */
@media (min-width: 1280px) {
  .masonry-grid .card {
    flex: 1 1 calc(33.333% - 11px);
    max-width: calc(33.333% - 11px);
  }
}

/* Mobile adjustments */
@media (max-width: 767px) {
  #main-header {
    padding: 12px 16px 8px;
  }

  .header-controls {
    gap: 4px;
  }

  #feed-area {
    padding: 12px;
  }

  .card-title {
    font-size: 16px;
  }

  .article-view {
    padding: 20px 16px 100px;
  }

  .article-title {
    font-size: 22px;
  }

  .overlay-bar {
    padding: 12px 16px;
  }
}

/* ==========================================================================
   UTILITY
   ========================================================================== */

/* Toast notification */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--inverse-surface);
  color: var(--surface);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden { display: none !important; }

/* Card fade-in */
.card {
  animation: cardIn 0.15s ease both;
}

@keyframes cardIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   EMBED MODE (Android WebView)
   ========================================================================== */

body.embed #btn-hamburger { position: relative; }
body.embed #btn-hamburger,
body.embed #mobile-menu-overlay {
  display: none !important;
}

body.embed #main-header {
  padding-top: 8px;
  padding-bottom: 6px;
}

body.embed #app-shell {
  display: block;
}

/* Prevent WebView edge-swipe and overscroll interference */
body.embed {
  overscroll-behavior: none;
}
body.embed #main-content,
body.embed #feed-area {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   FORAGESTREAM TICKER BAR
   ========================================================================== */

#fs-ticker {
  overflow: hidden;
  background: var(--surface-container-low);
  border-bottom: 1px solid rgba(216, 195, 180, 0.3);
  padding: 6px 0;
  position: relative;
  white-space: nowrap;
}

.fs-ticker-track {
  display: inline-flex;
  gap: 32px;
  will-change: transform;
}

.fs-ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--on-surface-variant);
  cursor: pointer;
  flex-shrink: 0;
  padding: 2px 8px;
  transition: color 50ms;
}

.fs-ticker-item:hover {
  color: var(--primary);
}

.fs-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fs-status-dot.fresh { background: var(--secondary); }
.fs-status-dot.seen { background: var(--error); }
.fs-status-dot.fetching { background: #d4a017; animation: pulse 1.5s ease infinite; }

/* ==========================================================================
   FORAGESTREAM CARDS
   ========================================================================== */

.fs-cards-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.fs-card {
  background: var(--surface-container-lowest);
  border: 1px solid rgba(216, 195, 180, 0.4);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 50ms, border-color 50ms;
  flex: 1 1 100%;
  min-width: 0;
}

.fs-card:hover {
  box-shadow: 0 4px 32px rgba(31, 28, 11, 0.08);
  border-color: var(--outline-variant);
}

.fs-card-source {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--outline);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fs-card-title {
  font-family: var(--font-headline);
  font-style: italic;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--on-surface);
  margin-bottom: 6px;
}

.fs-card-excerpt {
  font-size: 13px;
  line-height: 1.5;
  color: var(--on-surface-variant);
  margin-bottom: 8px;
}

.fs-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.fs-card-actions .action-btn {
  font-size: 10px;
  padding: 5px 12px;
}

/* ForageStream settings panel */
.fs-settings-panel {
  background: var(--surface-container-lowest);
  border: 1px solid rgba(216, 195, 180, 0.4);
  padding: 20px;
  margin-bottom: 20px;
}

.fs-settings-panel h3 {
  font-family: var(--font-headline);
  font-size: 15px;
  font-style: italic;
  margin-bottom: 12px;
  color: var(--on-surface-variant);
}

.fs-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}

.fs-settings-row .setting-label { color: var(--on-surface-variant); }
.fs-settings-row .setting-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--outline);
}

/* ForageStream detail modal */
.fs-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(31, 28, 11, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fs-modal {
  background: var(--surface);
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.fs-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  color: var(--on-surface-variant);
}

.fs-modal-close:hover { color: var(--on-surface); }

/* ==========================================================================
   ACTIVITY FEED (right sidebar)
   ========================================================================== */

.activity-feed {
  max-height: 200px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(216, 195, 180, 0.1);
  font-size: 11px;
  color: var(--on-surface-variant);
  line-height: 1.4;
}

.activity-item .activity-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--outline);
  white-space: nowrap;
  flex-shrink: 0;
}

.activity-item .activity-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item .material-symbols-outlined {
  font-size: 14px;
  color: var(--outline);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ==========================================================================
   TRANSCRIPT VIEWER
   ========================================================================== */

.transcript-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  background: rgba(212, 236, 162, 0.3);
  color: var(--secondary);
  border: 1px solid rgba(82, 101, 42, 0.2);
  cursor: pointer;
  transition: background 50ms;
}

.transcript-badge:hover {
  background: rgba(212, 236, 162, 0.5);
}

.transcript-badge .material-symbols-outlined {
  font-size: 14px;
}

.transcript-section {
  margin: 16px 0;
  padding: 16px;
  background: var(--surface-container);
  border-left: 2px solid var(--secondary);
  font-size: 14px;
  line-height: 1.7;
  color: var(--on-surface-variant);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ==========================================================================
   BLOG EDITOR ENHANCEMENTS
   ========================================================================== */

.blog-editor-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.blog-editor-toolbar .action-btn {
  font-size: 10px;
  padding: 4px 10px;
}

.blog-editor-toolbar .action-btn.active {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-color: var(--primary-container);
}

.blog-preview-area {
  padding: 16px;
  background: var(--surface-container-lowest);
  border: 1px solid rgba(216, 195, 180, 0.3);
  font-size: 16px;
  line-height: 1.8;
  color: var(--on-surface);
  min-height: 200px;
}

.blog-preview-area p { margin-bottom: 1em; }
.blog-preview-area img { max-width: 100%; height: auto; }

/* ==========================================================================
   MESSAGING SYSTEM
   ========================================================================== */

/* Unread message badge */
.msg-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: #e67e22;
  color: #fff;
  border-radius: 50%;
  margin-left: auto;
  line-height: 1;
}

.sidebar-nav-item {
  position: relative;
}

/* Identity circle — round avatar */
.identity-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.identity-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Thread list */
.thread-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(216, 195, 180, 0.2);
  cursor: pointer;
  transition: background 50ms;
  align-items: center;
}

.thread-item:hover {
  background: rgba(216, 195, 180, 0.1);
}
/* Avatar in thread list — separate click target, own hover */
.thread-item .identity-circle {
  position: relative;
  z-index: 1;
  transition: transform 0.15s, box-shadow 0.15s;
}
.thread-item .identity-circle:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--primary);
  border-radius: 50%;
}

.thread-item .thread-info {
  flex: 1;
  min-width: 0;
}

.thread-item .thread-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--on-surface);
  margin-bottom: 2px;
}

.thread-item .thread-subject {
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 2px;
}

.thread-item .thread-preview {
  font-size: 13px;
  color: var(--on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.thread-item .thread-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.thread-item .thread-time {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--outline);
  white-space: nowrap;
}

.thread-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: #e67e22;
  color: #fff;
  border-radius: 50%;
}

.thread-external-badge {
  font-size: 10px;
  color: var(--outline);
  font-style: italic;
}

/* Stacked identity circles for groups */
.thread-avatars-stacked {
  display: flex;
  position: relative;
  width: 40px;
  height: 40px;
}

.thread-avatars-stacked .identity-circle {
  position: absolute;
  border: 2px solid var(--surface);
}

.thread-avatars-stacked .identity-circle:nth-child(1) { top: 0; left: 0; z-index: 3; }
.thread-avatars-stacked .identity-circle:nth-child(2) { top: 4px; left: 10px; z-index: 2; }
.thread-avatars-stacked .identity-circle:nth-child(3) { top: 8px; left: 20px; z-index: 1; }

.thread-avatars-stacked .stacked-more {
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 9px;
  font-weight: 700;
  color: var(--outline);
  z-index: 4;
}

/* Compose form */
.compose-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
}

.compose-form label {
  font-size: 11px;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.compose-form input,
.compose-form textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  background: transparent;
  color: var(--on-surface);
  outline: none;
  transition: border-color 50ms;
}

.compose-form input:focus,
.compose-form textarea:focus {
  border-bottom-color: var(--primary);
}

.compose-form input::placeholder,
.compose-form textarea::placeholder {
  color: var(--outline);
  font-style: italic;
}

.compose-form textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(31, 28, 11, 0.12);
}

.autocomplete-dropdown .autocomplete-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: background 50ms;
}

.autocomplete-dropdown .autocomplete-item:hover {
  background: rgba(216, 195, 180, 0.15);
}

.autocomplete-dropdown .autocomplete-item .autocomplete-name {
  font-weight: 600;
}

.autocomplete-dropdown .autocomplete-item .autocomplete-username {
  font-size: 12px;
  color: var(--outline);
}

/* Responsive: tablet+ ForageStream cards */
@media (min-width: 768px) {
  .fs-card {
    flex: 1 1 calc(50% - 8px);
    max-width: calc(50% - 8px);
  }
}

@media (min-width: 1280px) {
  .fs-card {
    flex: 1 1 calc(33.333% - 11px);
    max-width: calc(33.333% - 11px);
  }
}

/* ==========================================================================
   PHONECHAT — Base Styles
   ========================================================================== */

/* Overlay mode — fills screen, centers frame */
.phone-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
}

.phone-chat-overlay.open {
  display: flex;
}

/* Frame — the chat container (always dark scheme) */
.phone-chat-frame {
  background: #1a1a1a;
  color: #e0e0e0;
  border: 1px solid #333;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: min(700px, 85dvh);
  overflow: hidden;
}

@media (max-width: 767px) {
  .phone-chat-frame {
    max-width: 100%;
    height: 100dvh;
    border: none;
  }
}

/* Header */
.phone-chat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  min-height: 0;
  background: #2a2a2a;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.phone-chat-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phone-chat-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: 2px;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.phone-chat-close:hover { opacity: 1; }

/* Messages area */
.phone-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* Message row */
.phone-chat-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 85%;
}

.phone-chat-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

/* Message row layout with avatar overlap */
.pc-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
  position: relative;
}
.pc-msg-row-user { justify-content: flex-end; }
.pc-msg-row-assistant { justify-content: flex-start; }
.pc-msg-avatar {
  flex-shrink: 0;
  z-index: 1;
}
.pc-msg-avatar .identity-circle,
.pc-msg-avatar img {
  border: none !important;
  box-shadow: none !important;
}
.pc-msg-row-user .pc-msg-avatar { margin-left: 0; }
.pc-msg-row-assistant .pc-msg-avatar { margin-right: 0; }

/* Bubbles */
.phone-chat-bubble-user,
.phone-chat-bubble-assistant {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
}

.phone-chat-bubble-user {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: 16px 16px 4px 16px;
}

.phone-chat-bubble-assistant {
  background: var(--surface-container);
  color: var(--on-surface);
  border-radius: 16px 16px 16px 4px;
}

/* Typing indicator */
.phone-chat-typing .phone-chat-bubble-assistant {
  min-width: 50px;
}

.typing-dots {
  display: inline-flex;
  gap: 2px;
  font-size: 20px;
  line-height: 1;
}

.typing-dots span {
  animation: typingBounce 1.4s ease infinite;
  display: inline-block;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Tool log (collapsed thinking display in chat bubbles) */
.tool-log-details {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.tool-log-details[open] { opacity: 0.85; }
.tool-log-summary {
  cursor: pointer;
  font-family: 'Space Grotesk', monospace;
  color: var(--text-secondary, #888);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tool-log-summary::before {
  content: '\25B6';
  font-size: 8px;
  transition: transform 0.15s;
}
.tool-log-details[open] > .tool-log-summary::before {
  transform: rotate(90deg);
}
.tool-log-summary::-webkit-details-marker { display: none; }
.tool-log-list {
  margin-top: 4px;
  padding-left: 12px;
  border-left: 2px solid var(--border-color, #333);
  font-family: 'Space Grotesk', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary, #888);
}
.tool-log-entry {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Image result cards (from [IMAGE:] signal) */
.image-result-meta {
  font-family: 'Space Grotesk', monospace;
  font-size: 12px;
  color: var(--text-secondary, #888);
  margin-top: 6px;
  opacity: 0.7;
}
.image-meta-popup {
  font-family: 'Space Grotesk', monospace;
  color: #ddd;
}
.image-meta-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  line-height: 1.4;
}
.image-meta-key {
  color: #7aa2f7;
  font-weight: 600;
  white-space: nowrap;
  min-width: 80px;
}
.image-meta-val {
  color: #ccc;
  word-break: break-word;
}

/* Media cards in chat bubbles */
.media-doc-card,
.media-link-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  margin-top: 8px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-family: var(--font-body);
  line-height: 1.3;
}
.media-doc-card {
  background: var(--surface-container-high);
  color: var(--on-surface);
  cursor: pointer;
  transition: background 0.15s;
}
.media-doc-card:hover {
  background: var(--surface-container-highest, #e0d6cc);
}
.media-link-card {
  background: var(--surface-container);
  color: var(--primary);
}
.media-doc-card .material-symbols-outlined,
.media-link-card .material-symbols-outlined {
  font-size: 18px;
  flex-shrink: 0;
}
.phone-chat-bubble-assistant img,
.phone-chat-bubble-user img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
}
.phone-chat-bubble-assistant video {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
}

/* Input row */
.phone-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #333;
  background: #1a1a1a;
  flex-shrink: 0;
}

.phone-chat-textarea {
  flex: 1;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid #444;
  border-radius: 20px;
  background: #252525;
  color: #e0e0e0;
  outline: none;
  resize: none;
  overflow: hidden;
  line-height: 1.4;
  transition: border-color 0.15s;
}

.phone-chat-textarea:focus {
  border-color: #666;
}

.phone-chat-textarea::placeholder {
  color: #888;
}

.phone-chat-send,
.phone-chat-mic {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.phone-chat-send:hover { background: var(--primary-container); }

.phone-chat-mic {
  background: transparent;
  color: var(--on-surface-variant);
}

.phone-chat-mic:hover { color: var(--primary); }
.phone-chat-mic.active { color: var(--error); }

/* Widget (injected interactive elements) */
.phone-chat-widget {
  padding: 8px 0;
  animation: widgetFadeIn 0.3s ease;
}

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

/* Phase transitions */
.phone-chat-phase-transitioned .phone-chat-bubble-user {
  transition: background 0.5s, color 0.5s;
}

.phone-chat-phase-transitioned .phone-chat-bubble-assistant {
  transition: background 0.5s, color 0.5s;
}

/* Avatar panel */
.phone-chat-avatar-panel {
  flex-shrink: 0;
  overflow: hidden;
  transition: height 0.3s ease;
}

.phone-chat-avatar-panel.collapsed {
  height: 40px;
}

.phone-chat-avatar-canvas {
  width: 100%;
  height: 200px;
}

.phone-chat-avatar-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  width: 100%;
  padding: 4px;
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  font-size: 12px;
}

/* Onboarding styles */
.ob-bg {
  background: #5c4433;
  position: absolute;
  inset: 0;
}

.ob-username-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.ob-subdomain {
  font-size: 12px;
  color: var(--outline);
  margin-top: 4px;
}

.ob-activate-btn {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 12px;
  transition: background 0.15s;
}

.ob-activate-btn:hover { background: var(--primary-container); }

/* ==========================================================================
   SESSION GROUP 3 — Groups, Identity, Avatars, UI Contrast
   ========================================================================== */

/* PhoneChat always renders in dark scheme regardless of app theme */
.phone-chat-bubble-user {
  background: rgba(255,255,255,0.12) !important;
  color: #fff !important;
}

.phone-chat-bubble-assistant {
  background: #E8A56A !important;
  color: #1a1a1a !important;
}
.phone-chat-bubble-assistant a {
  color: #1a4a7a !important;
  text-decoration: underline;
}

.phone-chat-header {
  font-weight: 700 !important;
  color: #fff !important;
}

/* Thread context bar */
.thread-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  font-size: 11px;
  opacity: 0.7;
  background: rgba(0,0,0,0.15);
}
.thread-context-bar .ctx-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary, #999);
}
.thread-context-bar .ctx-new-thread {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: inherit;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
}
.thread-context-bar .ctx-new-thread:hover {
  background: rgba(255,255,255,0.1);
}

/* Avatar chooser */
.avatar-chooser {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  padding: 12px 0;
}

.avatar-choice {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--outline-variant);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.avatar-choice:hover {
  transform: scale(1.08);
  border-color: var(--primary);
}

.avatar-choice.chosen {
  border: 4px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(137, 77, 13, 0.25);
}

.avatar-choice.dimmed {
  opacity: 0.3;
  pointer-events: none;
}

/* Avatar hover preview popup */
.avatar-preview-popup {
  position: fixed;
  z-index: 9500;
  width: 256px;
  height: 256px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(31, 28, 11, 0.25);
  pointer-events: none;
  animation: avatarPopIn 0.15s ease both;
}

.avatar-preview-popup img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-preview-popup .avatar-preview-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 6px 8px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

@keyframes avatarPopIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

/* Group header actions (video/mic placeholders) */
.group-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.group-header-actions .material-symbols-outlined {
  font-size: 20px;
  color: #fff;
  opacity: 0.3;
  cursor: default;
}

/* Group circles grid for thread list */
.group-circles-grid {
  display: grid;
  grid-template-columns: repeat(2, 20px);
  gap: 2px;
  width: 40px;
  height: 40px;
  align-content: center;
}

.group-circles-grid .identity-circle {
  border: 1.5px solid var(--surface);
}

.group-circles-grid .stacked-more {
  font-size: 9px;
  font-weight: 700;
  color: var(--outline);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Member chip for new group modal */
.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 4px;
  background: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--on-surface);
  cursor: default;
}

.member-chip .member-chip-remove {
  cursor: pointer;
  font-size: 14px;
  color: var(--outline);
  transition: color 50ms;
  display: flex;
  align-items: center;
}

.member-chip .member-chip-remove:hover {
  color: var(--error);
}

/* Settings avatar section */
.settings-avatar-section {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}

.settings-avatar-preview {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--outline-variant);
}

.settings-avatar-placeholder {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: var(--surface-container-high);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--outline);
}

.settings-avatar-placeholder .material-symbols-outlined {
  font-size: 48px;
}

/* Group sender label in group bubbles */
.group-bubble-sender {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* New Group form inside PhoneChat bodyHtml */
.new-group-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
}

.new-group-form label {
  font-size: 11px;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.new-group-form input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  background: transparent;
  color: var(--on-surface);
  outline: none;
  transition: border-color 50ms;
}

.new-group-form input:focus {
  border-bottom-color: var(--primary);
}

.new-group-form input::placeholder {
  color: var(--outline);
  font-style: italic;
}

.selected-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

/* ==========================================================================
   SESSION GROUP 4 — Social View, Blog Overhaul, Landing Page
   ========================================================================== */

/* Social view */
.social-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
}

.social-orbit {
  position: relative;
  min-height: 500px;
  width: 100%;
  max-width: 600px;
}

.social-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.social-node {
  position: absolute;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 1;
}

.social-node:hover .identity-circle {
  transform: scale(1.15);
}

.social-node .identity-circle {
  transition: transform 0.15s ease;
}

.social-node-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--on-surface-variant);
  text-align: center;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.social-detail-card {
  position: absolute;
  z-index: 10;
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  padding: 20px;
  box-shadow: 0 8px 32px rgba(31, 28, 11, 0.15);
  min-width: 240px;
  max-width: 320px;
  animation: cardIn 0.15s ease both;
}

.social-detail-card .detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.social-detail-card .detail-name {
  font-family: var(--font-headline);
  font-size: 18px;
  font-style: italic;
  font-weight: 500;
  color: var(--on-surface);
}

.social-detail-card .detail-username {
  font-size: 12px;
  color: var(--outline);
}

.social-detail-card .detail-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  background: rgba(212, 236, 162, 0.3);
  color: var(--on-secondary-container);
  border: 1px solid rgba(82, 101, 42, 0.15);
  margin-bottom: 8px;
}

.social-detail-card .detail-meta {
  font-size: 12px;
  color: var(--outline);
  margin-bottom: 4px;
}

.social-detail-card .detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.social-detail-card .detail-actions .action-btn {
  font-size: 10px;
  padding: 6px 12px;
}

.social-detail-card .detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--outline);
  cursor: pointer;
  transition: color 50ms;
}

.social-detail-card .detail-close:hover {
  color: var(--on-surface);
}

.orbit-placeholder {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--outline-variant);
  opacity: 0.4;
  animation: breathe 3s ease-in-out infinite;
  position: absolute;
}

@keyframes breathe {
  0%, 100% { opacity: 0.2; transform: scale(0.85); }
  50% { opacity: 0.5; transform: scale(1); }
}

/* Blog submenu */
.blog-submenu {
  display: none;
  flex-direction: column;
  background: var(--surface-container);
  padding-left: 32px;
}

.blog-submenu.open {
  display: flex;
}

.blog-submenu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--on-surface-variant);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  width: fit-content;
  min-width: 100%;
  transition: background 50ms, color 50ms;
}

.blog-submenu-item:hover {
  background: rgba(216, 195, 180, 0.15);
  color: var(--on-surface);
  text-decoration: none;
}

/* Sidebar blog nav wrapper for submenu positioning */
.sidebar-nav-item.has-submenu {
  position: relative;
}

/* Mobile blog submenu — inline expansion */
.mobile-blog-submenu {
  display: none;
  flex-direction: column;
  padding-left: 32px;
}

.mobile-blog-submenu.open {
  display: flex;
}

.mobile-blog-submenu .blog-submenu-item {
  width: fit-content;
  padding: 8px 12px;
  font-size: 14px;
}

/* Blog tags input */
.blog-tags-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  margin-bottom: 12px;
}

.blog-tags-input input {
  flex: 1;
  min-width: 100px;
  font-family: var(--font-body);
  font-size: 13px;
  padding: 4px 0;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  background: transparent;
  color: var(--on-surface);
  outline: none;
}

.blog-tags-input input:focus {
  border-bottom-color: var(--primary);
}

.blog-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(212, 236, 162, 0.3);
  color: var(--on-secondary-container);
  border: 1px solid rgba(82, 101, 42, 0.15);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

.blog-tag-chip .tag-remove {
  cursor: pointer;
  font-size: 14px;
  color: var(--outline);
  transition: color 50ms;
  display: flex;
  align-items: center;
}

.blog-tag-chip .tag-remove:hover {
  color: var(--error);
}

/* AI disclosure badge */
.ai-disclosure-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  background: rgba(186, 26, 26, 0.08);
  color: var(--error);
  border: 1px solid rgba(186, 26, 26, 0.15);
}

.ai-disclosure-badge .material-symbols-outlined {
  font-size: 12px;
}

/* Blog action buttons */
.blog-publish-btn {
  background: var(--secondary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 8px 16px;
  border: none;
  cursor: pointer;
  transition: background 50ms;
}

.blog-publish-btn:hover {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.blog-delete-btn {
  background: transparent;
  color: var(--error);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 8px 16px;
  border: 1px solid rgba(186, 26, 26, 0.3);
  cursor: pointer;
  transition: background 50ms, color 50ms;
}

.blog-delete-btn:hover {
  background: var(--error);
  color: #fff;
}

/* Post body */
.post-body {
  white-space: pre-line;
}

/* ==========================================================================
   SAGE BUTTON
   ========================================================================== */

.sage-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 8px 16px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  border: none;
  cursor: pointer;
  transition: background 50ms;
  margin-top: 12px;
}

.sage-btn:hover {
  background: var(--secondary);
  color: #fff;
}

/* ==========================================================================
   SHARE DROPDOWN
   ========================================================================== */

.share-dropdown {
  position: absolute;
  bottom: 100%;
  right: 0;
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 100;
  min-width: 160px;
  margin-bottom: 4px;
}

.share-dropdown a {
  display: block;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--on-surface);
  text-decoration: none;
  transition: background 50ms;
}

.share-dropdown a:hover {
  background: var(--surface-container-high);
  text-decoration: none;
}

/* ==========================================================================
   TRANSCRIPT REQUEST BUTTON
   ========================================================================== */

.transcript-request-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 7px 14px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--outline-variant);
  cursor: pointer;
  transition: background 50ms, color 50ms;
}

.transcript-request-btn:hover {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.transcript-request-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ==========================================================================
   CONNECTED ACCOUNTS
   ========================================================================== */

.connected-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--outline-variant);
}

.connected-account-row:last-child {
  border-bottom: none;
}

.connected-account-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.connected-account-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 600px) {
  .connected-account-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .connected-account-actions {
    margin-top: 8px;
  }
}

/* ==========================================================================
   SESSION GROUP 6 — Dark/Light Mode + Layout Overhaul
   ========================================================================== */

/* ---------- Dark theme variable overrides ---------- */
[data-theme="dark"] {
  --primary: #f0a868;
  --primary-container: #7a4510;
  --on-primary: #1a1100;
  --on-primary-container: #ffdcc2;
  --secondary: #a8c96a;
  --secondary-container: #3d4f1a;
  --on-secondary-container: #d4eca2;
  --surface: #1a1812;
  --surface-dim: #141210;
  --surface-container-lowest: #0f0e0a;
  --surface-container-low: #201e16;
  --surface-container: #252318;
  --surface-container-high: #302d22;
  --surface-container-highest: #3b382c;
  --on-surface: #e8e0c8;
  --on-surface-variant: #cac0a8;
  --outline: #968c7a;
  --outline-variant: #4a4538;
  --inverse-surface: #e8e0c8;
  --error: #ffb4ab;
  --primary-fixed: #3d2200;
  --on-primary-fixed: #ffdcc2;
}

/* Dark mode body dot grid */
[data-theme="dark"] body {
  background-image: radial-gradient(var(--outline-variant) 0.5px, transparent 0.5px);
}

/* Dark mode main content background */
[data-theme="dark"] #main-content {
  background: linear-gradient(to bottom, rgba(26,24,18,0.9), rgba(26,24,18,0.95));
}

/* Dark mode header frosted glass */
[data-theme="dark"] #main-header {
  background: rgba(26, 24, 18, 0.8);
}

/* Dark mode overlay bar */
[data-theme="dark"] .overlay-bar {
  background: rgba(26, 24, 18, 0.85);
}


/* Dark mode card borders and shadows */
[data-theme="dark"] .card {
  border-color: var(--outline-variant);
  box-shadow: 0 2px 32px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .card:hover {
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .card.selected {
  box-shadow: 0 4px 32px rgba(240, 168, 104, 0.15);
}

/* Dark mode fs-card borders */
[data-theme="dark"] .fs-card {
  border-color: var(--outline-variant);
}

[data-theme="dark"] .fs-card:hover {
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.35);
}

/* Dark mode elements using hardcoded rgba borders */
[data-theme="dark"] .sidebar-brand,
[data-theme="dark"] .sidebar-section,
[data-theme="dark"] .sidebar-footer,
[data-theme="dark"] #main-header,
[data-theme="dark"] .trending-item,
[data-theme="dark"] .activity-item,
[data-theme="dark"] .keyword-row,
[data-theme="dark"] .source-row,
[data-theme="dark"] .article-source-bar,
[data-theme="dark"] .article-bottom-actions,
[data-theme="dark"] #fs-ticker,
[data-theme="dark"] .fs-settings-panel,
[data-theme="dark"] .blog-post-card,
[data-theme="dark"] .repost-compose,
[data-theme="dark"] .settings-section h3,
[data-theme="dark"] .blog-preview-area {
  border-color: var(--outline-variant);
}

/* Dark mode hover backgrounds using hardcoded rgba */
[data-theme="dark"] .sidebar-nav-item:hover,
[data-theme="dark"] .blog-submenu-item:hover,
[data-theme="dark"] .thread-item:hover,
[data-theme="dark"] .autocomplete-dropdown .autocomplete-item:hover {
  background: rgba(74, 69, 56, 0.4);
}

[data-theme="dark"] .header-btn:hover {
  background: rgba(74, 69, 56, 0.4);
}

/* Dark mode summary box and quote backgrounds */
[data-theme="dark"] .card-summary,
[data-theme="dark"] .article-summary-box {
  background: rgba(37, 35, 24, 0.7);
}

[data-theme="dark"] .metrics-quote {
  background: rgba(37, 35, 24, 0.5);
}

/* Dark mode keyword highlight */
[data-theme="dark"] .card-title .kw-highlight,
[data-theme="dark"] .card-excerpt .kw-highlight,
[data-theme="dark"] .article-title .kw-highlight,
[data-theme="dark"] .article-body .kw-highlight {
  background: rgba(122, 69, 16, 0.5);
}

/* Dark mode chips */
[data-theme="dark"] .chip {
  background: rgba(61, 79, 26, 0.4);
  border-color: rgba(168, 201, 106, 0.2);
}

[data-theme="dark"] .filter-chip:hover {
  background: rgba(61, 79, 26, 0.6);
}

/* Dark mode action button borders */
[data-theme="dark"] .action-btn,
[data-theme="dark"] .btn-refine {
  border-color: var(--outline-variant);
}

/* Dark mode mobile menu backdrop */
[data-theme="dark"] #mobile-menu-overlay .menu-backdrop {
  background: rgba(0, 0, 0, 0.6);
}

/* Dark mode autocomplete dropdown */
[data-theme="dark"] .autocomplete-dropdown {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Dark mode fs-modal backdrop */
[data-theme="dark"] .fs-modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
}

/* Dark mode social detail card */
[data-theme="dark"] .social-detail-card {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Dark mode avatar preview popup */
[data-theme="dark"] .avatar-preview-popup {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Dark mode agent box */
[data-theme="dark"] .agent-box {
  border-color: var(--outline-variant);
}

/* Dark mode transcript/blog badges */
[data-theme="dark"] .transcript-badge {
  background: rgba(61, 79, 26, 0.4);
  border-color: rgba(168, 201, 106, 0.25);
}

[data-theme="dark"] .transcript-badge:hover {
  background: rgba(61, 79, 26, 0.6);
}

/* Dark mode share dropdown */
[data-theme="dark"] .share-dropdown {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Dark mode AI disclosure badge */
[data-theme="dark"] .ai-disclosure-badge {
  background: rgba(255, 180, 171, 0.1);
  border-color: rgba(255, 180, 171, 0.2);
}

/* Dark mode blog tag chips */
[data-theme="dark"] .blog-tag-chip {
  background: rgba(61, 79, 26, 0.4);
  border-color: rgba(168, 201, 106, 0.2);
}

/* Dark mode avatar choice border */
[data-theme="dark"] .avatar-choice {
  border-color: var(--outline-variant);
}

/* Dark mode settings avatar */
[data-theme="dark"] .settings-avatar-preview {
  border-color: var(--outline-variant);
}

/* ---------- Header sub-controls row ---------- */
.header-sub-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Feed Mode Toggle ---------- */
.feed-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--outline-variant);
  border-radius: 20px;
  overflow: hidden;
}

.feed-mode-btn {
  padding: 3px 14px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--on-surface-variant);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 100ms, color 100ms;
}

.feed-mode-btn:hover {
  background: rgba(137, 77, 13, 0.08);
}

[data-theme="dark"] .feed-mode-btn:hover {
  background: rgba(240, 168, 104, 0.1);
}

.feed-mode-btn.active {
  background: var(--primary);
  color: #fff;
}

/* ---------- Relevance Slider ---------- */
.relevance-slider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.relevance-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: var(--outline-variant);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.relevance-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}
.relevance-slider input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
}
.relevance-label {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--on-surface-variant);
  min-width: 16px;
  text-align: center;
}

/* ---------- Theme Toggle Button ---------- */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
  transition: color 50ms, background 50ms;
}

.theme-toggle-btn:hover {
  background: rgba(216, 195, 180, 0.2);
  color: var(--on-surface);
}

[data-theme="dark"] .theme-toggle-btn:hover {
  background: rgba(74, 69, 56, 0.4);
}

.theme-toggle-btn .material-symbols-outlined {
  font-size: 20px;
}

/* ==========================================================================
   SESSION GROUP 7 — Content Overlay Redesign + Real-time Notifications
   ========================================================================== */

/* Hero media — full-width image/video at top of article overlay */
.hero-media {
  width: 100%;
  max-height: 400px;
  overflow: hidden;
  margin-bottom: 20px;
  border-radius: 4px;
}

.hero-media img {
  width: 100%;
  height: 100%;
  max-height: 400px;
  object-fit: cover;
  display: block;
}

.hero-media iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border: none;
}

/* Full date display in article overlay */
.article-full-date {
  font-size: 13px;
  color: var(--outline);
  margin-left: auto;
}

/* Unified action bar — single row of all action buttons below the article */
.article-actions-unified {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid rgba(216, 195, 180, 0.3);
  align-items: center;
}

.article-actions-unified .action-btn,
.article-actions-unified .transcript-request-btn {
  white-space: nowrap;
}

.article-actions-unified .article-original-link {
  margin-top: 0;
}

/* Inline close button — positioned in article content area */
.article-inline-close {
  position: sticky;
  top: 12px;
  float: right;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 249, 237, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 50%;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: color 50ms, background 100ms;
  margin-left: 8px;
}

.article-inline-close:hover {
  color: var(--on-surface);
  background: rgba(216, 195, 180, 0.35);
}

.article-inline-close .material-symbols-outlined {
  font-size: 22px;
}

[data-theme="dark"] .article-inline-close {
  background: rgba(42, 38, 30, 0.85);
}

[data-theme="dark"] .article-inline-close:hover {
  background: rgba(74, 69, 56, 0.5);
}

/* Hamburger notification dot */
.hamburger-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: #e67e22;
  border-radius: 50%;
  pointer-events: none;
}

/* SSE connection status indicator (optional) */
.sse-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
}

.sse-indicator.connected { background: #27ae60; }
.sse-indicator.disconnected { background: #e74c3c; }

/* Mobile PhoneChat keyboard fixes */
@supports (height: 100dvh) {
  @media (max-width: 767px) {
    .phone-chat-frame {
      height: 100dvh;
      max-height: 100dvh;
      display: flex;
      flex-direction: column;
    }

    .phone-chat-frame .phone-chat-messages {
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
    }

    .phone-chat-frame .phone-chat-input-row {
      flex-shrink: 0;
    }
  }
}

/* ==========================================================================
   VIDEO CALL OVERLAY
   ========================================================================== */

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
}

.local-video {
  position: absolute;
  bottom: 80px;
  right: 16px;
  width: 150px;
  height: 100px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.3);
  z-index: 10001;
  background: #222;
}

.call-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-family: var(--font-body);
  font-size: 18px;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.call-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

.call-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.call-btn:hover {
  background: rgba(255,255,255,0.35);
}

.call-btn .material-symbols-outlined {
  font-size: 22px;
}

.call-btn-active {
  background: rgba(220, 50, 50, 0.7) !important;
}

.call-btn-active:hover {
  background: rgba(220, 50, 50, 0.85) !important;
}

.call-btn-hangup {
  background: #d32f2f !important;
}

.call-btn-hangup:hover {
  background: #b71c1c !important;
}

.call-timeout-warning {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffab00;
  font-family: var(--font-body);
  font-size: 16px;
  background: rgba(0,0,0,0.7);
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 10002;
}

.call-timeout-warning .material-symbols-outlined {
  font-size: 24px;
  color: #ffab00;
}

.call-pip-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--inverse-surface);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10000;
  padding: 0 16px;
}

.call-pip-bar .pip-bar-name {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  flex: 1;
}

.call-pip-bar .call-btn {
  width: 36px;
  height: 36px;
}

.call-pip-bar .call-btn .material-symbols-outlined {
  font-size: 18px;
}

.call-pip-mode .remote-video,
.call-pip-mode .local-video,
.call-pip-mode .call-status,
.call-pip-mode .call-controls {
  display: none !important;
}

/* Thread header video call button */
.thread-call-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
  display: flex;
  align-items: center;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.thread-call-btn:hover {
  opacity: 1;
}

.thread-call-btn .material-symbols-outlined {
  font-size: 22px;
}

/* Incoming call banner */
.incoming-call-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10010;
  background: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  min-width: 280px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-100%); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.incoming-call-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface);
}

.incoming-call-info .material-symbols-outlined {
  font-size: 20px;
  color: var(--primary);
}

.incoming-call-actions {
  display: flex;
  gap: 8px;
}

.incoming-call-accept {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #4caf50;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.incoming-call-accept:hover {
  background: #388e3c;
}

.incoming-call-decline {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #d32f2f;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.incoming-call-decline:hover {
  background: #b71c1c;
}

@media (max-width: 767px) {
  .local-video {
    width: 100px;
    height: 75px;
    bottom: 76px;
    right: 8px;
  }

  .call-controls {
    gap: 12px;
    padding: 12px;
  }

  .incoming-call-banner {
    left: 8px;
    right: 8px;
    transform: none;
    min-width: auto;
  }

  @keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
}

[data-theme="dark"] .article-actions-unified {
  border-top-color: rgba(74, 69, 56, 0.4);
}

/* ==========================================================================
   CONTEXT MENU
   ========================================================================== */

.context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
  animation: contextMenuIn 0.12s ease-out;
}

@keyframes contextMenuIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--on-surface);
  transition: background 0.1s;
  user-select: none;
}

.context-menu-item:hover {
  background: var(--surface-container-high);
}

.context-menu-item .material-symbols-outlined {
  font-size: 18px;
  color: var(--on-surface-variant);
}

.context-menu-divider {
  border-top: 1px solid var(--outline-variant);
  margin: 4px 0;
}

[data-theme="dark"] .context-menu {
  background: var(--surface-container-lowest);
  border-color: var(--outline-variant);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ---------------------------------------------------------------------------
   Voice Chat Mode
   --------------------------------------------------------------------------- */

/* Thread header action buttons — right-aligned row */
.thread-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.thread-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: inherit;
  opacity: 0.6;
  transition: opacity 0.2s, color 0.2s;
  display: flex;
  align-items: center;
}
.thread-action-btn .material-symbols-outlined { font-size: 18px; }
.thread-action-btn:hover { opacity: 1; }
.thread-voice-btn.active {
  opacity: 1;
  color: var(--primary);
}

/* Expanded full-page chat mode (desktop only) */
@media (min-width: 768px) {
  .phone-chat-expanded .phone-chat-positioner {
    max-width: 100% !important;
    width: 100% !important;
    height: 100dvh !important;
    padding: 0 !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
  }
  .phone-chat-expanded .phone-chat-frame {
    max-width: 100% !important;
    height: 100dvh !important;
    border: none !important;
    border-radius: 0 !important;
  }
  .phone-chat-expanded .phone-chat-messages {
    max-width: 70%;
    margin: 0 auto;
    width: 100%;
  }
  .phone-chat-expanded .phone-chat-input-row {
    max-width: 70%;
    margin: 0 auto;
    width: 100%;
  }
  .phone-chat-expanded .phone-chat-header {
    padding: 6px 15%;
  }
  .phone-chat-expanded .phone-chat-bubble-user,
  .phone-chat-expanded .phone-chat-bubble-assistant {
    font-size: 15px;
  }
  .phone-chat-expanded .phone-chat-bubble-assistant img,
  .phone-chat-expanded .phone-chat-bubble-user img {
    max-width: 100%;
  }
  .phone-chat-expanded .phone-chat-bg {
    background: #1a1a1a !important;
  }
  .phone-chat-expanded .thread-context-bar {
    max-width: 70%;
    margin: 0 auto;
    width: 100%;
  }
  .phone-chat-expanded .phone-chat-avatar-panel {
    max-width: 70%;
    margin: 0 auto;
    width: 100%;
  }
  /* Hide expand button on mobile */
  .thread-expand-btn { display: flex; }
}
@media (max-width: 767px) {
  .thread-expand-btn { display: none !important; }
}

/* Status dot in header */
.voice-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
  background: #888;
  transition: background 0.3s;
}
.voice-status-dot.voice-state-listening { background: #4caf50; }
.voice-status-dot.voice-state-processing { background: #ff9800; }
.voice-status-dot.voice-state-speaking { background: #2196f3; }
.voice-status-dot.voice-state-connecting { background: #888; animation: voice-pulse 1.5s ease-in-out infinite; }

/* Voice controls in input row */
.phone-chat-input-row.voice-active {
  flex-direction: column;
  padding: 8px 12px;
  gap: 8px;
}

.voice-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Draft bubble interim state */
.voice-draft-bubble.interim {
  font-style: italic;
  opacity: 0.5;
}

.voice-mic-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.voice-state-indicator {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.voice-state-icon { font-size: 28px; z-index: 1; opacity: 0.7; }

.voice-send-btn,
.voice-stop-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
}
.voice-send-btn {
  background: var(--primary);
  color: var(--on-primary, #fff);
}
.voice-stop-btn {
  background: #d32f2f;
  color: #fff;
}
.voice-send-btn:hover,
.voice-stop-btn:hover { filter: brightness(1.1); }

/* State ring around mic button */
.voice-state-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: border-color 0.3s, transform 0.15s;
}
.voice-state-ring.voice-state-listening {
  border-color: #4caf50;
  animation: voice-pulse 2s ease-in-out infinite;
}
.voice-state-ring.voice-state-processing {
  border-color: #ff9800;
  animation: voice-pulse 1s ease-in-out infinite;
}
.voice-state-ring.voice-state-speaking {
  border-color: #2196f3;
  animation: none;
}

@keyframes voice-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
}

.voice-status-dot.voice-state-paused { background: #ff5722; }
.voice-state-ring.voice-state-paused {
  border-color: #ff5722;
  animation: none;
}

.voice-paused-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: inherit;
}
.voice-paused-content {
  text-align: center;
  color: #fff;
}
.voice-paused-content .material-symbols-outlined {
  font-size: 48px;
  opacity: 0.7;
}
.voice-paused-content p {
  margin: 8px 0 16px;
  font-size: 14px;
  opacity: 0.8;
}
.voice-resume-btn {
  background: var(--primary, #4caf50);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 24px;
  font-size: 14px;
  cursor: pointer;
}
.voice-resume-btn:hover { opacity: 0.9; }

/* Draft bubble — user's in-progress transcript */
.voice-draft-bubble {
  border: 1px dashed var(--primary) !important;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.voice-draft-bubble.interim {
  opacity: 0.6;
  font-style: italic;
}
.voice-draft-text {
  flex: 1;
  word-break: break-word;
}
.voice-draft-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  align-items: center;
}
.voice-draft-send,
.voice-draft-clear {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: inherit;
  opacity: 0.7;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
}
.voice-draft-send:hover { opacity: 1; color: var(--primary); }
.voice-draft-clear:hover { opacity: 1; color: #d32f2f; }
.voice-draft-send .material-symbols-outlined,
.voice-draft-clear .material-symbols-outlined { font-size: 20px; }

.phone-chat-msg.voice-draft {
  animation: voice-draft-fade 0.3s ease-in;
}

@keyframes voice-draft-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* AI streaming bubble */
.voice-ai-streaming .phone-chat-bubble-assistant {
  opacity: 0.85;
  border-left: 2px solid var(--primary);
}

/* Media generating spinner */
.voice-media-generating {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  opacity: 0.7;
}
.spinning {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Attachment menu */
.attach-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--on-surface);
  opacity: 0.6;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
}
.attach-menu-btn:hover { opacity: 1; }

.attach-popup {
  position: absolute;
  bottom: 100%;
  left: 8px;
  background: var(--surface-container, #2a2a2a);
  border: 1px solid var(--outline-variant, #444);
  border-radius: 12px;
  padding: 6px 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 100;
  display: none;
  min-width: 160px;
}
.attach-popup.open { display: block; }
.attach-popup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--on-surface);
  font-size: 14px;
  transition: background 0.15s;
}
.attach-popup-item:hover { background: rgba(255,255,255,0.08); }
.attach-popup-item .material-symbols-outlined { font-size: 20px; opacity: 0.7; }

/* Camera overlay */
.camera-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.camera-overlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-controls {
  position: absolute;
  bottom: 40px;
  display: flex;
  gap: 24px;
  align-items: center;
}
.camera-capture-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255,255,255,0.2);
  cursor: pointer;
  transition: background 0.2s;
}
.camera-capture-btn:hover { background: rgba(255,255,255,0.4); }
.camera-cancel-btn,
.camera-flip-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fullscreen media viewer */
.media-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.media-viewer-overlay img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: default;
  touch-action: pinch-zoom;
}
.media-viewer-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 12px;
}
.media-viewer-actions button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.media-viewer-actions button:hover { background: rgba(255,255,255,0.3); }

/* Voice settings panel */
.voice-settings-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70%;
  background: var(--surface-container, #1e1e1e);
  border-top: 1px solid var(--outline-variant, #444);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  overflow-y: auto;
  z-index: 50;
  animation: slide-up 0.25s ease-out;
}
@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.voice-settings-panel h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}
.voice-settings-section {
  margin-bottom: 16px;
}
.voice-settings-section label {
  display: block;
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.voice-settings-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--on-surface);
  cursor: pointer;
  opacity: 0.6;
}
.voice-settings-close:hover { opacity: 1; }

.voice-model-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--outline-variant, #444);
  border-radius: 8px;
}
.voice-model-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
.voice-model-item:hover { background: rgba(255,255,255,0.06); }
.voice-model-item.selected { background: rgba(var(--primary-rgb, 200,150,100), 0.15); font-weight: 600; }

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
}
.voice-chip {
  padding: 6px 10px;
  border-radius: 16px;
  border: 1px solid var(--outline-variant, #444);
  background: none;
  color: var(--on-surface);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.voice-chip:hover { background: rgba(255,255,255,0.06); }
.voice-chip.selected { border-color: var(--primary); background: rgba(var(--primary-rgb, 200,150,100), 0.12); }

.response-mode-toggle {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--outline-variant, #444);
}
.response-mode-toggle button {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--on-surface);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.response-mode-toggle button:hover { background: rgba(255,255,255,0.06); }
.response-mode-toggle button.selected { background: var(--primary); color: var(--on-primary, #fff); }

/* Profile popup — identity circle click */
.profile-popup-card {
  background: var(--surface-container, #1e1e1e);
  border: 1px solid var(--outline-variant, #444);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.profile-popup-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
}
.profile-popup-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.profile-popup-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--outline-variant, #444);
  background: none;
  color: var(--on-surface);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.profile-popup-link:hover { background: rgba(255,255,255,0.08); }
.profile-popup-link .material-symbols-outlined { font-size: 18px; opacity: 0.7; }

/* ==========================================================================
   Signal collapsed tokens — [IMAGE: ...] etc. in chat messages
   ========================================================================== */
/* Contact photo — circular avatar from Google People API */
.contact-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin: 8px 0;
  border: 2px solid rgba(128,128,128,0.2);
}

.signal-collapsed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(128,128,128,0.15);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  cursor: pointer;
  vertical-align: middle;
  max-width: 100%;
  overflow: hidden;
}
.signal-collapsed .signal-label {
  font-weight: 600;
  opacity: 0.6;
  white-space: nowrap;
}
.signal-collapsed .signal-content {
  display: none;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  opacity: 0.7;
  margin-left: 4px;
}
.signal-collapsed.signal-expanded .signal-content {
  display: inline;
}
.signal-collapsed::after {
  content: '›';
  opacity: 0.4;
  font-size: 13px;
  transition: transform 0.15s;
}
.signal-collapsed.signal-expanded::after {
  transform: rotate(90deg);
}

/* ==========================================================================
   Chat link styling
   ========================================================================== */
.chat-link {
  color: var(--primary, #5b7a3a);
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}
.chat-link:hover {
  text-decoration-style: solid;
}

/* ==========================================================================
   Link cards — compact clickable cards for links in messages
   ========================================================================== */
.link-card {
  display: block;
  margin: 3px 0;
}
.link-card .chat-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(128,128,128,0.12);
  border: 1px solid rgba(128,128,128,0.15);
  border-radius: 8px;
  padding: 6px 12px;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-card .chat-link:hover {
  background: rgba(128,128,128,0.22);
  text-decoration: none;
}
.link-card .chat-link::before {
  content: 'open_in_new';
  font-family: 'Material Symbols Outlined';
  font-size: 16px;
  opacity: 0.5;
}
