/* Teams Chat Exporter — interactive demo.
   Single stylesheet, isolated from the landing page via iframe.
   Tokens derived from teams.microsoft.com/v2 (dark mode) and the
   real popup's Svelte styles. */

:root {
  /* Teams dark tokens (default). Light tokens follow when
     html|body[data-theme="light"]. */
  --bg:        #141414;
  --bg-soft:   #1a1a1a;
  --bg-hover:  #1f1f1f;
  --bg-active: #292929;
  --bg-bubble: #292929;
  --bg-rail:   #1b1b1b;
  --bg-card:   #2a2a2a;
  --text:      #ffffff;
  --text-2:    #d6d6d6;
  --text-3:    #adadad;
  --text-4:    #8e8e8e;
  --stroke:    #2e2e2e;
  --stroke-2:  #3a3a3a;
  --brand:     #5b5fc7;
  --brand-2:   #7b8ee8;
  --brand-bg:  rgba(91, 95, 199, 0.18);
  --urgent:    #d13438;
  --link:      #93b1ff;
  --green:     #6ccb5f;
  --yellow:    #ffbf3c;
  --hover-overlay: rgba(255, 255, 255, 0.06);
  --hover-overlay-strong: rgba(255, 255, 255, 0.10);
  --divider-stroke: rgba(255, 255, 255, 0.08);

  --rail-w:    68px;
  --list-w:    340px;
  --titlebar-h: 48px;
  --header-h:  56px;
  --composer-h: 78px;

  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple Color Emoji",
               "Segoe UI Emoji", "Segoe UI Symbol", system-ui, sans-serif;

  --radius:    8px;
  --radius-lg: 12px;

  --shadow-pop: 0 12px 36px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35),
                0 0 0 1px var(--hover-overlay);
}

/* Teams light-theme tokens (pulled from teams.microsoft.com/v2/ in
   light mode: body bg #f5f5f5, text #242424, secondary #616161). */
body.theme-light, body[data-theme="light"], :root[data-theme="light"] {
  --bg:        #f5f5f5;
  --bg-soft:   #ebebeb;
  --bg-hover:  #ededed;
  --bg-active: #e1e1e1;
  --bg-bubble: transparent;
  --bg-rail:   #f5f5f5;
  --bg-card:   #ffffff;
  --text:      #242424;
  --text-2:    #424242;
  --text-3:    #616161;
  --text-4:    #8a8a8a;
  --stroke:    #e1e1e1;
  --stroke-2:  #c7c7c7;
  --brand:     #5b5fc7;
  --brand-2:   #4f52b2;
  --brand-bg:  rgba(91, 95, 199, 0.12);
  --urgent:    #c4314b;
  --link:      #2557d6;
  --green:     #13a10e;
  --yellow:    #f7630c;
  --hover-overlay: rgba(0, 0, 0, 0.05);
  --hover-overlay-strong: rgba(0, 0, 0, 0.10);
  --divider-stroke: rgba(0, 0, 0, 0.10);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08),
                0 0 0 1px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%; width: 100%;
  background: #050505;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px; line-height: 1.43;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Shell — fills the iframe viewport, no scroll */
.demo-shell {
  position: relative;
  width: 100%; height: 100vh;
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: hidden;
  isolation: isolate;
}

/* ───── Teams clone ────────────────────────────────────────────────── */

.teams {
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
}

/* Title bar */
.titlebar {
  display: flex; align-items: center; gap: 8px;
  height: var(--titlebar-h); min-height: var(--titlebar-h);
  padding: 0 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--stroke);
  position: relative; z-index: 5;
}
.tb-left { display: flex; gap: 4px; }
.tb-icon {
  width: 32px; height: 32px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.tb-icon:hover { background: var(--bg-hover); }
.tb-search {
  flex: 1 1 auto;
  max-width: 760px;
  height: 32px;
  background: var(--hover-overlay);
  border-radius: 4px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  margin: 0 16px;
  color: var(--text-3);
}
.tb-search input {
  flex: 1; height: 100%; background: transparent; border: 0; outline: 0;
  color: var(--text-3); font-size: 13px;
}
.tb-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.tb-extension {
  position: relative;
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
  background: var(--brand-bg);
  border: 1px solid var(--brand-2);
  transition: background 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}
.tb-extension img { width: 22px; height: 22px; border-radius: 6px; }
.tb-extension:hover {
  background: var(--brand-bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(91, 95, 199, 0.35);
}
.tb-extension.pulsing {
  animation: ext-bounce 1.8s ease-in-out infinite;
}
.tb-extension.pulsing::after {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 12px;
  border: 2px solid var(--brand);
  animation: ext-pulse 1.4s ease-out infinite;
  pointer-events: none;
}
.tb-extension.pulsing::before {
  content: '';
  position: absolute; inset: -8px;
  border-radius: 14px;
  background: radial-gradient(circle, rgba(91, 95, 199, 0.20) 0%, transparent 70%);
  animation: ext-glow 1.4s ease-out infinite;
  pointer-events: none;
}
@keyframes ext-pulse {
  0%   { transform: scale(0.96); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes ext-glow {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.1); }
}
@keyframes ext-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}
.ext-pulse { display: none; }

.tb-avatar {
  position: relative; width: 32px; height: 32px;
  background: transparent;
  flex-shrink: 0;
}
.tb-avatar img {
  width: 100%; height: 100%;
  border-radius: 50%;
  display: block;
  background: var(--bg-card);
}
.presence {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px;
  background: var(--green);
  border: 2px solid var(--bg);
  border-radius: 50%;
  z-index: 2;
}

/* Layout — 3 columns */
.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: var(--rail-w) var(--list-w) 1fr;
}

/* App rail (left) */
.app-rail {
  background: var(--bg);
  padding: 8px 0; gap: 4px;
  display: flex; flex-direction: column; align-items: center;
  border-right: 1px solid var(--stroke);
  overflow: hidden;
}
.rail-btn {
  width: 56px; height: 56px;
  border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--text-2);
  font-size: 10px; font-weight: 400;
  position: relative;
}
.rail-btn svg { color: var(--text-2); width: 22px; height: 22px; }
.rail-btn span { font-size: 10px; line-height: 1.1; color: var(--text-2); margin-top: 2px; }
.rail-btn:hover { background: var(--hover-overlay); color: var(--text); }
.rail-btn:hover svg, .rail-btn:hover span { color: var(--text); }
.rail-btn.rail-current { color: var(--text); }
.rail-btn.rail-current svg, .rail-btn.rail-current span { color: var(--text); font-weight: 600; }
.rail-btn.rail-current::before {
  content: ''; position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 3px; background: var(--brand-2); border-radius: 0 3px 3px 0;
}
.rail-btn .badge {
  position: absolute; top: 4px; right: 8px;
  min-width: 14px; height: 14px; padding: 0 4px;
  background: var(--urgent); color: white;
  border-radius: 7px; font-size: 10px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--bg);
}
.rail-sep { height: 1px; width: 40px; background: var(--divider-stroke); margin: 6px 0; }

/* Chat list rail */
.chat-list {
  background: var(--bg);
  border-right: 1px solid var(--stroke);
  display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.cl-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 6px;
}
.cl-header h1 { font-size: 18px; font-weight: 600; letter-spacing: 0; margin: 0; }
.cl-actions { display: flex; gap: 4px; }
.cl-actions button { width: 28px; height: 28px; color: var(--text-3); border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; }
.cl-actions button:hover { background: var(--bg-hover); color: var(--text); }

.cl-tabs {
  display: flex; gap: 4px;
  padding: 4px 12px 8px;
  overflow-x: auto;
}
.cl-tab {
  padding: 3px 9px;
  font-size: 12px; font-weight: 400;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  color: var(--text-2);
  white-space: nowrap;
  background: transparent;
}
.cl-tab:hover { background: var(--hover-overlay); color: var(--text); }
.cl-tab.cl-tab-active { background: var(--bg-active); border-color: var(--bg-active); color: var(--text); }

.cl-scroll {
  flex: 1 1 0; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 4px 12px;
}
.cl-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.cl-scroll::-webkit-scrollbar-thumb { background: var(--hover-overlay-strong); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
.cl-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); background-clip: content-box; border: 2px solid transparent; }

.cl-folder { padding: 6px 12px 2px; margin-top: 6px; }
.cl-folder-header {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  color: var(--text-2); letter-spacing: 0;
  padding: 4px 4px;
  border-radius: 4px;
  width: 100%;
  text-align: left;
}
.cl-folder-header svg { color: var(--text-3); transition: transform 150ms ease; }
.cl-folder-header:hover { background: var(--hover-overlay); color: var(--text); }

.cl-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px; align-items: center;
  padding: 4px 12px;
  margin: 0;
  border-radius: 4px;
  text-decoration: none; color: inherit;
  position: relative;
  min-height: 36px;
}
.cl-row:hover { background: var(--hover-overlay); }
.cl-row.cl-selected { background: var(--bg-active); }
.cl-row.cl-selected::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; background: var(--brand-2); border-radius: 0 3px 3px 0;
}
.cl-avatar {
  width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  background: var(--bg-card);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cl-avatar img { width: 100%; height: 100%; }
.cl-avatar.cl-group { color: white; font-weight: 600; font-size: 12px; letter-spacing: -0.02em; }
.cl-text { min-width: 0; }
.cl-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px;
}
.cl-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cl-time { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.cl-preview {
  font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cl-preview .cl-from { color: var(--text-2); font-weight: 500; }
.cl-unread {
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--brand); color: white;
  border-radius: 9px; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Chat pane */
.chat-pane {
  display: flex; flex-direction: column;
  background: var(--bg);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.cp-header {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  height: 48px; min-height: 48px;
  border-bottom: 1px solid var(--stroke);
}
.cp-title { display: flex; align-items: center; gap: 8px; }
.cp-chat-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 11px;
  flex-shrink: 0;
}
.cp-chat-avatar img { width: 100%; height: 100%; border-radius: 50%; }
.cp-title h2 { font-size: 14px; font-weight: 600; margin: 0; line-height: 1.2; }
.cp-subtitle { font-size: 11px; color: var(--text-3); display: none; }
.cp-tabs { display: flex; gap: 2px; margin-left: 12px; align-items: center; height: 100%; }
.cp-tab {
  padding: 0 10px;
  font-size: 13px; color: var(--text-2);
  border-radius: 0;
  position: relative;
  height: 100%;
  display: inline-flex; align-items: center;
}
.cp-tab:hover { color: var(--text); }
.cp-tab.cp-tab-active { color: var(--text); font-weight: 600; }
.cp-tab.cp-tab-active::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: 0;
  height: 2px; background: var(--brand-2);
  border-radius: 1px;
}
.cp-actions { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.cp-meet {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px; font-size: 13px; font-weight: 600;
  background: transparent;
  border-radius: 4px;
  color: var(--text);
}
.cp-meet svg { color: var(--text); }
.cp-meet:hover { background: var(--hover-overlay); }
.cp-icon {
  width: 32px; height: 32px; border-radius: 4px;
  color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.cp-icon:hover { background: var(--hover-overlay); color: var(--text); }

/* Messages */
.cp-messages {
  flex: 1 1 0; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 28px 8px;
  scroll-behavior: smooth;
}
.cp-messages::-webkit-scrollbar { width: 10px; height: 10px; }
.cp-messages::-webkit-scrollbar-thumb { background: var(--hover-overlay-strong); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
.cp-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); background-clip: content-box; border: 2px solid transparent; }

.day-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0;
  font-size: 12px; color: var(--text-3); font-weight: 600;
}
.day-divider::before, .day-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--divider-stroke);
}

.msg {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  margin: 6px 0;
  padding: 4px 0;
  border-radius: 4px;
}
.msg.msg-stacked {
  /* same author chains: hide avatar, tighten spacing */
  grid-template-columns: 36px 1fr;
  margin-top: 0; padding-top: 0;
}
.msg.msg-stacked .msg-avatar { visibility: hidden; }
.msg.msg-stacked .msg-author-line { display: none; }
.msg:hover { background: var(--bg-soft); }
.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; overflow: hidden;
  background: var(--bg-card);
  margin-top: 2px;
  flex-shrink: 0;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-content { min-width: 0; }
.msg-author-line {
  display: flex; align-items: baseline; gap: 8px;
  margin: 0 0 2px;
}
.msg-author { font-size: 14px; font-weight: 600; color: var(--text); }
.msg-ts { font-size: 12px; color: var(--text-3); font-weight: 400; }
.msg-urgent {
  display: inline-block; padding: 1px 6px;
  background: var(--urgent); color: white;
  border-radius: 3px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.msg-body {
  background: var(--bg-bubble);
  border-radius: 6px;
  padding: 6px 12px 8px;
  margin: 0 0 4px;
  font-size: 14px; line-height: 20px;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  width: fit-content;
}
/* In light mode Teams shows no message background; just floating text. */
body[data-theme="light"] .msg-body,
:root[data-theme="light"] .msg-body {
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.msg-body a { color: var(--link); text-decoration: underline; }
.msg-body .mention { color: var(--brand-2); font-weight: 500; }
.msg-body p { margin: 0; }
.msg-body p + p { margin-top: 6px; }

/* Reply quote */
.msg-reply {
  display: flex; align-items: stretch;
  margin: 2px 0 6px;
  background: var(--hover-overlay);
  border-radius: 4px;
  overflow: hidden;
  max-width: 480px;
}
.msg-reply-bar { width: 3px; background: var(--brand-2); }
.msg-reply-body {
  padding: 6px 10px;
  font-size: 12px;
  flex: 1; min-width: 0;
}
.msg-reply-author { font-weight: 600; color: var(--brand-2); }
.msg-reply-text { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Forwarded block */
.msg-forwarded {
  margin: 4px 0;
  border-left: 3px solid var(--text-3);
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
}
.msg-forwarded-label {
  font-size: 11px; color: var(--text-3); font-weight: 600;
  margin-bottom: 4px;
}
.msg-forwarded-text { font-size: 13px; color: var(--text-2); }

/* Attachments */
.msg-attachments {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 6px 0 2px;
}
.msg-att-image {
  max-width: 360px; max-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  overflow: hidden;
}
.msg-att-image img { width: 100%; height: auto; display: block; }
.msg-att-file {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--stroke);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.msg-att-file-icon {
  width: 28px; height: 28px; border-radius: 4px;
  background: var(--brand-bg); color: var(--brand-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.msg-att-file-meta { display: flex; flex-direction: column; }
.msg-att-file-name { color: var(--text); }
.msg-att-file-size { color: var(--text-3); font-size: 11px; }

/* Reactions: Teams uses small pill chips with the emoji + a tiny count.
   Real height 22px, slightly translucent bg, rounder pill. The chips
   sit attached to the bottom of the bubble, pulled up slightly. */
.msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin: -8px 0 6px 8px;
  position: relative;
  z-index: 1;
}
.msg-reaction {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px 0 6px;
  background: var(--bg-soft);
  border: 1px solid var(--stroke);
  border-radius: 11px;
  font-size: 11px; font-weight: 600;
  color: var(--text-2);
  font-variant-emoji: emoji;
  transition: background 100ms ease, border-color 100ms ease;
  cursor: default;
  line-height: 1;
}
.msg-reaction:hover { background: var(--hover-overlay); border-color: var(--stroke-2); }
.msg-reaction-emoji {
  font-size: 14px;
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", system-ui, sans-serif;
}

/* System messages */
.msg-system {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  font-style: italic;
  padding: 6px 0;
}

/* Composer */
.cp-composer {
  padding: 12px 16px 16px;
}
.composer-shell {
  background: var(--bg-soft);
  border: 1px solid var(--stroke);
  border-radius: 4px;
  display: flex; flex-direction: column;
  transition: border-color 150ms ease;
}
.composer-shell:focus-within { border-color: var(--brand-2); }
.composer-input {
  min-height: 44px;
  padding: 12px 16px;
  color: var(--text-3); font-size: 14px;
}
.composer-tools {
  display: flex; align-items: center; gap: 0;
  padding: 4px 8px;
}
.composer-spacer { flex: 1; }
.composer-tools button {
  width: 32px; height: 32px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: background 100ms ease, color 100ms ease;
}
.composer-tools button:hover { background: var(--hover-overlay); color: var(--text); }
.composer-tools button.send { color: var(--brand-2); margin-left: 4px; }
.composer-tools button.send:hover { background: var(--brand-bg); color: var(--brand-2); }

/* ───── Extension popup ───────────────────────────────────────────── */
/* The popup is loaded as an iframe pointing at /popup-embed/popup.html,
   which serves the actual built Svelte popup from the extension with a
   small chrome.* shim. Identical visuals + working picker / format
   chips / settings / history pages. */

.popup {
  position: absolute;
  top: 56px; right: 16px;
  width: 420px;
  height: 640px;
  max-height: calc(100% - 80px);
  border-radius: 12px;
  /* Match the popup body bg so any sub-pixel seam is invisible. The
     popup's body uses --color-bg from popup.css = #f8fafc. */
  background: #f8fafc;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  /* Isolate so the iframe's own backing can never bleed beyond the
     rounded corner. */
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  transform-origin: 95% 0%;
  transform: translateY(-12px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms ease-out;
  z-index: 30;
}
.popup[data-open="true"] { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }
.popup iframe {
  position: absolute;
  /* Inset slightly negative so the iframe overshoots the wrapper edges
     by 1 px in every direction. overflow:hidden + border-radius on the
     parent crops it cleanly and any anti-alias gap disappears. */
  top: -1px; left: -1px; right: -1px; bottom: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  border: 0;
  border-radius: 0;
  background: transparent;
  display: block;
}
:root[data-theme="dark"] .popup,
body[data-theme="dark"] .popup {
  background: #0f172a;
}

/* ───── Tour controls ──────────────────────────────────────────────── */

.tour-controls {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 40;
  pointer-events: none;
}
/* The hidden attribute must trump display rules below. */
[hidden] { display: none !important; }
.tour-pip {
  display: inline-flex; align-items: center; gap: 12px;
  background: #2563eb;
  border: 1px solid var(--hover-overlay-strong);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600; color: #ffffff;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.45), 0 2px 6px rgba(0,0,0,0.35);
  pointer-events: auto;
  letter-spacing: 0.01em;
}
.tour-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  animation: tour-dot 1.4s ease-out infinite;
}
@keyframes tour-dot {
  0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6); }
  100% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
}
.tour-pip-hint { color: rgba(255, 255, 255, 0.85); font-weight: 500; }
.tour-replay {
  display: inline-flex; align-items: center; gap: 8px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  color: #2563eb;
  box-shadow: 0 10px 28px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.2);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.tour-replay:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(0,0,0,0.4), 0 4px 8px rgba(0,0,0,0.2);
}
.tour-replay svg { stroke: currentColor; fill: none; stroke-width: 2; }

.caption {
  position: absolute; bottom: 72px; left: 50%; transform: translateX(-50%);
  min-width: 320px; max-width: 580px;
  text-align: center;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 14px; font-weight: 500;
  line-height: 1.45;
  box-shadow:
    0 18px 36px -8px rgba(0,0,0,0.55),
    0 8px 16px -8px rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
  z-index: 35;
}
.caption.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.caption strong {
  display: block; color: #2563eb; font-weight: 700;
  margin-bottom: 2px;
  letter-spacing: -0.005em;
}
/* Caption arrow pointing down to the pip */
.caption::after {
  content: '';
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  width: 14px; height: 14px;
  background: #ffffff;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  transform: translateX(-50%) rotate(45deg);
}

/* Step highlight rings for autoplay */
#tourHighlight {
  position: fixed;
  pointer-events: none;
  border: 2px solid #2563eb;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.10);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.0), 0 8px 24px rgba(37, 99, 235, 0.35);
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 220ms ease, transform 220ms ease, top 240ms ease, left 240ms ease, width 240ms ease, height 240ms ease;
  z-index: 38;
}
#tourHighlight.show {
  opacity: 1;
  transform: scale(1);
  animation: tourPulse 1.6s ease-in-out infinite;
}
@keyframes tourPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45), 0 8px 24px rgba(37, 99, 235, 0.35); }
  50%      { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.18), 0 8px 24px rgba(37, 99, 235, 0.35); }
}

/* ───── Mobile (under 900px) ───────────────────────────────────────── */

@media (max-width: 900px) {
  :root { --list-w: 0; --rail-w: 0; }
  .titlebar { height: 44px; min-height: 44px; padding: 0 8px; }
  .tb-search { display: none; }
  .tb-extension { width: 36px; height: 36px; }
  .layout { grid-template-columns: 1fr; }
  .app-rail, .chat-list { display: none; }
  .cp-header { padding: 0 12px; }
  .cp-tabs, .cp-actions { display: none; }
  .cp-messages { padding: 8px 12px 12px; }
  .msg { padding: 4px; grid-template-columns: 28px 1fr; gap: 8px; }
  .msg-avatar { width: 24px; height: 24px; }
  .msg-body { padding: 5px 10px 7px; font-size: 14px; }
  .msg-att-image { max-width: 280px; }

  .popup {
    position: fixed;
    top: auto; left: 8px; right: 8px;
    bottom: 0;
    width: auto; max-width: none;
    max-height: 76vh;
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
    transform-origin: 50% 100%;
  }
  .popup[data-open="true"] {
    transform: translateY(0);
  }
  .pp-export-icon { width: 28px; height: 28px; }
  .pp-format-grid { grid-template-columns: repeat(5, 1fr); }
  .pp-two-col { grid-template-columns: 1fr; }

  .tour-pip-hint { display: none; }
  /* Caption sits above the bottom sheet, just under the chat header. */
  .caption {
    min-width: auto; max-width: calc(100vw - 24px);
    font-size: 12px; padding: 8px 14px;
    top: 108px; bottom: auto;
    line-height: 1.4;
  }
  .tour-controls { bottom: 12px; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
