/* Gridrunners PWA — Sovereign Dark Grid Workspace */

.keep-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Workspace Top App Bar */
.keep-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: 64px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(9, 13, 20, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 210px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.05rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.keep-search-wrap {
  flex: 1;
  max-width: 680px;
  position: relative;
  display: flex;
  align-items: center;
}

.keep-search-input {
  width: 100%;
  height: 44px;
  padding: 0 2.5rem 0 2.65rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.92rem;
  transition: all 0.15s ease;
}

.keep-search-input:focus {
  outline: none;
  background: var(--bg-elevated);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.14);
}

.keep-search-icon {
  position: absolute;
  left: 0.9rem;
  color: var(--text-muted);
  pointer-events: none;
}

.keep-search-clear {
  position: absolute;
  right: 0.6rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  display: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

@media (max-width: 780px) {
  .topbar-left {
    min-width: auto;
  }
  .hide-mobile {
    display: none !important;
  }
}

/* Workspace Body: Left Rail + Main Board */
.keep-body {
  display: flex;
  flex: 1;
}

.keep-sidebar {
  width: 260px;
  padding: 0.85rem 0.6rem;
  border-right: 1px solid var(--border-subtle);
  background: rgba(11, 16, 25, 0.72);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-shrink: 0;
  transition: width 0.2s ease, transform 0.2s ease;
}

.keep-sidebar.collapsed {
  width: 68px;
}

.keep-sidebar.collapsed .nav-label,
.keep-sidebar.collapsed .sidebar-section-title,
.keep-sidebar.collapsed .sidebar-footer {
  display: none;
}

@media (max-width: 820px) {
  .keep-sidebar {
    position: fixed;
    top: 64px;
    bottom: 0;
    left: 0;
    z-index: 55;
    background: var(--bg-obsidian);
    box-shadow: var(--shadow-card);
  }
  .keep-sidebar.collapsed {
    transform: translateX(-100%);
    width: 260px;
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.68rem 0.95rem;
  border-radius: 0 999px 999px 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.14s ease;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-emerald-dim);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.35);
  font-weight: 600;
}

.nav-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-obsidian);
  color: var(--text-muted);
}

.sidebar-section-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.9rem 0.95rem 0.35rem;
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Main Content Area */
.keep-main {
  flex: 1;
  padding: 1.5rem 2rem 4rem;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 640px) {
  .keep-main {
    padding: 1rem 0.9rem 3rem;
  }
}

/* Invite Redemption Banner (#fragment auto-detected) */
.invite-banner {
  max-width: 680px;
  margin: 0 auto 1.4rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(6, 182, 212, 0.14));
  border: 1px solid var(--accent-emerald);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.invite-banner.visible {
  display: flex;
}

/* Google Keep Quick-Capture Composer Bar */
.keep-composer {
  max-width: 640px;
  margin: 0 auto 2.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.keep-composer:focus-within {
  border-color: var(--accent-cyan);
}

.composer-top-row {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem 0.2rem;
  gap: 0.5rem;
}

.composer-collapsed-only {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  cursor: text;
  color: var(--text-secondary);
}

.keep-composer.expanded .composer-collapsed-only {
  display: none;
}

.composer-expanded-body {
  display: none;
}

.keep-composer.expanded .composer-expanded-body {
  display: block;
}

.composer-title-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.02rem;
  font-weight: 600;
  padding: 0.3rem 0;
}

.composer-title-input:focus {
  outline: none;
}

.composer-stream-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  flex-wrap: wrap;
}

.composer-select {
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
}

.composer-textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.93rem;
  padding: 0.55rem 1rem;
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}

.composer-textarea:focus {
  outline: none;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(9, 13, 20, 0.45);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.color-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.color-dot:hover,
.color-dot.selected {
  transform: scale(1.18);
  border-color: #ffffff;
}

.color-dot.obsidian { background: #141c2b; }
.color-dot.emerald  { background: #0d3b2e; }
.color-dot.cyan     { background: #0c3547; }
.color-dot.amber    { background: #422c09; }
.color-dot.violet   { background: #2e1d4a; }
.color-dot.crimson  { background: #45151b; }

/* Keep Board Section Labels ("PINNED", "OTHERS") */
.board-section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0.25rem;
}

/* Keep Card Grid (Masonry-style responsive grid + single-column list mode) */
.keep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 1rem;
  margin-bottom: 2.25rem;
  align-items: start;
}

.keep-grid.list-view {
  grid-template-columns: 1fr;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

/* Individual Keep Card */
.keep-card {
  position: relative;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 1rem 1.05rem 0.8rem;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.keep-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
}

/* Keep Card Color Themes */
.keep-card.theme-obsidian {
  background: var(--bg-surface);
}
.keep-card.theme-emerald {
  background: linear-gradient(165deg, rgba(16, 185, 129, 0.15), #0f1b1d 85%);
  border-color: rgba(16, 185, 129, 0.35);
}
.keep-card.theme-cyan {
  background: linear-gradient(165deg, rgba(6, 182, 212, 0.15), #0f1924 85%);
  border-color: rgba(6, 182, 212, 0.35);
}
.keep-card.theme-amber {
  background: linear-gradient(165deg, rgba(245, 158, 11, 0.15), #1c1812 85%);
  border-color: rgba(245, 158, 11, 0.35);
}
.keep-card.theme-violet {
  background: linear-gradient(165deg, rgba(139, 92, 246, 0.16), #171426 85%);
  border-color: rgba(139, 92, 246, 0.38);
}
.keep-card.theme-crimson {
  background: linear-gradient(165deg, rgba(239, 68, 68, 0.15), #211317 85%);
  border-color: rgba(239, 68, 68, 0.38);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-kind-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
  background: rgba(9, 13, 20, 0.65);
  border: 1px solid var(--border-subtle);
  color: var(--accent-cyan);
}

.card-kind-badge.wall {
  color: var(--accent-emerald);
}
.card-kind-badge.doc {
  color: var(--accent-cyan);
}
.card-kind-badge.room {
  color: var(--accent-amber);
}

.card-pin-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.15rem 0.3rem;
  border-radius: 6px;
  opacity: 0.65;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.keep-card:hover .card-pin-btn,
.card-pin-btn.pinned {
  opacity: 1;
}

.card-pin-btn.pinned {
  color: var(--accent-emerald);
}

.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.card-content {
  margin: 0;
  font-size: 0.89rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Interactive Keep Checklist inside Cards */
.keep-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

.keep-checklist li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.keep-checklist li.done span {
  text-decoration: line-through;
  color: var(--text-muted);
}

.keep-checklist input[type="checkbox"] {
  accent-color: var(--accent-emerald);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Room Message Mini-Feed inside Room Cards */
.room-mini-log {
  background: rgba(9, 13, 20, 0.55);
  border: 1px solid rgba(35, 48, 71, 0.7);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.room-msg-line {
  display: flex;
  gap: 0.4rem;
  line-height: 1.35;
}

.room-msg-author {
  font-family: var(--font-mono);
  color: var(--accent-emerald);
  font-weight: 600;
  flex-shrink: 0;
}

.card-meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.meta-chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.12rem 0.45rem;
  border-radius: 5px;
  background: rgba(9, 13, 20, 0.65);
  border: 1px solid rgba(50, 69, 101, 0.5);
  color: var(--text-secondary);
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(35, 48, 71, 0.55);
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

.keep-card:hover .card-actions {
  opacity: 1;
}

.card-action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.card-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Identity, Shamir & Switchboard Panel */
.identity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

@media (max-width: 480px) {
  .identity-grid {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.panel-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mono-field {
  width: 100%;
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.55rem;
}

/* Keep Modal Overlay for Card Editing & Wire Inspection */
.keep-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 7, 12, 0.78);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.keep-modal-backdrop.open {
  display: flex;
}

.keep-modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.wire-inspector-box {
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-secondary);
  overflow-x: auto;
}

/* Card Collapse (_ / +) and Encrypted Attachments */
.card-header-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.card-collapse-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.card-collapse-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

.card-collapsible-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.keep-card.collapsed .card-collapsible-body {
  display: none;
}

.keep-card.drag-over {
  border-color: var(--accent-emerald) !important;
  box-shadow: 0 0 0 2px var(--accent-emerald), var(--shadow-card);
}

.keep-card[draggable="true"] {
  cursor: grab;
  user-select: none;
}

.keep-card[draggable="true"]:active {
  cursor: grabbing;
}

.card-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1;
  cursor: grab;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  transition: color 0.14s ease, background 0.14s ease;
}

.keep-card:hover .card-drag-handle {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.keep-card.dragging {
  opacity: 0.48;
  transform: scale(0.97);
  border-style: dashed !important;
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.keep-card.drop-before {
  border-top: 3px solid var(--accent-emerald) !important;
  box-shadow: 0 -4px 14px rgba(16, 185, 129, 0.35), var(--shadow-card);
}

.keep-card.drop-after {
  border-bottom: 3px solid var(--accent-emerald) !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35), var(--shadow-card);
}

.card-attachments {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.attachment-thumb {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.attachment-chip button {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0 0.2rem;
}

.attachment-chip button:hover {
  text-decoration: underline;
}

.composer-attachments-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.2rem 1rem 0.45rem;
}

/* Browser Setup & Vault Persistence Guard */
.perms-banner {
  max-width: 680px;
  margin: 0 auto 1.25rem;
  padding: 0.9rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  display: none;
  flex-direction: column;
  gap: 0.65rem;
}

.perms-banner.visible {
  display: flex;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.55rem;
}

.perm-item {
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.perm-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.perm-badge {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  text-transform: uppercase;
  border: 1px solid var(--border-subtle);
}

.perm-badge.granted {
  color: var(--accent-emerald);
  background: var(--accent-emerald-dim);
  border-color: rgba(16, 185, 129, 0.35);
}

.perm-badge.prompt {
  color: var(--accent-amber);
  background: var(--accent-amber-dim);
}

.perm-badge.denied {
  color: var(--accent-crimson);
}

/* Light Theme Adjustments for Keep Workspace */
[data-theme="light"] .keep-topbar {
  background: rgba(244, 246, 250, 0.92);
}

[data-theme="light"] .keep-sidebar {
  background: rgba(255, 255, 255, 0.88);
}

[data-theme="light"] .composer-footer {
  background: var(--bg-elevated);
}

[data-theme="light"] .keep-card.theme-emerald {
  background: linear-gradient(165deg, rgba(16, 185, 129, 0.14), #ffffff 88%);
}
[data-theme="light"] .keep-card.theme-cyan {
  background: linear-gradient(165deg, rgba(6, 182, 212, 0.14), #ffffff 88%);
}
[data-theme="light"] .keep-card.theme-amber {
  background: linear-gradient(165deg, rgba(245, 158, 11, 0.14), #ffffff 88%);
}
[data-theme="light"] .keep-card.theme-violet {
  background: linear-gradient(165deg, rgba(139, 92, 246, 0.14), #ffffff 88%);
}
[data-theme="light"] .keep-card.theme-crimson {
  background: linear-gradient(165deg, rgba(239, 68, 68, 0.14), #ffffff 88%);
}

[data-theme="light"] .card-kind-badge,
[data-theme="light"] .meta-chip,
[data-theme="light"] .room-mini-log {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}

[data-theme="light"] .card-action-btn:hover {
  background: var(--bg-hover);
}

/* --- Markdown & Emoji Toolbar, Picker, Rendered Typography & Card Reactions --- */
.md-toolbar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 1rem;
  border-top: 1px solid rgba(50, 69, 101, 0.35);
  border-bottom: 1px solid rgba(50, 69, 101, 0.35);
  background: rgba(9, 13, 20, 0.32);
  flex-wrap: wrap;
}

#modal-md-toolbar {
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
}

.md-tool-btn {
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.48rem;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1.25;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.md-tool-btn:hover,
.md-tool-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

.emoji-picker-popover {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.45rem 0.75rem;
  background: var(--bg-obsidian);
  border-bottom: 1px solid var(--border-subtle);
  max-height: 136px;
  overflow-y: auto;
}

.emoji-picker-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 1.08rem;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease;
}

.emoji-picker-btn:hover {
  transform: scale(1.18);
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}

.md-rendered {
  white-space: normal;
  line-height: 1.5;
  font-size: 0.89rem;
  color: var(--text-secondary);
}

.md-rendered .md-p {
  margin: 0 0 0.5rem;
}
.md-rendered .md-p:last-child {
  margin-bottom: 0;
}

.md-rendered .md-h {
  margin: 0.45rem 0 0.3rem;
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
}
.md-rendered .md-h1 { font-size: 1.15rem; }
.md-rendered .md-h2 { font-size: 1.05rem; }
.md-rendered .md-h3 { font-size: 0.96rem; }
.md-rendered .md-h4,
.md-rendered .md-h5,
.md-rendered .md-h6 { font-size: 0.89rem; }

.md-rendered .md-inline-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(9, 13, 20, 0.72);
  border: 1px solid rgba(50, 69, 101, 0.55);
  color: var(--accent-cyan);
}

.md-rendered .md-code-block {
  position: relative;
  margin: 0.45rem 0;
  padding: 0.6rem 0.75rem;
  border-radius: 7px;
  background: rgba(9, 13, 20, 0.82);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-primary);
  overflow-x: auto;
  white-space: pre;
}

.md-rendered .md-code-lang {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 0.64rem;
  color: var(--accent-emerald);
  text-transform: uppercase;
}

.md-rendered .md-quote {
  margin: 0.4rem 0;
  padding: 0.3rem 0.7rem;
  border-left: 3px solid var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  border-radius: 0 5px 5px 0;
  color: var(--text-primary);
}

.md-rendered .md-list {
  margin: 0.35rem 0 0.5rem 1.2rem;
  padding: 0;
}

.md-rendered .md-task-item {
  list-style: none;
  margin-left: -1.1rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.md-rendered .md-task-item.done span {
  text-decoration: line-through;
  color: var(--text-muted);
}

.md-rendered .md-link {
  color: var(--accent-cyan);
  text-decoration: underline;
}

.md-rendered .md-mark {
  background: rgba(245, 158, 11, 0.28);
  color: var(--text-primary);
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.md-rendered .md-hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 0.55rem 0;
}

.md-rendered .md-table-wrap {
  overflow-x: auto;
  margin: 0.45rem 0;
}

.md-rendered .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.md-rendered .md-table th,
.md-rendered .md-table td {
  border: 1px solid var(--border-subtle);
  padding: 0.28rem 0.5rem;
  text-align: left;
}

.md-rendered .md-table th {
  background: rgba(9, 13, 20, 0.65);
  color: var(--text-primary);
}

.card-reactions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(9, 13, 20, 0.6);
  border: 1px solid rgba(50, 69, 101, 0.55);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.12s ease, background 0.12s ease;
}

.reaction-chip:hover,
.reaction-chip.active {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.15);
  color: var(--text-primary);
}

/* --- WebRTC Watch Party Theater & Floating Emoji Overlay --- */
.watch-theater-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr);
  gap: 1.15rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .watch-theater-grid {
    grid-template-columns: 1fr;
  }
}

.watch-stage-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.watch-video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #04070c;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.watch-video-container:fullscreen,
.watch-video-container:-webkit-full-screen,
.watch-video-container.watch-fullscreen-active,
.modal-call-stage:fullscreen,
.modal-call-stage:-webkit-full-screen,
.modal-call-stage.watch-fullscreen-active {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  border: none !important;
  border-radius: 0 !important;
  background: #000 !important;
  z-index: 9999 !important;
}

.watch-stage-fs-btn {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 7;
  padding: 0.34rem 0.68rem;
  font-size: 0.75rem;
  border-radius: 7px;
  background: rgba(9, 13, 20, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f8fafc;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.watch-stage-fs-btn:hover {
  background: rgba(15, 23, 42, 0.92);
  border-color: var(--accent-cyan);
}

#watch-party-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.watch-emoji-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

@keyframes watchFloatEmoji {
  0% {
    transform: translateY(0) scale(0.75);
    opacity: 0;
  }
  15% {
    transform: translateY(-24px) scale(1.15);
    opacity: 1;
  }
  80% {
    opacity: 0.92;
  }
  100% {
    transform: translateY(-210px) scale(1.3);
    opacity: 0;
  }
}

.floating-emoji-bubble {
  position: absolute;
  bottom: 18px;
  font-size: 1.85rem;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.65));
  animation: watchFloatEmoji 2.3s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

.watch-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.watch-reaction-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.watch-reaction-bar .reaction-chip {
  font-size: 0.92rem;
  padding: 0.22rem 0.52rem;
}

.watch-chat-card {
  display: flex;
  flex-direction: column;
  min-height: 360px;
  max-height: 540px;
}

.watch-chat-log {
  flex: 1;
  overflow-y: auto;
  background: rgba(9, 13, 20, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.65rem;
  margin-bottom: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.83rem;
}

/* Modal Live Stream Chat & Voice / Video Call Lounge */
.modal-live-chat-panel {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(9, 13, 20, 0.5);
}

.modal-av-call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.modal-call-join-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.modal-call-stage {
  position: relative;
  width: 100%;
  min-height: 190px;
  max-height: 290px;
  aspect-ratio: 16 / 9;
  background: #04070c;
  border: 1px solid var(--accent-cyan);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

#modal-local-video {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 124px;
  height: 74px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--accent-emerald);
  background: #080d16;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.65);
  z-index: 2;
}

.modal-chat-log {
  min-height: 115px;
  max-height: 195px;
  margin-bottom: 0;
}

/* --- Sandboxed MiniApp Cards & Cooklang Summary Preview --- */
.card-kind-badge.miniapp {
  color: #e9d5ff;
  border-color: rgba(168, 85, 247, 0.55);
  background: rgba(168, 85, 247, 0.16);
}

.keep-card.miniapp-card {
  border-color: rgba(168, 85, 247, 0.52);
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.18), var(--shadow-card);
}

.keep-card.miniapp-card:hover {
  border-color: #a855f7;
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.45), var(--shadow-card);
}

.miniapp-grid-summary {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.5rem 0.65rem;
  border-radius: 7px;
  background: rgba(11, 15, 23, 0.62);
  border: 1px solid rgba(168, 85, 247, 0.32);
}

.miniapp-summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}

.miniapp-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.14rem 0.42rem;
  border-radius: 4px;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.miniapp-pill.tweak {
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.12);
}

.miniapp-ing-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.miniapp-ing-chip {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.miniapp-launch-hint {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #e9d5ff;
  padding-top: 0.15rem;
}
