/* ==========================================================================
   cns.im — Premium layer (applies on top of every style)
     1. Chat wallpapers (html[data-wallpaper="on"])
     2. Light & texture: film grain, top-edge highlight on raised panels
     3. Custom accent (html[data-accent], --ah = hue) — OKLCH, readable in light and dark
     4. Density (html[data-density="compact"])
     5. Motion: spring bubbles, send fly-in, counter roll (driven by js/motion.js)
     6. Appearance panel
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Chat wallpapers — pattern (--wp) + accent tint (--wp-tint), fixed behind the scrolling stream
   -------------------------------------------------------------------------- */
:root {
  --wp-doodle-ink: rgba(16, 22, 34, .055);
  --wp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='rgba(16,22,34,.055)' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 16h24a6 6 0 0 1 6 6v11a6 6 0 0 1-6 6H27l-8 7v-7h-5a6 6 0 0 1-6-6V22a6 6 0 0 1 6-6z'/%3E%3Cpath d='M98 26l36-14-12 36-9-13zM113 35l21-23'/%3E%3Cpath d='M78 74l4 8.2 9 1.3-6.5 6.3 1.5 9L78 94.6l-8 4.2 1.5-9-6.5-6.3 9-1.3z'/%3E%3Cpath d='M30 128s-13-7.8-13-16.5a7 7 0 0 1 13-3.9 7 7 0 0 1 13 3.9c0 8.7-13 16.5-13 16.5z'/%3E%3Ccircle cx='128' cy='118' r='6'/%3E%3Cpath d='M134 118v3a4 4 0 0 0 8 0v-3a14 14 0 1 0-5.5 11'/%3E%3Cpath d='M120 66h24v16h-24zM120 66l12 9 12-9'/%3E%3Ccircle cx='60' cy='30' r='1.3'/%3E%3Ccircle cx='150' cy='150' r='1.3'/%3E%3Ccircle cx='72' cy='140' r='1.3'/%3E%3Ccircle cx='10' cy='82' r='1.3'/%3E%3C/svg%3E") 0 0 / 160px 160px repeat;
  --wp-tint: radial-gradient(90% 70% at 100% 100%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
             radial-gradient(70% 60% at 0% 0%, color-mix(in srgb, var(--accent) 4%, transparent), transparent 70%);
}
:root[data-theme="dark"] {
  --wp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='rgba(255,255,255,.04)' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 16h24a6 6 0 0 1 6 6v11a6 6 0 0 1-6 6H27l-8 7v-7h-5a6 6 0 0 1-6-6V22a6 6 0 0 1 6-6z'/%3E%3Cpath d='M98 26l36-14-12 36-9-13zM113 35l21-23'/%3E%3Cpath d='M78 74l4 8.2 9 1.3-6.5 6.3 1.5 9L78 94.6l-8 4.2 1.5-9-6.5-6.3 9-1.3z'/%3E%3Cpath d='M30 128s-13-7.8-13-16.5a7 7 0 0 1 13-3.9 7 7 0 0 1 13 3.9c0 8.7-13 16.5-13 16.5z'/%3E%3Ccircle cx='128' cy='118' r='6'/%3E%3Cpath d='M134 118v3a4 4 0 0 0 8 0v-3a14 14 0 1 0-5.5 11'/%3E%3Cpath d='M120 66h24v16h-24zM120 66l12 9 12-9'/%3E%3Ccircle cx='60' cy='30' r='1.3'/%3E%3Ccircle cx='150' cy='150' r='1.3'/%3E%3Ccircle cx='72' cy='140' r='1.3'/%3E%3Ccircle cx='10' cy='82' r='1.3'/%3E%3C/svg%3E") 0 0 / 160px 160px repeat;
}
/* Glass: a lighter, blue-tinted doodle on the frosted pane */
:root[data-skin="glass"]:not([data-theme="dark"]) {
  --wp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='rgba(0,60,160,.05)' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 16h24a6 6 0 0 1 6 6v11a6 6 0 0 1-6 6H27l-8 7v-7h-5a6 6 0 0 1-6-6V22a6 6 0 0 1 6-6z'/%3E%3Cpath d='M98 26l36-14-12 36-9-13zM113 35l21-23'/%3E%3Cpath d='M78 74l4 8.2 9 1.3-6.5 6.3 1.5 9L78 94.6l-8 4.2 1.5-9-6.5-6.3 9-1.3z'/%3E%3Cpath d='M30 128s-13-7.8-13-16.5a7 7 0 0 1 13-3.9 7 7 0 0 1 13 3.9c0 8.7-13 16.5-13 16.5z'/%3E%3Ccircle cx='128' cy='118' r='6'/%3E%3Cpath d='M134 118v3a4 4 0 0 0 8 0v-3a14 14 0 1 0-5.5 11'/%3E%3Cpath d='M120 66h24v16h-24zM120 66l12 9 12-9'/%3E%3C/svg%3E") 0 0 / 160px 160px repeat;
}
/* Aurora: a star field */
:root[data-skin="aurora"] {
  --wp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' fill='rgba(79,70,229,.22)'%3E%3Ccircle cx='12' cy='20' r='1'/%3E%3Ccircle cx='70' cy='8' r='.7' opacity='.6'/%3E%3Ccircle cx='130' cy='34' r='1.2'/%3E%3Ccircle cx='166' cy='90' r='.8' opacity='.7'/%3E%3Ccircle cx='40' cy='96' r='.9' opacity='.8'/%3E%3Ccircle cx='100' cy='120' r='1.3'/%3E%3Ccircle cx='150' cy='160' r='.7'/%3E%3Ccircle cx='20' cy='160' r='1.1' opacity='.7'/%3E%3Ccircle cx='86' cy='66' r='.6' opacity='.5'/%3E%3Cpath d='M62 140l1.6 4.8 4.8 1.6-4.8 1.6-1.6 4.8-1.6-4.8-4.8-1.6 4.8-1.6z'/%3E%3Cpath d='M150 54l1.2 3.6 3.6 1.2-3.6 1.2-1.2 3.6-1.2-3.6-3.6-1.2 3.6-1.2z'/%3E%3C/svg%3E") 0 0 / 180px 180px repeat;
  --wp-tint: radial-gradient(80% 60% at 100% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
             radial-gradient(70% 60% at 0% 100%, rgba(168, 85, 247, .06), transparent 70%);
}
:root[data-skin="aurora"][data-theme="dark"] {
  --wp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' fill='rgba(205,210,255,.42)'%3E%3Ccircle cx='12' cy='20' r='1'/%3E%3Ccircle cx='70' cy='8' r='.7' opacity='.6'/%3E%3Ccircle cx='130' cy='34' r='1.2'/%3E%3Ccircle cx='166' cy='90' r='.8' opacity='.7'/%3E%3Ccircle cx='40' cy='96' r='.9' opacity='.8'/%3E%3Ccircle cx='100' cy='120' r='1.3'/%3E%3Ccircle cx='150' cy='160' r='.7'/%3E%3Ccircle cx='20' cy='160' r='1.1' opacity='.7'/%3E%3Ccircle cx='86' cy='66' r='.6' opacity='.5'/%3E%3Cpath d='M62 140l1.6 4.8 4.8 1.6-4.8 1.6-1.6 4.8-1.6-4.8-4.8-1.6 4.8-1.6z'/%3E%3Cpath d='M150 54l1.2 3.6 3.6 1.2-3.6 1.2-1.2 3.6-1.2-3.6-3.6-1.2 3.6-1.2z'/%3E%3C/svg%3E") 0 0 / 180px 180px repeat;
}
/* Sandstone: linen weave */
:root[data-skin="sandstone"] {
  --wp: repeating-linear-gradient(0deg, rgba(64, 42, 20, .028) 0 1px, transparent 1px 4px),
        repeating-linear-gradient(90deg, rgba(64, 42, 20, .022) 0 1px, transparent 1px 5px);
  --wp-tint: radial-gradient(90% 70% at 100% 100%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 70%);
}
:root[data-skin="sandstone"][data-theme="dark"] {
  --wp: repeating-linear-gradient(0deg, rgba(255, 232, 205, .022) 0 1px, transparent 1px 4px),
        repeating-linear-gradient(90deg, rgba(255, 232, 205, .016) 0 1px, transparent 1px 5px);
}
/* Obsidian: dot matrix */
:root[data-skin="obsidian"] {
  --wp: radial-gradient(rgba(0, 0, 0, .1) 1px, transparent 1.4px) 0 0 / 16px 16px;
  --wp-tint: linear-gradient(transparent, transparent);
}
:root[data-skin="obsidian"][data-theme="dark"] {
  --wp: radial-gradient(rgba(255, 255, 255, .085) 1px, transparent 1.4px) 0 0 / 16px 16px;
  --wp-tint: radial-gradient(60% 40% at 100% 100%, color-mix(in srgb, var(--hl) 5%, transparent), transparent 70%);
}
/* Noir Luxe: art-deco fans */
:root[data-skin="noir"] {
  --wp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='28' fill='none' stroke='rgba(156,122,60,.13)' stroke-width='1'%3E%3Cpath d='M0 28a28 28 0 0 1 56 0M9 28a19 19 0 0 1 38 0M18 28a10 10 0 0 1 20 0'/%3E%3C/svg%3E") 0 0 / 56px 28px,
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='28' fill='none' stroke='rgba(156,122,60,.13)' stroke-width='1'%3E%3Cpath d='M0 28a28 28 0 0 1 56 0M9 28a19 19 0 0 1 38 0M18 28a10 10 0 0 1 20 0'/%3E%3C/svg%3E") 28px 14px / 56px 28px;
  --wp-tint: radial-gradient(80% 60% at 50% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%);
}
:root[data-skin="noir"][data-theme="dark"] {
  --wp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='28' fill='none' stroke='rgba(212,180,122,.075)' stroke-width='1'%3E%3Cpath d='M0 28a28 28 0 0 1 56 0M9 28a19 19 0 0 1 38 0M18 28a10 10 0 0 1 20 0'/%3E%3C/svg%3E") 0 0 / 56px 28px,
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='28' fill='none' stroke='rgba(212,180,122,.075)' stroke-width='1'%3E%3Cpath d='M0 28a28 28 0 0 1 56 0M9 28a19 19 0 0 1 38 0M18 28a10 10 0 0 1 20 0'/%3E%3C/svg%3E") 28px 14px / 56px 28px;
}
/* Arctic: snowflakes */
:root[data-skin="arctic"] {
  --wp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' fill='none' stroke='rgba(94,129,172,.13)' stroke-width='1.3' stroke-linecap='round'%3E%3Cpath d='M30 20v20M21.3 25l17.4 10M21.3 35l17.4-10M27 22l3 3 3-3M27 38l3-3 3 3'/%3E%3Cpath d='M90 80v12M84.8 83l10.4 6M84.8 89l10.4-6'/%3E%3Ccircle cx='72' cy='30' r='1' fill='rgba(94,129,172,.2)' stroke='none'/%3E%3Ccircle cx='20' cy='96' r='1.2' fill='rgba(94,129,172,.2)' stroke='none'/%3E%3Ccircle cx='110' cy='18' r='.8' fill='rgba(94,129,172,.2)' stroke='none'/%3E%3C/svg%3E") 0 0 / 120px 120px repeat;
  --wp-tint: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent 40%);
}
:root[data-skin="arctic"][data-theme="dark"] {
  --wp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' fill='none' stroke='rgba(216,222,233,.065)' stroke-width='1.3' stroke-linecap='round'%3E%3Cpath d='M30 20v20M21.3 25l17.4 10M21.3 35l17.4-10M27 22l3 3 3-3M27 38l3-3 3 3'/%3E%3Cpath d='M90 80v12M84.8 83l10.4 6M84.8 89l10.4-6'/%3E%3Ccircle cx='72' cy='30' r='1' fill='rgba(216,222,233,.1)' stroke='none'/%3E%3Ccircle cx='20' cy='96' r='1.2' fill='rgba(216,222,233,.1)' stroke='none'/%3E%3Ccircle cx='110' cy='18' r='.8' fill='rgba(216,222,233,.1)' stroke='none'/%3E%3C/svg%3E") 0 0 / 120px 120px repeat;
}
:root[data-wallpaper="on"] :is(.nx-messages-area, .ap-preview-stream) { background: var(--wp-tint), var(--wp); }

/* --------------------------------------------------------------------------
   2. Light & texture
   -------------------------------------------------------------------------- */
/* Film grain kills banding in the large gradients of the textured styles. */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 2147483000; pointer-events: none; display: none;
  opacity: var(--grain, 0);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 180px 180px;
}
:root:is([data-skin="aurora"], [data-skin="sandstone"], [data-skin="noir"], [data-skin="obsidian"]) body::after { display: block; }
:root[data-skin="aurora"] { --grain: .035; }
:root[data-skin="aurora"][data-theme="dark"] { --grain: .05; }
:root[data-skin="sandstone"] { --grain: .06; }
:root[data-skin="noir"] { --grain: .045; }
:root[data-skin="noir"][data-theme="dark"] { --grain: .06; }
:root[data-skin="obsidian"][data-theme="dark"] { --grain: .04; }

/* A key light from above: a hairline highlight on the top edge of raised surfaces (dark modes). */
:root[data-theme="dark"] :is(.modal, .menu, .toast, .ai-panel, .auth-card, .forward-card, .convo, .msg-actions, .jump-bottom)::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 1px 0 var(--edge-hi, rgba(255, 255, 255, .06));
}
:root[data-skin="noir"][data-theme="dark"] { --edge-hi: rgba(243, 223, 174, .1); }
:root[data-skin="aurora"][data-theme="dark"] { --edge-hi: rgba(190, 195, 255, .09); }
:root[data-skin="obsidian"][data-theme="dark"] { --edge-hi: rgba(255, 255, 255, .08); }

/* --------------------------------------------------------------------------
   3. Custom accent — any hue, derived in OKLCH so lightness stays even across hues
   -------------------------------------------------------------------------- */
:root[data-accent][data-accent]:not([data-theme="dark"]) {
  --accent: oklch(.55 .17 var(--ah));
  --accent-strong: oklch(.49 .17 var(--ah));
  --accent-ink: #FFFFFF;
  --accent-soft: oklch(.55 .17 var(--ah) / .1);
  --accent-soft-2: oklch(.55 .17 var(--ah) / .18);
  --accent-text: oklch(.47 .15 var(--ah));
  --focus-ring: 0 0 0 3px oklch(.55 .17 var(--ah) / .24);
  --bubble-me: oklch(.94 .045 var(--ah));
  --bubble-me-text: oklch(.26 .06 var(--ah));
  --bubble-me-line: oklch(.55 .17 var(--ah) / .16);
  --hl: oklch(.62 .2 var(--ah));
  --grad: linear-gradient(135deg, oklch(.58 .2 var(--ah)), oklch(.55 .21 calc(var(--ah) + 35)));
  --grad-btn: linear-gradient(180deg, oklch(.62 .19 var(--ah)), oklch(.51 .2 var(--ah)));
  --gold: linear-gradient(135deg, oklch(.8 .09 var(--ah)), oklch(.62 .12 var(--ah)) 50%, oklch(.48 .1 var(--ah)));
  --gold-line: oklch(.55 .1 var(--ah) / .45);
  --gold-ink: oklch(.18 .04 var(--ah));
}
:root[data-accent][data-accent][data-theme="dark"] {
  --accent: oklch(.74 .15 var(--ah));
  --accent-strong: oklch(.8 .14 var(--ah));
  --accent-ink: oklch(.2 .04 var(--ah));
  --accent-soft: oklch(.74 .15 var(--ah) / .13);
  --accent-soft-2: oklch(.74 .15 var(--ah) / .22);
  --accent-text: oklch(.82 .12 var(--ah));
  --focus-ring: 0 0 0 3px oklch(.74 .15 var(--ah) / .3);
  --bubble-me: oklch(.33 .07 var(--ah));
  --bubble-me-text: oklch(.95 .02 var(--ah));
  --bubble-me-line: oklch(.74 .15 var(--ah) / .18);
  --hl: oklch(.86 .19 var(--ah));
  --grad: linear-gradient(135deg, oklch(.6 .2 var(--ah)), oklch(.57 .21 calc(var(--ah) + 35)));
  --grad-btn: linear-gradient(180deg, oklch(.64 .19 var(--ah)), oklch(.53 .2 var(--ah)));
  --gold: linear-gradient(135deg, oklch(.88 .08 var(--ah)), oklch(.72 .11 var(--ah)) 48%, oklch(.52 .1 var(--ah)));
  --gold-line: oklch(.78 .09 var(--ah) / .4);
  --gold-ink: oklch(.18 .04 var(--ah));
}
/* Styles whose own bubbles/marks are solid colour follow the custom hue too */
:root[data-accent][data-skin="aurora"] { --glow: radial-gradient(1100px 540px at -5% -12%, oklch(.6 .2 var(--ah) / .18), transparent 62%), radial-gradient(900px 500px at 105% -8%, oklch(.6 .2 calc(var(--ah) + 35) / .12), transparent 60%); }
:root[data-accent][data-skin="aurora"] :is(.nx-bubble.me, .ai-msg.user .ai-content),
:root[data-accent][data-skin="aurora"] .rail-me { background: var(--grad); color: #fff; }
:root[data-accent][data-skin="glass"] { --selected: var(--accent); --selected-shadow: 0 6px 18px -8px var(--accent); }
:root[data-accent][data-skin="glass"] :is(.nx-bubble.me, .ai-msg.user .ai-content) { background: linear-gradient(180deg, oklch(.66 .17 var(--ah)), oklch(.57 .19 var(--ah))); color: #fff; }
:root[data-accent][data-skin="glass"] .nx-chat-row.is-selected .nx-chat-row-inner { color: var(--accent-ink); }
:root[data-accent][data-accent][data-skin="obsidian"] { --bubble-me: var(--accent); --bubble-me-text: var(--accent-ink); }
:root[data-accent]:is([data-skin="glass"], [data-skin="sandstone"], [data-skin="arctic"]) .rail-me { background: linear-gradient(150deg, oklch(.72 .14 var(--ah)), oklch(.52 .17 var(--ah))); color: #fff; }

/* --------------------------------------------------------------------------
   4. Density — compact
   -------------------------------------------------------------------------- */
:root[data-density="compact"] { --fs-base: 13.5px; --fs-md: 13px; --fs-lg: 14.5px; --list-w: 340px; }
:root[data-density="compact"] .nx-chat-row-inner { padding: 7px 10px; gap: 10px; }
:root[data-density="compact"] .nx-chat-row-inner .avatar { --size: 36px; }
:root[data-density="compact"] .nx-chat-row .line + .line { margin-top: 1px; }
:root[data-density="compact"] .listpane-head { padding-top: 12px; gap: 9px; }
:root[data-density="compact"] .convo-head { min-height: 54px; padding-top: 6px; padding-bottom: 6px; }
:root[data-density="compact"] .nx-messages-inner { gap: 6px; padding-top: 4px; }
:root[data-density="compact"] .nx-bubble { padding: 6px 11px 5px; line-height: 1.42; }
:root[data-density="compact"] .nx-bubble-wrap.g-cont { margin-top: -4px; }
:root[data-density="compact"] .composer { padding-top: 6px; padding-bottom: 10px; }
:root[data-density="compact"] .rail-btn { width: 36px; height: 36px; }
:root[data-density="compact"] .acc-row { padding-top: 9px; padding-bottom: 9px; }

/* --------------------------------------------------------------------------
   5. Motion
   -------------------------------------------------------------------------- */
.nx-bubble-wrap { animation: bubble-spring 420ms var(--ease-spring) both; }
.nx-bubble-wrap.them { transform-origin: 0 100%; }
.nx-bubble-wrap.me { transform-origin: 100% 100%; }
@keyframes bubble-spring { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }

/* The message just sent travels up out of the composer */
.nx-bubble-wrap.is-sent { animation: send-fly 560ms cubic-bezier(.2, 1.25, .35, 1) both; transform-origin: 100% 100%; }
@keyframes send-fly {
  0%   { opacity: 0; transform: translate(-6%, 72px) scale(.55); }
  45%  { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

/* Counters roll their new value up from below; new badges pop in */
:is(.count, .rail-count, .nx-complete-count) { overflow: hidden; }
.is-roll { animation: count-roll 460ms var(--ease-spring); }
@keyframes count-roll { from { padding-top: 1.7em; } }
.is-pop { animation: count-pop 420ms var(--ease-spring); }
@keyframes count-pop { from { transform: scale(.3); opacity: 0; } }

/* Header pieces settle after the avatar flies in (see motion.js) */
.convo-id.is-arriving { animation: id-in 380ms var(--ease-out) both; }
@keyframes id-in { from { opacity: 0; transform: translateX(-10px); } }

/* --------------------------------------------------------------------------
   6. Appearance panel
   -------------------------------------------------------------------------- */
.ap { width: min(860px, 100%); }
.ap .modal-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.ap-main { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.ap-section { display: flex; flex-direction: column; gap: 10px; }
.ap-section > .ap-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ap-section > .ap-h b { font-size: var(--fs-md); font-weight: 650; }
.ap-section > .ap-h span { font-size: var(--fs-xs); color: var(--text-3); }
.ap-styles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ap-styles .skin-opt { padding: 7px 7px 9px; gap: 8px; }
.ap-styles .skin-opt .sw { height: 62px; }
.ap-styles .skin-opt .nm { flex-direction: column; align-items: flex-start; gap: 1px; }
.ap-styles .skin-opt .nm b { font-size: var(--fs-sm); font-weight: 650; color: var(--text); display: flex; align-items: center; gap: 5px; }
.ap-styles .skin-opt .nm small { font-size: 10.5px; color: var(--text-3); font-weight: 500; line-height: 1.3; }
.ap-styles .skin-opt .nm i { opacity: 0; }
.ap-styles .skin-opt.is-active .nm i { opacity: 1; }

.ap-swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ap-swatch {
  width: 30px; height: 30px; border-radius: 50%; flex: none; position: relative;
  background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  transition: transform var(--t-base) var(--ease-spring), box-shadow var(--t-fast);
}
.ap-swatch:hover { transform: scale(1.1); }
.ap-swatch.is-active { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--sw); }
.ap-swatch.is-active::after { content: "\2713"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.ap-swatch.is-default { background: conic-gradient(from 210deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--surface-3)), var(--accent)); }
.ap-swatch.is-default.is-active { --sw: var(--accent); }
.ap-hue { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.ap-hue input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 12px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(90deg, oklch(.65 .17 0), oklch(.65 .17 45), oklch(.65 .17 90), oklch(.65 .17 135), oklch(.65 .17 180),
    oklch(.65 .17 225), oklch(.65 .17 270), oklch(.65 .17 315), oklch(.65 .17 360));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.ap-hue input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: oklch(.65 .17 var(--h, 150)); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.ap-hue input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: oklch(.65 .17 var(--h, 150)); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.ap-hue .val { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; width: 34px; text-align: right; }

.ap-toggles { display: flex; flex-direction: column; border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--line-strong); overflow: hidden; }
.ap-toggle { display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
.ap-toggle + .ap-toggle { box-shadow: inset 0 1px 0 var(--line); }
.ap-toggle .t { flex: 1; min-width: 0; }
.ap-toggle .t b { display: block; font-size: var(--fs-md); font-weight: 600; }
.ap-toggle .t span { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.ap-toggle > i { font-size: 17px; color: var(--text-3); width: 20px; text-align: center; }
.ap-toggle .segmented { min-width: 200px; }
.switch {
  position: relative; width: 40px; height: 24px; border-radius: 999px; flex: none;
  background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background var(--t-base);
}
.switch::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform var(--t-base) var(--ease-spring);
}
.switch.is-on { background: var(--accent); box-shadow: none; }
.switch.is-on::after { transform: translateX(16px); }

/* Live preview (sticky beside the controls) */
.ap-preview { position: sticky; top: 0; display: flex; flex-direction: column; border-radius: var(--r-xl); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-2); }
.ap-preview-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ap-preview-head .avatar { --size: 30px; }
.ap-preview-head .avatar-face { display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 12px; background: linear-gradient(140deg, #F59E0B, #EF4444); }
.ap-preview-head b { font-size: var(--fs-md); font-weight: 650; display: block; line-height: 1.2; }
.ap-preview-head span { font-size: 10.5px; color: var(--ok); }
.ap-preview-stream { display: flex; flex-direction: column; gap: 6px; padding: 14px 12px; min-height: 250px; }
.ap-preview-stream .nx-bubble-wrap { animation: none; max-width: 86%; }
.ap-preview-stream .nx-bubble { font-size: 12.5px; padding: 7px 11px 5px; }
.ap-preview-stream .nx-bubble-time { font-size: 9.5px; }
.ap-preview-stream .nx-date-sep { position: static; margin: 2px 0 4px; }
.ap-preview-foot { padding: 8px 10px 10px; }
.ap-preview-foot .composer-box { padding: 4px; }
.ap-preview-foot .composer-box .fake { flex: 1; padding: 6px 4px; font-size: 12.5px; color: var(--text-4); }
.ap-preview-foot .send-btn { width: 30px; height: 30px; }
.ap-preview-chips { display: flex; gap: 6px; padding: 10px 12px 0; flex-wrap: wrap; }
.ap .modal-foot .btn-ghost { margin-right: auto; }

@media (max-width: 860px) {
  .ap .modal-body { grid-template-columns: 1fr; }
  .ap-preview { position: static; order: -1; }
  .ap-preview-stream { min-height: 0; }
}
@media (max-width: 560px) {
  .ap-styles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ap-toggle { flex-wrap: wrap; }
  .ap-toggle .segmented { min-width: 0; width: 100%; }
}
