<style>
/* Chat preview – pure CSS theme cycler
   Themes (loop every ~3s): Frutiger Aero → Discord → Win95 Classic → Neon Cyber → Soft Pastel
   Dimensions are locked so the rest of the page never shifts. */

.preview-wrap {
  width: 360px;
  height: 290px;
  margin: 0;
  position: relative;
  /* isolate any overflow */
  overflow: hidden;
}

.preview {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 12.5px;
  line-height: 1.35;
  overflow: hidden;
  /* theme variables driven by the keyframes below */
  background: var(--bg);
  color: var(--text) !important;
  border: var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  animation: cycle-themes 5s infinite;
}

/* ── layout (fixed sizes – no theme ever changes these) ── */
.preview-bar {
  height: 32px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: var(--bar-bg);
  color: var(--bar-color);
}

.preview-title {
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--title-color);
}

.tabs-row {
  height: 28px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  background: var(--tabs-bg, var(--bg));
  border-bottom: 1px solid var(--divider, transparent);
}

.ptab {
  padding: 4px 10px;
  border-radius: 4px 4px 0 0;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--tab-color);
  background: var(--tab-bg);
  cursor: default;
  white-space: nowrap;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  border-bottom: 1px solid var(--divider, transparent);
}

.ptab.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-color);
  font-weight: 600;
  border-bottom: none;
}

.preview-body {
  flex: 1;
  display: flex;
  min-height: 0;
  background: var(--chat-bg, var(--bg));
  position: relative;
  z-index: 2;
}

.preview-side {
  width: 98px;
  flex-shrink: 0;
  padding: 10px 8px;
  background: var(--side-bg);
  color: var(--side-color);
  overflow: hidden;
  border-right: 1px solid var(--divider, transparent);
}

.preview-side h4 {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--side-h);
}

.preview-user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 12px;
  color: var(--side-color);
}

.preview-user.on {
  color: var(--text);
  background: var(--bar-bg);
}

.preview-chat {
  flex: 1;
  padding: 10px 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.av.blue   { background: #5865f2; }
.av.purple { background: #9b59b6; }
.av.green  { background: #2ecc71; }

.msg .body {
  min-width: 0;
}

.meta {
  font-size: 11px;
  margin-bottom: 2px;
  color: var(--meta);
}
.meta strong {
  color: var(--text) !important;
  font-weight: 600;
  margin-right: 6px;
}

.text {
  color: var(--text) !important;
  word-break: break-word;
}

.text code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--code-bg);
  color: var(--code-color);
}

/* ── theme keyframes (discrete jumps) ── */
@keyframes cycle-themes {
  /* 1 · Frutiger Aero */
  0%, 19.99% {
    --bg: #d6ecf8;
    --bar-bg: linear-gradient(to bottom, #8ed4f5 0%, #4aa9de 45%, #3b98cf 55%, #5bb8ea 100%);
    --bar-color: #fff;
    --title-color: #fff;
    --tabs-bg: rgba(255,255,255,0.18);
    --tab-bg: transparent;
    --tab-color: #1a5f8c;
    --tab-active-bg: rgba(255,255,255,0.55);
    --tab-active-color: #0d47a1;
    --side-bg: rgba(255,255,255,0.28);
    --side-color: #1565c0;
    --side-h: #0d47a1;
    --chat-bg: transparent;
    --text: #0d3b66;
    --meta: #1976d2;
    --code-bg: rgba(255,255,255,0.55);
    --code-color: #0d47a1;
    --border: 1px solid rgba(255,255,255,0.75);
    --shadow: 0 14px 40px rgba(30,136,229,0.32), inset 0 1px 0 rgba(255,255,255,0.7);
    --radius: 10px;
    --divider: rgba(255,255,255,0.35);
  }

  /* 2 · Discord */
  20%, 39.99% {
    --bg: #313338;
    --bar-bg: #1e1f22;
    --bar-color: #f2f3f5;
    --title-color: #f2f3f5;
    --tabs-bg: #2b2d31;
    --tab-bg: transparent;
    --tab-color: #949ba4;
    --tab-active-bg: #404249;
    --tab-active-color: #fff;
    --side-bg: #2b2d31;
    --side-color: #949ba4;
    --side-h: #b5bac1;
    --chat-bg: #313338;
    --text: #dbdee1;
    --meta: #949ba4;
    --code-bg: #1e1f22;
    --code-color: #dbdee1;
    --border: 1px solid #1e1f22;
    --shadow: 0 10px 28px rgba(0,0,0,0.55);
    --radius: 8px;
    --divider: #1e1f22;
  }

  /* 3 · Windows 95 Classic */
  40%, 59.99% {
    --bg: #c0c0c0;
    --bar-bg: #000080;
    --bar-color: #fff;
    --title-color: #fff;
    --tabs-bg: #c0c0c0;
    --tab-bg: #c0c0c0;
    --tab-color: #000;
    --tab-active-bg: #c0c0c0;
    --tab-active-color: #000;
    --side-bg: #c0c0c0;
    --side-color: #000;
    --side-h: #000080;
    --chat-bg: #c0c0c0;
    --text: #000;
    --meta: #000;
    --code-bg: #fff;
    --code-color: #000;
    --border: 2px solid #808080;
    --shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #808080, 2px 2px 0 #000;
    --radius: 0;
    --divider: #808080;
  }

  /* 4 · Neon Cyberpunk */
  60%, 79.99% {
    --bg: #0a0a12;
    --bar-bg: #12081f;
    --bar-color: #00f5ff;
    --title-color: #00f5ff;
    --tabs-bg: #0f0618;
    --tab-bg: transparent;
    --tab-color: #9080b0;
    --tab-active-bg: rgba(255,0,170,0.18);
    --tab-active-color: #ff00aa;
    --side-bg: #0f0618;
    --side-color: #c0a0d0;
    --side-h: #ff00aa;
    --chat-bg: #0a0a12;
    --text: #e8e0ff;
    --meta: #00f5ff;
    --code-bg: #1a0a2e;
    --code-color: #00f5ff;
    --border: 1px solid #ff00aa;
    --shadow: 0 0 18px rgba(255,0,170,0.4), 0 0 36px rgba(0,245,255,0.18), inset 0 0 40px rgba(255,0,170,0.04);
    --radius: 4px;
    --divider: rgba(255,0,170,0.25);
  }

  /* 5 · Soft Pastel */
  80%, 100% {
    --bg: #fdf8f5;
    --bar-bg: linear-gradient(90deg, #ffd1dc, #e8d5ff);
    --bar-color: #5c4a6e;
    --title-color: #5c4a6e;
    --tabs-bg: #faf0f5;
    --tab-bg: transparent;
    --tab-color: #9a7b9a;
    --tab-active-bg: #ffe8ef;
    --tab-active-color: #c45a7a;
    --side-bg: #faf0f5;
    --side-color: #8a6a8a;
    --side-h: #c45a7a;
    --chat-bg: #fdf8f5;
    --text: #4a3a55;
    --meta: #a07a9a;
    --code-bg: #f5e6f0;
    --code-color: #8a4a6a;
    --border: 1px solid #f0d0e0;
    --shadow: 0 12px 36px rgba(220,150,180,0.28);
    --radius: 14px;
    --divider: #f0d0e0;
  }
}
</style>