/* ntcom - Developed by acidvegas in CSS (https://github.com/acidvegas) */
/* style.css */

/* Editorial monochrome: one accent, warm off-white, near-black. Accent is set per-site from settings. */

@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: italic; font-weight: 400; font-display: swap; src: url('fonts/jetbrains-mono-latin-400-italic.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/jetbrains-mono-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 800; font-display: swap; src: url('fonts/jetbrains-mono-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Emoji Large'; src: local('Apple Color Emoji'), local('Segoe UI Emoji'), local('Noto Color Emoji'), local('NotoColorEmoji'), local('Twemoji Mozilla'); size-adjust: 135%; unicode-range: U+00A9, U+00AE, U+203C, U+2049, U+2122, U+2139, U+2194-21AA, U+231A-23FF, U+24C2, U+25AA-27BF, U+2934-2935, U+2B05-2B55, U+3030, U+303D, U+3297, U+3299, U+FE0F, U+200D, U+1F000-1FAFF, U+E0020-E007F; }
@font-face { font-family: 'Lato'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/lato-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Lato'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/lato-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Lato'; font-style: normal; font-weight: 900; font-display: swap; src: url('fonts/lato-latin-900-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 200 900; font-display: swap; src: url('fonts/source-sans-3-latin-wght-normal.woff2') format('woff2-variations'); }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 200 1000; font-display: swap; src: url('fonts/nunito-latin-wght-normal.woff2') format('woff2-variations'); }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 300 500; font-display: swap; src: url('fonts/fraunces-latin-wght-normal.woff2') format('woff2-variations'); }

:root {
	--bg: #0b0b0b;
	--bg-1: #111110;
	--bg-2: #161615;
	--rule: #232322;
	--rule-strong: #2e2e2c;
	--text: #ece8df;
	--text-dim: #8d8a82;
	--text-muted: #5a5750;
	--accent: #c87034;
	--accent-rgb: 200, 112, 52;
	--online: #4cc38a;
	--idle: #e8c547;
	--danger: #e5484d;
	--rule-hover: #3a3a37;
	--text-body: #d9d5cc;

	/* code highlighting */
	--hl-keyword: #c87034;
	--hl-string: #a9b665;
	--hl-comment: #5a5750;
	--hl-number: #d3869b;
	--hl-function: #e8c547;
	--hl-builtin: #7daea3;
	--hl-operator: #8d8a82;
	--hl-attr: #e78a4e;

	--font-serif: 'Fraunces', 'Iowan Old Style', 'Apple Garamond', Georgia, serif;
	--font-sans: 'Inter', system-ui, -apple-system, sans-serif;
	--font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

	--msg-size: 14px;
	--left-w: 300px;
	--right-w: 280px;
	--header-h: 60px;
}

/* ------------------------------------------------------------------ themes (picked per user in Settings > Preferences; the default is the palette above) */

:root[data-theme="dracula"] {
	--bg: #282a36; --bg-1: #21222c; --bg-2: #343746; --rule: #343746; --rule-strong: #44475a; --rule-hover: #565a73;
	--text: #f8f8f2; --text-body: #f8f8f2; --text-dim: #c3c5d4; --text-muted: #7b86b8;
	--accent: #bd93f9; --accent-rgb: 189, 147, 249; --online: #50fa7b; --idle: #f1fa8c; --danger: #ff5555;
	--hl-keyword: #ff79c6; --hl-string: #f1fa8c; --hl-comment: #6272a4; --hl-number: #bd93f9; --hl-function: #50fa7b; --hl-builtin: #8be9fd; --hl-operator: #ff79c6; --hl-attr: #50fa7b;
	--font-serif: var(--font-sans);
}

:root[data-theme="nord"] {
	--bg: #2e3440; --bg-1: #292e39; --bg-2: #3b4252; --rule: #3b4252; --rule-strong: #4c566a; --rule-hover: #5e6a82;
	--text: #eceff4; --text-body: #d8dee9; --text-dim: #b7c0d0; --text-muted: #7b88a1;
	--accent: #88c0d0; --accent-rgb: 136, 192, 208; --online: #a3be8c; --idle: #ebcb8b; --danger: #bf616a;
	--hl-keyword: #81a1c1; --hl-string: #a3be8c; --hl-comment: #616e88; --hl-number: #b48ead; --hl-function: #88c0d0; --hl-builtin: #8fbcbb; --hl-operator: #81a1c1; --hl-attr: #8fbcbb;
	--font-serif: var(--font-sans);
}

:root[data-theme="github"] {
	--bg: #0d1117; --bg-1: #010409; --bg-2: #151b23; --rule: #21262d; --rule-strong: #30363d; --rule-hover: #3d444d;
	--text: #e6edf3; --text-body: #e6edf3; --text-dim: #9198a1; --text-muted: #656c76;
	--accent: #4493f8; --accent-rgb: 68, 147, 248; --online: #3fb950; --idle: #d29922; --danger: #f85149;
	--hl-keyword: #ff7b72; --hl-string: #a5d6ff; --hl-comment: #8b949e; --hl-number: #79c0ff; --hl-function: #d2a8ff; --hl-builtin: #ffa657; --hl-operator: #e6edf3; --hl-attr: #79c0ff;
	--font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
	--font-serif: var(--font-sans);
}

:root[data-theme="slack"] {
	--bg: #1a1d21; --bg-1: #1a1d21; --bg-2: #222529; --rule: #2c2d30; --rule-strong: #3b3d42; --rule-hover: #50535a;
	--text: #f8f8f8; --text-body: #d1d2d3; --text-dim: #ababad; --text-muted: #818385;
	--accent: #1d9bd1; --accent-rgb: 29, 155, 209; --online: #2bac76; --idle: #ecb22e; --danger: #e01e5a;
	--hl-keyword: #e01e5a; --hl-string: #2bac76; --hl-comment: #818385; --hl-number: #ecb22e; --hl-function: #36c5f0; --hl-builtin: #36c5f0; --hl-operator: #d1d2d3; --hl-attr: #e8912d;
	--font-sans: 'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif;
	--font-serif: var(--font-sans);
}

/* Slack's aubergine sidebar with the blue selected row */
:root[data-theme="slack"] .left { --bg-1: #350d36; --bg-2: #4a1d4b; --rule: #4b2a4c; --rule-strong: #5e3a5f; --text: #ffffff; --text-dim: #d8c8d8; --text-muted: #a58fa5; color: var(--text); }
:root[data-theme="slack"] .chan.active, :root[data-theme="slack"] .topic-item.active { background: #1164a3; color: #fff; }

:root[data-theme="zulip"] {
	--bg: #1d1d1d; --bg-1: #191919; --bg-2: #2a2a2a; --rule: #2e2e2e; --rule-strong: #3d3d3d; --rule-hover: #525252;
	--text: #ebebeb; --text-body: #e0e0e0; --text-dim: #b0b0b0; --text-muted: #808080;
	--accent: #6492fe; --accent-rgb: 100, 146, 254; --online: #44c21d; --idle: #f5a623; --danger: #e05a5a;
	--hl-keyword: #66d9ef; --hl-string: #e6db74; --hl-comment: #75715e; --hl-number: #ae81ff; --hl-function: #a6e22e; --hl-builtin: #a6e22e; --hl-operator: #f92672; --hl-attr: #a6e22e;
	--font-sans: 'Source Sans 3', 'Helvetica Neue', Helvetica, Arial, sans-serif;
	--font-serif: var(--font-sans);
}

:root[data-theme="sakura"] {
	--bg: #1f1520; --bg-1: #1a111b; --bg-2: #2c1b2c; --rule: #36222f; --rule-strong: #4a2f45; --rule-hover: #6e4566;
	--text: #fde7f1; --text-body: #f6dbe8; --text-dim: #d8abc3; --text-muted: #9d7189;
	--accent: #ff7eb6; --accent-rgb: 255, 126, 182; --online: #7ee0b0; --idle: #ffd27a; --danger: #ff6b8a;
	--hl-keyword: #ff7eb6; --hl-string: #a6e3c5; --hl-comment: #9d7189; --hl-number: #c7a0ff; --hl-function: #ffb3d9; --hl-builtin: #8fd3ff; --hl-operator: #f5c2e7; --hl-attr: #ffd27a;
	--font-sans: 'Nunito', 'Helvetica Neue', Helvetica, Arial, sans-serif;
	--font-serif: var(--font-sans);
}

/* Sakura softens the square edges */
:root[data-theme="sakura"] :is(.btn, input, select, textarea, .composer-box, .panel, .modal, .menu, .popover, .toast, .msg-actions, .topic-bar, .pin-bar, .badge, .status-pill, .pin-label, .role-tag, .chan-icon, .avatar img, .msg-body pre, .msg-body code, .attachments img, .preview, .poll-opt) { border-radius: 10px; }
:root[data-theme="sakura"] :is(.badge, .status-pill, .pin-label, .role-tag, .msg-body code) { border-radius: 999px; }

/* ------------------------------------------------------------------ light mode: one palette per theme (data-mode is set by theme.js) */

:root[data-mode="light"] {
	color-scheme: light;
	--bg: #f6f3ec; --bg-1: #efebe2; --bg-2: #e6e1d6; --rule: #ddd7ca; --rule-strong: #cdc6b6; --rule-hover: #b5ad9b;
	--text: #1a1916; --text-body: #2a2824; --text-dim: #5d5950; --text-muted: #8d887c;
	--online: #2f9e6a; --idle: #b8901a; --danger: #d23b40;
	--hl-keyword: #b35a1f; --hl-string: #6b7d1e; --hl-comment: #9a958a; --hl-number: #b0567a; --hl-function: #a0700a; --hl-builtin: #3c7d74; --hl-operator: #6b675e; --hl-attr: #c0612a;
}

:root[data-theme="dracula"][data-mode="light"] {
	--bg: #f8f8f2; --bg-1: #efeff7; --bg-2: #e4e4f0; --rule: #dcdcea; --rule-strong: #c9c9de; --rule-hover: #a9a9c8;
	--text: #282a36; --text-body: #282a36; --text-dim: #44475a; --text-muted: #6272a4;
	--accent: #8e5be8; --accent-rgb: 142, 91, 232; --online: #1fa84a; --idle: #b38b00; --danger: #e5383b;
	--hl-keyword: #d6409f; --hl-string: #9a7d00; --hl-comment: #6272a4; --hl-number: #8e5be8; --hl-function: #1f9d4c; --hl-builtin: #0e94a8; --hl-operator: #d6409f; --hl-attr: #1f9d4c;
}

/* Dracula light keeps Dracula's dark sidebar so it still reads as Dracula */
:root[data-theme="dracula"][data-mode="light"] .left { --bg: #191a21; --bg-1: #282a36; --bg-2: #343746; --rule: #343746; --rule-strong: #44475a; --text: #f8f8f2; --text-dim: #c3c5d4; --text-muted: #7b86b8; --accent: #bd93f9; --accent-rgb: 189, 147, 249; color: var(--text); color-scheme: dark; }

:root[data-theme="nord"][data-mode="light"] {
	--bg: #eceff4; --bg-1: #e5e9f0; --bg-2: #d8dee9; --rule: #d8dee9; --rule-strong: #c2cad8; --rule-hover: #a7b1c2;
	--text: #2e3440; --text-body: #3b4252; --text-dim: #4c566a; --text-muted: #7b88a1;
	--accent: #5e81ac; --accent-rgb: 94, 129, 172; --online: #5f8a4c; --idle: #b98c2f; --danger: #bf616a;
	--hl-keyword: #5e81ac; --hl-string: #5f8a4c; --hl-comment: #8a94a8; --hl-number: #a4789d; --hl-function: #3f8a9e; --hl-builtin: #4c8a87; --hl-operator: #5e81ac; --hl-attr: #4c8a87;
}

:root[data-theme="github"][data-mode="light"] {
	--bg: #ffffff; --bg-1: #f6f8fa; --bg-2: #eff2f5; --rule: #e1e6eb; --rule-strong: #d1d9e0; --rule-hover: #b8c1ca;
	--text: #1f2328; --text-body: #1f2328; --text-dim: #59636e; --text-muted: #818b98;
	--accent: #0969da; --accent-rgb: 9, 105, 218; --online: #1a7f37; --idle: #9a6700; --danger: #d1242f;
	--hl-keyword: #cf222e; --hl-string: #0a3069; --hl-comment: #59636e; --hl-number: #0550ae; --hl-function: #8250df; --hl-builtin: #953800; --hl-operator: #1f2328; --hl-attr: #0550ae;
}

:root[data-theme="slack"][data-mode="light"] {
	--bg: #ffffff; --bg-1: #ffffff; --bg-2: #f8f8f8; --rule: #e8e8e8; --rule-strong: #dddddd; --rule-hover: #c5c5c5;
	--text: #1d1c1d; --text-body: #1d1c1d; --text-dim: #616061; --text-muted: #868686;
	--accent: #1264a3; --accent-rgb: 18, 100, 163; --online: #007a5a; --idle: #b88a0e; --danger: #e01e5a;
	--hl-keyword: #e01e5a; --hl-string: #007a5a; --hl-comment: #868686; --hl-number: #b88a0e; --hl-function: #1264a3; --hl-builtin: #1d9bd1; --hl-operator: #1d1c1d; --hl-attr: #e8912d;
}

/* Slack's classic light look keeps the aubergine sidebar */
:root[data-theme="slack"][data-mode="light"] .left { --bg: #2c0b2d; --bg-1: #3f0e40; --bg-2: #350d36; --rule: #522653; --rule-strong: #6a3a6b; color-scheme: dark; }

:root[data-theme="zulip"][data-mode="light"] {
	--bg: #ffffff; --bg-1: #f7f7f7; --bg-2: #ececec; --rule: #e5e5e5; --rule-strong: #d4d4d4; --rule-hover: #b5b5b5;
	--text: #262626; --text-body: #333333; --text-dim: #666666; --text-muted: #8c8c8c;
	--accent: #2d6be0; --accent-rgb: 45, 107, 224; --online: #3ca31c; --idle: #e08a00; --danger: #d64545;
	--hl-keyword: #008000; --hl-string: #ba2121; --hl-comment: #3d7b7b; --hl-number: #666666; --hl-function: #0000ff; --hl-builtin: #008000; --hl-operator: #666666; --hl-attr: #687822;
}

:root[data-theme="sakura"][data-mode="light"] {
	--bg: #fff5f9; --bg-1: #ffeaf2; --bg-2: #ffdceb; --rule: #fbd3e3; --rule-strong: #f3bcd2; --rule-hover: #e59bbb;
	--text: #4a2338; --text-body: #5a2e45; --text-dim: #8a5470; --text-muted: #b48299;
	--accent: #e5508f; --accent-rgb: 229, 80, 143; --online: #2fa977; --idle: #d49a1e; --danger: #e0446a;
	--hl-keyword: #d63f86; --hl-string: #2f9a6e; --hl-comment: #b48299; --hl-number: #8a5cd6; --hl-function: #c2457f; --hl-builtin: #2f86c2; --hl-operator: #a14d77; --hl-attr: #c98a12;
}

/* the sun shows in dark mode (switch to light), the moon in light mode */
.mode-toggle .i-moon, :root[data-mode="light"] .mode-toggle .i-sun { display: none; }
:root[data-mode="light"] .mode-toggle .i-moon { display: block; }

/* the film grain belongs to the default theme */
:root[data-theme] body::before { display: none; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
	margin: 0;
	font-family: var(--font-sans);
	background: var(--bg);
	color: var(--text);
	line-height: 1.6;
	font-size: 16px;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow-x: hidden;
}

/* film-grain texture overlay */
body::before {
	content: '';
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 1000;
	opacity: 0.035;
	mix-blend-mode: overlay;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

a { color: var(--text); text-decoration: none; transition: color 0.15s ease, border-color 0.15s ease; }
a:hover { color: var(--accent); }
p { margin: 0 0 1em; color: var(--text-dim); }
.serif { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); }
.small { font-size: 0.85rem; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
[hidden] { display: none !important; }

h1, h2, h3, h4 { color: var(--text); font-weight: 500; line-height: 1.15; margin: 0 0 0.6em; letter-spacing: -0.01em; }
h1 { font-family: var(--font-serif); font-weight: 300; font-size: clamp(2rem, 3.6vw, 3rem); letter-spacing: -0.015em; }
h2 { font-family: var(--font-serif); font-weight: 400; font-size: clamp(1.4rem, 2.2vw, 1.9rem); }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); }

.section-label { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-muted); letter-spacing: 0.14em; text-transform: lowercase; margin: 0 0 18px; display: inline-flex; align-items: center; gap: 10px; }
.rule-mark { display: inline-block; width: 28px; height: 1px; background: var(--accent); }
.kicker { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.18em; color: var(--text-dim); text-transform: uppercase; margin-bottom: 22px; display: inline-flex; align-items: center; gap: 10px; }
.dot { display: inline-block; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6); animation: dotPulse 2.4s ease-in-out infinite; }
@keyframes dotPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* BUTTONS */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 13px 22px;
	font-family: var(--font-sans);
	font-size: 0.86rem;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	border: 1px solid transparent;
	border-radius: 0;
	cursor: pointer;
	transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
	white-space: nowrap;
	line-height: 1.2;
}
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { background: var(--accent); color: var(--text); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--rule-strong); }
.btn-ghost:hover { border-color: var(--text); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(229, 72, 77, 0.4); }
.btn-danger:hover { border-color: var(--danger); color: var(--text); background: rgba(229, 72, 77, 0.15); }
.btn-sm { padding: 8px 14px; font-size: 0.74rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }

.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	background: transparent;
	color: var(--text-dim);
	border: 1px solid transparent;
	cursor: pointer;
	transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
	flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent); border-color: var(--rule-strong); }
.icon-btn.active { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.4); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

:focus { outline: none; }
:focus-visible, input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.35); }

/* FORMS */
.form { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: flex; flex-direction: column; gap: 8px; }
.form-row label, .label { font-size: 0.78rem; color: var(--text-dim); letter-spacing: 0.04em; }
.form-row .hint { font-size: 0.78rem; color: var(--text-muted); margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
	background: var(--bg-1);
	color: var(--text);
	border: 1px solid var(--rule-strong);
	border-radius: 0;
	padding: 12px 14px;
	font-family: var(--font-sans);
	font-size: 16px;
	width: 100%;
	max-width: 100%;
	transition: border-color 0.15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--rule-hover); }
input:focus, select:focus, textarea:focus { border-color: rgba(var(--accent-rgb), 0.6); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input[type=color], .inline-form input[type=color] { width: 56px; height: 40px; padding: 3px; background: var(--bg-1); border: 1px solid var(--rule-strong); cursor: pointer; flex-shrink: 0; appearance: none; -webkit-appearance: none; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; }
input[type=color]::-moz-color-swatch { border: 0; }
input[type=number] { appearance: textfield; -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=file] { color: var(--text-dim); font-size: 0.85rem; max-width: 100%; }
input[type=file]::file-selector-button { background: transparent; color: var(--text); border: 1px solid var(--rule-strong); padding: 8px 14px; margin-right: 12px; font-family: var(--font-sans); font-size: 0.74rem; letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer; }
input[type=file]::file-selector-button:hover { border-color: var(--text); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

.check { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; font-size: 0.92rem; color: var(--text); }
.check input { appearance: none; width: 18px; height: 18px; border: 1px solid var(--rule-strong); background: var(--bg-1); margin: 2px 0 0; flex-shrink: 0; cursor: pointer; position: relative; }
.check input:checked { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.18); }
.check input:checked::after { content: ''; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid var(--accent); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.check small { display: block; color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.theme-card { display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.theme-card input { position: absolute; opacity: 0; pointer-events: none; }
.theme-preview { position: relative; display: flex; height: 76px; border: 1px solid var(--rule-strong); border-radius: 6px; overflow: hidden; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.tp-half { position: relative; flex: 1; }
.tp-half i { position: absolute; left: 0; top: 0; bottom: 0; width: 26%; }
.tp-half b { position: absolute; left: 36%; top: 18px; width: 52%; height: 6px; border-radius: 3px; opacity: 0.85; }
.tp-half b + b { top: 32px; opacity: 0.5; }
.tp-half em { position: absolute; left: 36%; bottom: 14px; width: 34%; height: 10px; border-radius: 3px; }
.theme-card:hover .theme-preview { border-color: var(--rule-hover); }
.theme-card input:checked + .theme-preview { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.35); }
.theme-card input:focus-visible + .theme-preview { box-shadow: 0 0 0 2px var(--accent); }
.theme-name { font-size: 0.88rem; color: var(--text-dim); display: flex; justify-content: space-between; align-items: baseline; }
.theme-name small { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-muted); }
.theme-card input:checked ~ .theme-name { color: var(--text); }

.flash { padding: 12px 16px; margin-bottom: 14px; background: var(--bg-1); border: 1px solid var(--rule-strong); border-left: 2px solid var(--accent); color: var(--text); font-size: 0.9rem; }
.flash.error { border-left-color: var(--danger); }

/* BRAND MARK */
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-name { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 400; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mark { width: 34px; height: 34px; flex-shrink: 0; display: block; }
.mark img { width: 100%; height: 100%; object-fit: contain; }
.mark-lg { width: 64px; height: 64px; }

/* ================================================================ AUTH */

.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { position: relative; border-right: 1px solid var(--rule); background: radial-gradient(ellipse at 50% 45%, rgba(var(--accent-rgb), 0.07), transparent 60%), var(--bg); display: flex; flex-direction: column; justify-content: space-between; padding: 36px 48px; overflow: hidden; }
.auth-art .art { width: min(560px, 100%); margin: 0 auto; display: block; }
.auth-art .art-caption { max-width: 520px; }
.auth-art .art-caption h1 { margin-bottom: 14px; }
.auth-art .art-caption p { font-size: 1.02rem; line-height: 1.7; margin: 0; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 88px); background: var(--bg-1); }
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-card h2 { margin-bottom: 8px; }
.auth-card .lede { margin-bottom: 30px; font-size: 0.95rem; }
.auth-alt { margin-top: 26px; font-size: 0.88rem; color: var(--text-muted); }
.auth-alt a { border-bottom: 1px solid var(--rule-strong); padding-bottom: 1px; }
.auth-alt a:hover { border-bottom-color: var(--accent); }
.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row img { height: 50px; width: auto; border: 1px solid var(--rule-strong); background: var(--bg-1); display: block; }
.captcha-row .icon-btn { height: 50px; width: 44px; border-color: var(--rule-strong); }

.pending-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 40px 24px; text-align: center; }
.pending-card { max-width: 560px; }
.pending-card .art { width: min(320px, 80vw); margin: 0 auto 28px; display: block; }
.pending-card p { font-size: 1rem; line-height: 1.7; }
.status-line { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.14em; color: var(--text-muted); display: inline-flex; gap: 10px; align-items: center; margin-top: 18px; }

.error-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 40px 24px; text-align: center; }
.error-wrap .art { width: min(420px, 86vw); margin: 0 auto 24px; display: block; }
.error-code { font-family: var(--font-serif); font-weight: 300; font-size: clamp(3rem, 8vw, 5rem); line-height: 1; margin-bottom: 8px; }

/* ================================================================ ANIMATED ART */

.art { overflow: visible; }
.art .a-stroke { stroke: var(--accent); fill: none; }
.art .a-fill { fill: var(--accent); }
.art .t-stroke { stroke: var(--text); fill: none; }
.art .d-stroke { stroke: var(--rule-strong); fill: none; }
.art .m-stroke { stroke: var(--text-muted); fill: none; }
.art .t-fill { fill: var(--text); }
.art text { font-family: var(--font-mono); fill: var(--text-muted); letter-spacing: 0.12em; }
.art .spin { transform-box: view-box; transform-origin: 50% 50%; animation: spin 14s linear infinite; }
.art .spin-slow { transform-box: view-box; transform-origin: 50% 50%; animation: spin 60s linear infinite; }
.art .spin-rev { transform-box: view-box; transform-origin: 50% 50%; animation: spin 90s linear infinite reverse; }
.art .sweep { transform-box: view-box; transform-origin: 50% 50%; animation: spin 6s linear infinite; }
.art .blip { transform-box: fill-box; transform-origin: center; animation: blip 6s ease-out infinite; opacity: 0; }
.art .ring-out { transform-box: fill-box; transform-origin: center; animation: ringOut 6s ease-out infinite; opacity: 0; }
.art .packet { stroke-dasharray: 4 220; animation: packet 5s linear infinite; }
.art .twinkle { animation: twinkle 4s ease-in-out infinite; }
.art .scan { animation: scanY 4.5s ease-in-out infinite alternate; }
.art .breathe { animation: breathe 5s ease-in-out infinite; }
.art .drift { animation: drift 9s ease-in-out infinite alternate; }
.art .trace { stroke-dasharray: 600; animation: trace 4s linear infinite; }
.art .shoot { animation: shoot 7s ease-in infinite; opacity: 0; }
.art .pulse-ring { transform-box: fill-box; transform-origin: center; animation: ringOut 3s ease-out infinite; opacity: 0; }
.art .orbit { transform-box: view-box; transform-origin: 50% 50%; animation: spin 3s linear infinite; }
.art .dash-flow { stroke-dasharray: 3 7; animation: dashFlow 3s linear infinite; }
.art .tip { transform-box: fill-box; transform-origin: 0% 100%; animation: tip 6s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blip { 0% { opacity: 0; transform: scale(0.4); } 8% { opacity: 1; transform: scale(1.3); } 20% { opacity: 1; transform: scale(1); } 70% { opacity: 0.35; } 100% { opacity: 0; } }
@keyframes ringOut { 0% { opacity: 0.8; transform: scale(0.3); } 100% { opacity: 0; transform: scale(2.4); } }
@keyframes packet { from { stroke-dashoffset: 224; } to { stroke-dashoffset: 0; } }
@keyframes twinkle { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes scanY { from { transform: translateY(0); } to { transform: translateY(150px); } }
@keyframes breathe { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.9; } }
@keyframes drift { from { transform: translate(0, 0) rotate(-4deg); } to { transform: translate(26px, -10px) rotate(6deg); } }
@keyframes trace { from { stroke-dashoffset: 600; } to { stroke-dashoffset: 0; } }
@keyframes shoot { 0%, 70% { opacity: 0; transform: translate(0, 0); } 72% { opacity: 1; } 85% { opacity: 0; transform: translate(-120px, 60px); } 100% { opacity: 0; } }
@keyframes dashFlow { to { stroke-dashoffset: -40; } }
@keyframes tip { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-3deg); } }

@media (prefers-reduced-motion: reduce) {
	.art *, .dot { animation: none !important; }
	.art .blip, .art .ring-out, .art .pulse-ring { opacity: 0.6; }
}

/* ================================================================ CHAT APP */

body.app-body { overflow: hidden; }

.app {
	height: 100vh;
	height: 100dvh;
	display: grid;
	grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
	background: var(--bg);
}
.app.hide-right { grid-template-columns: var(--left-w) minmax(0, 1fr) 0; }
.app.hide-right .right { display: none; }

.left, .right { background: var(--bg-1); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.left { border-right: 1px solid var(--rule); }
.right { border-left: 1px solid var(--rule); }

.side-head { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px 0 18px; border-bottom: 1px solid var(--rule); flex-shrink: 0; }
.side-head .brand { min-width: 0; }
.side-head .brand-name { font-size: 1.08rem; }
.side-head .mark { width: 30px; height: 30px; }
.side-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 0 18px; scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }

.side-search { padding: 12px 14px 4px; }
.side-search input { padding: 8px 12px; font-size: 14px; font-family: var(--font-mono); background: var(--bg); border-color: var(--rule); }
.side-search-btn { margin-left: auto; }

.group-head { display: flex; align-items: center; gap: 8px; padding: 3px 14px 3px 10px; margin: 14px 8px 2px 8px; border-radius: 6px; font-family: var(--font-mono); font-weight: 800; font-size: 1.22rem; letter-spacing: 0.06em; color: var(--text-dim); text-transform: lowercase; cursor: pointer; user-select: none; white-space: nowrap; }
.group-head:hover { color: var(--text); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--rule-strong); }
.group-head .chev { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.4; transition: transform 0.15s ease; flex-shrink: 0; }
.group-head.collapsed .chev { transform: rotate(-90deg); }
.group.dragging { opacity: 0.4; }
.group-head .group-count { margin-left: auto; font-size: 0.66rem; }
.group-head .icon-btn { width: 20px; height: 20px; margin-left: auto; border-color: var(--rule-strong); }
.group-head .manage-btn { height: 26px; margin-right: -8px; }
.group-head .icon-btn:hover { border-color: var(--accent); }
.group-head .group-name { overflow: hidden; text-overflow: ellipsis; }
.group-head .group-lock { width: 15px; height: 15px; stroke: var(--text-muted); fill: none; stroke-width: 2; flex-shrink: 0; }
.group-head .add-chan + .add-chan { margin-left: 0; }
.member-row .check { flex: 1; }
.group-head .add-chan { opacity: 0; transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease; }
.group-head:hover .add-chan, .group-head .add-chan:focus-visible { opacity: 1; }
.group-head .badge + .add-chan { margin-left: 6px; }
.chan[draggable] { cursor: pointer; }
.topic-item { display: flex; align-items: center; gap: 8px; padding: 1px 14px 1px 24px; margin: 0 8px 0 34px; border-radius: 6px; color: var(--text-muted); cursor: pointer; font-size: 0.95rem; border-left: 2px solid transparent; position: relative; line-height: 1.5; }
.chan:has(+ .topic-tree)::after { content: ''; position: absolute; left: 2px; top: 50%; bottom: 0; width: 14px; border-left: 1.5px solid var(--rule-strong); border-top: 1.5px solid var(--rule-strong); border-top-left-radius: 10px; pointer-events: none; }
.topic-item::before { content: ''; position: absolute; left: -24px; top: 0; bottom: 0; border-left: 1.5px solid var(--rule-strong); }
.topic-item:last-child::before { bottom: auto; height: 50%; width: 22px; border-bottom: 1.5px solid var(--rule-strong); border-bottom-left-radius: 10px; }
.topic-item .ti-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-item:hover { color: var(--text); background: var(--bg-2); outline: 1px solid var(--rule-strong); outline-offset: -1px; }
.topic-item .chan-manage { display: inline-flex; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: 22px; visibility: hidden; }
.topic-item:hover .chan-manage { visibility: visible; }
.topic-item:hover .badge:not(.mention) { visibility: hidden; }
.topic-item.unread { color: var(--text-dim); font-weight: 500; }
.topic-item.active { color: var(--text); background: rgba(var(--accent-rgb), 0.08); }
.topic-item.muted, .topic-item.resolved { opacity: 0.5; }
.topic-more { padding: 2px 14px 4px 58px; font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.06em; color: var(--text-muted); cursor: pointer; }
.topic-more:hover { color: var(--accent); }
.topic-bar { display: flex; align-items: baseline; gap: 10px; margin: 16px 24px 4px 22px; padding: 6px 12px; background: var(--bg-1); border: 1px solid var(--rule); border-left: 2px solid rgba(var(--accent-rgb), 0.6); cursor: pointer; font-size: 0.92rem; min-width: 0; }
.topic-bar:hover { border-color: var(--rule-strong); border-left-color: var(--accent); }
.topic-bar .tb-chan { font-family: var(--font-mono); font-weight: 700; flex-shrink: 0; }
.topic-bar .tb-sep { color: var(--text-muted); }
.topic-bar b { font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-bar .tb-go { margin-left: auto; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.1em; color: var(--text-muted); opacity: 0; flex-shrink: 0; }
.topic-bar:hover .tb-go { opacity: 1; color: var(--accent); }
.topic-bar.resolved b { color: var(--text-dim); }
.chat-title-text b .hd-topic { display: inline; font-size: inherit; color: var(--text-dim); }
.hd-back { cursor: pointer; font-family: var(--font-mono); font-size: 0.74rem !important; letter-spacing: 0.04em; }
.hd-back:hover { color: var(--accent); }
.topic-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--rule); font-family: var(--font-mono); font-size: 0.86rem; }
.topic-row .topic-chan { color: var(--text-dim); font-weight: 700; flex-shrink: 0; }
.topic-row .topic-chan b { font-weight: 800; margin-right: 1px; }
.topic-row .topic-sep { color: var(--text-muted); }
.topic-row input { border: 0; background: transparent; padding: 4px 0; font-family: var(--font-mono); font-size: 14px; box-shadow: none !important; min-width: 0; }
.chan-manage { display: none; width: 22px; height: 26px; margin-left: auto; border-color: transparent; }
.chan-manage svg { width: 16px; height: 16px; }
.chan .badge + .chan-manage { margin-left: 6px; }
.chan .chan-add + .chan-manage { margin-left: 2px; }
.chan .chan-add { width: 20px; height: 20px; border-color: var(--rule-strong); }
.chan .chan-add svg, .group-head .add-chan:not(.manage-btn) svg { width: 13px; height: 13px; }
.chan .chan-add:hover { border-color: var(--accent); color: var(--accent); }
.chan .chan-manage:not(.chan-add) { margin-right: -8px; }
.chan:hover .chan-manage, .chan .chan-manage:focus-visible { display: inline-flex; }
.chan:hover .badge:not(.mention) { display: none; }
.chan-manage:hover, .group-head .manage-btn:hover { border-color: transparent; color: var(--accent); }
.group-head .manage-btn { border-color: transparent; width: 22px; }
.chan.dragging { opacity: 0.4; background: rgba(var(--accent-rgb), 0.12); border-left-color: var(--accent); }
.hover-tip { position: fixed; z-index: 450; pointer-events: none; background: var(--bg-1); border: 1px solid var(--rule-strong); border-right: 2px solid var(--accent); color: var(--text); font-family: var(--font-mono); font-size: 0.92rem; letter-spacing: 0.02em; padding: 7px 12px; white-space: nowrap; box-shadow: 0 12px 30px -12px #000; }
.hover-tip::after { content: ''; position: absolute; right: -8px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-left-color: var(--accent); border-right: 0; }
.group-head .icon-btn svg { width: 14px; height: 14px; }
.group-head .rule-mark { width: 14px; }

.chan { display: flex; align-items: center; gap: 10px; padding: 2px 14px 2px 10px; line-height: 1.45; margin: 0 8px; border-radius: 6px; color: var(--text-dim); cursor: pointer; position: relative; font-size: 1.12rem; border-left: 2px solid transparent; transition: background 0.15s ease, color 0.15s ease; }
.chan:hover { background: var(--bg-2); color: var(--text); outline: 1px solid var(--rule-strong); outline-offset: -1px; }
.chan.active { background: rgba(var(--accent-rgb), 0.08); color: var(--text); }
.chan.unread { color: var(--text); font-weight: 500; }
.chan.muted { opacity: 0.5; }
.chan-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-lock { width: 14px; height: 14px; margin-left: 7px; vertical-align: -1px; stroke: var(--text-muted); fill: none; stroke-width: 2; }
.chan-icon { width: 22px; height: 22px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 700; font-size: 0.82rem; border: 1px solid; position: relative; }
.chan-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chan-icon.lg { width: 34px; height: 34px; font-size: 1.05rem; }
.chan-icon.xl { width: 64px; height: 64px; font-size: 1.8rem; }
.chan-icon .lock { position: absolute; right: -6px; bottom: -6px; width: 16px; height: 16px; background: var(--bg-1); border-radius: 50%; padding: 2px; stroke: var(--text-dim); fill: none; stroke-width: 2; }
.chan-icon.lg .lock { right: -7px; bottom: -7px; width: 19px; height: 19px; }
.chan-icon.xl .lock { right: -9px; bottom: -9px; width: 28px; height: 28px; padding: 4px; }
.chan .avatar, .chan .chan-icon { width: 30px; height: 30px; }
.chan-hash { width: 30px; flex-shrink: 0; text-align: center; font-family: var(--font-mono); font-weight: 700; font-size: 1.55rem; line-height: 1; position: relative; }
.chan-icon.bare { border: 0 !important; background: transparent !important; }

.badge { font-family: var(--font-mono); font-size: 0.68rem; min-width: 20px; height: 18px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--rule-strong); color: var(--text-dim); background: var(--bg); flex-shrink: 0; }
.badge.mention { border-color: var(--accent); color: var(--text); background: rgba(var(--accent-rgb), 0.25); }

.side-link { display: flex; align-items: center; gap: 10px; padding: 6px 18px; font-size: 0.82rem; color: var(--text-muted); cursor: pointer; font-family: var(--font-mono); letter-spacing: 0.04em; }
.side-link:hover { color: var(--accent); }
.side-link svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.6; }

.me-card { border-top: 1px solid var(--rule); padding: 10px 10px 10px 14px; display: flex; align-items: center; gap: 4px; flex-shrink: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.me-card .who { flex: 1; min-width: 0; cursor: pointer; margin-left: 6px; }
.me-card .icon-btn { width: 30px; }
.me-card .who b { display: block; font-weight: 500; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar { width: 34px; height: 34px; position: relative; flex-shrink: 0; display: inline-block; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--bg-2); }
.avatar .presence { position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--bg-1); background: transparent; }
.avatar .presence.online { background: var(--online); box-shadow: 0 0 8px rgba(76, 195, 138, 0.7); animation: onlineBlip 3s ease-in-out infinite; }
.avatar .presence.idle { background: var(--idle); box-shadow: 0 0 6px rgba(232, 197, 71, 0.55); }
@keyframes onlineBlip { 0%, 100% { box-shadow: 0 0 4px rgba(76, 195, 138, 0.5); } 50% { box-shadow: 0 0 11px rgba(76, 195, 138, 0.95); } }

/* MAIN */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.chat-head { height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 14px 0 20px; border-bottom: 1px solid var(--rule); flex-shrink: 0; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.chat-title-text { min-width: 0; }
.chat-title-text b { display: block; font-family: var(--font-serif); font-weight: 400; font-size: 1.15rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.chat-title-text span { display: block; font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-actions { display: flex; align-items: center; gap: 2px; }
.only-mobile { display: none !important; }

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 0 8px; scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; overscroll-behavior: contain; }
.messages-inner { display: flex; flex-direction: column; }
.history-edge { padding: 32px 24px 20px; }
.history-edge .chan-icon { margin-bottom: 16px; }
.history-edge h2 { margin-bottom: 6px; }
.history-edge p { font-size: 0.92rem; max-width: 640px; }
.loader { display: flex; justify-content: center; padding: 18px; }
.loader .art { width: 46px; height: 46px; }

.day { display: flex; align-items: center; gap: 14px; margin: 18px 24px 6px; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.14em; color: var(--text-muted); text-transform: lowercase; }
.day::before, .day::after { content: ''; flex: 1; height: 1px; background: var(--rule); }
.new-divider { display: flex; align-items: center; gap: 12px; margin: 8px 24px; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.14em; color: var(--accent); text-transform: lowercase; }
.new-divider::after { content: ''; flex: 1; height: 1px; background: rgba(var(--accent-rgb), 0.5); }

.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 14px; padding: 3px 24px 3px 22px; position: relative; border-left: 2px solid transparent; transition: background 0.15s ease; }
.msg:hover, .msg.menu-open { background: color-mix(in srgb, var(--text) 3%, transparent); }
.msg.head { margin-top: 12px; padding-top: 5px; }
.msg.mentioned { background: rgba(var(--accent-rgb), 0.06); border-left-color: var(--accent); }
.msg.flash-hl { animation: flashHl 2.4s ease; }
@keyframes flashHl { 0%, 30% { background: rgba(var(--accent-rgb), 0.18); } 100% { background: transparent; } }
.msg .avatar { width: 38px; height: 38px; cursor: pointer; margin-top: 2px; }
.msg-main { min-width: 0; }
.sys-line { display: flex; align-items: baseline; gap: 10px; padding: 3px 24px 3px 30px; margin: 4px 0; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }
.sys-line .sys-arrow { color: var(--accent); opacity: 0.7; width: 28px; text-align: center; flex-shrink: 0; }
.sys-line [data-user] { cursor: pointer; }
.sys-line [data-user]:hover { color: var(--text-dim); }
.sys-line .sys-time { font-size: 0.68rem; opacity: 0.8; }
.msg .gutter-time { font-family: var(--font-mono); font-size: 0.64rem; color: var(--text-muted); opacity: 0; text-align: right; padding-top: 4px; white-space: nowrap; }
.msg:hover .gutter-time { opacity: 1; }
.msg-meta { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.msg-author { font-weight: 600; font-size: 0.92rem; cursor: pointer; }
.msg-author:hover { text-decoration: underline; text-underline-offset: 3px; }
/* one width for every role tag, one colour per role */
.role-tag { --tag: var(--text-dim); display: inline-block; min-width: 5.4em; text-align: center; font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--tag); border: 1px solid color-mix(in srgb, var(--tag) 45%, transparent); padding: 0 5px; line-height: 1.5; }
.role-tag.admin { --tag: var(--danger); }
.role-tag.mod { --tag: var(--idle); }
.role-tag.bot { --tag: #5b9cf0; }
:root[data-mode="light"] .role-tag.bot { --tag: #2f6fd0; }
.msg-time { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); letter-spacing: 0.04em; }
.pin-label { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); border: 1px solid rgba(var(--accent-rgb), 0.4); padding: 0 5px; line-height: 1.5; }
.msg.pinned { border-left-color: var(--accent); }
.msg .gutter-stack { display: grid; align-self: start; }
.msg .gutter-stack > * { grid-area: 1 / 1; }
.msg .gutter-pin { justify-self: end; align-self: start; margin-top: 4px; font-size: 0.5rem; padding: 0 3px; }
.msg:hover .gutter-pin { visibility: hidden; }
.pin-btn { position: relative; }
.pin-count { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: var(--bg); font-family: var(--font-mono); font-size: 0.62rem; font-weight: 700; line-height: 16px; text-align: center; }
.pin-bar { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 20px; border-bottom: 1px solid var(--rule); background: var(--bg-1); flex-shrink: 0; min-width: 0; }
.pin-bar > svg { width: 16px; height: 16px; stroke: var(--accent); fill: none; stroke-width: 2; flex-shrink: 0; }
.pin-bar .pin-text { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.pin-bar .pin-pos { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); flex-shrink: 0; }
.pin-bar b { font-weight: 600; font-size: 0.88rem; flex-shrink: 0; }
.pin-bar .pin-excerpt { font-size: 0.88rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
.pin-bar .pin-text:hover .pin-excerpt { color: var(--text); }
.pin-bar .icon-btn { width: 28px; height: 28px; flex-shrink: 0; }

.msg-body { font-family: var(--font-mono); font-size: var(--msg-size); line-height: 1.6; color: var(--text-body); overflow-wrap: anywhere; min-width: 0; }
.msg-body > :last-child { margin-bottom: 0; }
.msg-body p { color: inherit; margin: 0 0 0.45em; }
.msg-body a { color: var(--accent); border-bottom: 1px solid rgba(var(--accent-rgb), 0.35); }
.msg-body a:hover { color: var(--text); border-bottom-color: var(--text); }
.msg-body strong { color: var(--text); font-weight: 700; }
.msg-body em { font-style: italic; }
.msg-body del, .msg-body s { color: var(--text-muted); }
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4, .msg-body h5, .msg-body h6 { font-family: var(--font-mono); font-weight: 700; margin: 0.4em 0 0.3em; letter-spacing: 0; text-transform: none; color: var(--text); }
.msg-body h1 { font-size: 1.3em; } .msg-body h2 { font-size: 1.18em; } .msg-body h3 { font-size: 1.08em; } .msg-body h4, .msg-body h5, .msg-body h6 { font-size: 1em; }
.msg-body ul, .msg-body ol { margin: 0.2em 0 0.5em; padding-left: 1.6em; }
.msg-body ul { list-style: none; }
.msg-body ul li::before { content: '—'; color: var(--text-muted); margin-left: -1.6em; width: 1.6em; display: inline-block; }
.msg-body blockquote { margin: 0.3em 0 0.5em; padding: 2px 0 2px 14px; border-left: 2px solid var(--rule-strong); color: var(--text-dim); }
.msg-body code { font-family: var(--font-mono); font-size: 0.92em; tab-size: 4; background: var(--bg-2); border: 1px solid var(--rule); padding: 1px 5px; }
.msg-body pre { background: var(--bg-1); border: 1px solid var(--rule); border-left: 2px solid rgba(var(--accent-rgb), 0.6); padding: 12px 14px; margin: 0.4em 0 0.6em; overflow-x: auto; max-width: 100%; line-height: 1.5; }
.msg-body pre code { background: none; border: 0; padding: 0; font-size: 0.92em; white-space: pre; }
.msg-body table { border-collapse: collapse; margin: 0.4em 0 0.6em; display: block; overflow-x: auto; max-width: 100%; }
.msg-body th, .msg-body td { border: 1px solid var(--rule-strong); padding: 5px 10px; text-align: left; }
.msg-body th { background: var(--bg-2); color: var(--text); font-weight: 500; }
.msg-body hr { border: 0; border-top: 1px solid var(--rule-strong); margin: 0.8em 0; }
.msg-body img.emoji { width: 1.4em; height: 1.4em; vertical-align: -0.35em; object-fit: contain; }
.msg-body.jumbo { font-size: 2.2em; line-height: 1.3; }
.msg-body.jumbo img.emoji { width: 1.3em; height: 1.3em; }
.msg-edited { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-muted); margin-left: 4px; }

.mention { background: rgba(var(--accent-rgb), 0.14); color: var(--text); padding: 0 3px; cursor: pointer; border: 1px solid rgba(var(--accent-rgb), 0.25); }
.mention.me, .mention-all { background: rgba(var(--accent-rgb), 0.32); border-color: rgba(var(--accent-rgb), 0.7); }

/* user-chosen text colors (allowed exception to the single-accent rule: this is user content) */
.c-red { color: #e5484d; } .c-orange { color: #f08c3a; } .c-yellow { color: #e8c547; } .c-green { color: #4cc38a; } .c-cyan { color: #3fc1c9; } .c-blue { color: #5b9cf0; } .c-purple { color: #a57cf0; } .c-pink { color: #e66bb0; } .c-brown { color: #a0714f; } .c-white { color: #ece8df; } .c-grey, .c-gray { color: #8d8a82; } .c-black { color: #0b0b0b; }
.bg-red { background: #e5484d; } .bg-orange { background: #f08c3a; } .bg-yellow { background: #e8c547; } .bg-green { background: #4cc38a; } .bg-cyan { background: #3fc1c9; } .bg-blue { background: #5b9cf0; } .bg-purple { background: #a57cf0; } .bg-pink { background: #e66bb0; } .bg-brown { background: #a0714f; } .bg-white { background: #ece8df; } .bg-grey, .bg-gray { background: #8d8a82; } .bg-black { background: #0b0b0b; }
.msg-body [class^='bg-'], .msg-body span[style*='background'] { padding: 0 3px; }

/* pygments: tuned to the house palette */
.hl-k, .hl-kd, .hl-kn, .hl-kr, .hl-kc, .hl-kt, .hl-ow { color: var(--hl-keyword); }
.hl-s, .hl-s1, .hl-s2, .hl-sb, .hl-sd, .hl-se, .hl-sh, .hl-si, .hl-sx, .hl-sr, .hl-ss, .hl-sa, .hl-dl { color: var(--hl-string); }
.hl-c, .hl-c1, .hl-cm, .hl-cp, .hl-cs, .hl-ch, .hl-cpf { color: var(--hl-comment); font-style: italic; }
.hl-m, .hl-mi, .hl-mf, .hl-mh, .hl-mo, .hl-il, .hl-mb { color: var(--hl-number); }
.hl-nf, .hl-fm, .hl-nc, .hl-nn { color: var(--hl-function); }
.hl-nb, .hl-bp, .hl-nd { color: var(--hl-builtin); }
.hl-o, .hl-p { color: var(--hl-operator); }
.hl-na, .hl-nt { color: var(--hl-attr); }
.hl-gd { color: var(--danger); } .hl-gi { color: var(--online); } .hl-gh, .hl-gu { color: var(--text); font-weight: 700; }
.hl-err { color: #e5484d; }

.reply-ref { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--text-muted); margin: 0 0 3px; cursor: pointer; min-width: 0; font-family: var(--font-mono); }
.reply-ref::before { content: ''; width: 18px; height: 9px; border-left: 1px solid var(--rule-strong); border-top: 1px solid var(--rule-strong); margin-top: 7px; flex-shrink: 0; }
.reply-ref b { color: var(--text-dim); font-weight: 500; flex-shrink: 0; }
.reply-ref span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-ref:hover span { color: var(--text-dim); }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 2px; }
.att-img { display: block; max-width: min(420px, 100%); border: 1px solid var(--rule); cursor: zoom-in; background: var(--bg-1); }
.att-img img { display: block; max-width: 100%; max-height: 340px; width: auto; height: auto; }
.att-video { max-width: min(480px, 100%); border: 1px solid var(--rule); background: #000; }
.att-video video { display: block; max-width: 100%; max-height: 360px; }
.att-audio { width: min(420px, 100%); }
.att-audio audio { width: 100%; }
.att-file { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--rule-strong); background: var(--bg-1); max-width: min(380px, 100%); }
.att-file svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 1.4; flex-shrink: 0; }
.att-file div { min-width: 0; }
.att-file b { display: block; font-weight: 500; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-file span { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); }

.preview { display: flex; gap: 14px; margin: 8px 0 2px; padding: 10px 12px; border: 1px solid var(--rule); border-left: 2px solid rgba(var(--accent-rgb), 0.6); background: var(--bg-1); max-width: 520px; }
.preview .pv-text { min-width: 0; flex: 1; }
.preview .pv-site { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.preview a { display: block; font-weight: 500; font-size: 0.9rem; color: var(--text); margin: 2px 0; }
.preview a:hover { color: var(--accent); }
.preview p { font-size: 0.8rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.preview img { width: 96px; height: 72px; object-fit: cover; border: 1px solid var(--rule); flex-shrink: 0; }

.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.reaction { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border: 1px solid var(--rule-strong); background: var(--bg-1); color: var(--text-dim); font-family: var(--font-mono); font-size: 0.74rem; cursor: pointer; line-height: 1.7; transition: border-color 0.15s ease; }
.reaction:hover { border-color: var(--text-dim); }
.reaction.mine { border-color: rgba(var(--accent-rgb), 0.7); background: rgba(var(--accent-rgb), 0.12); color: var(--text); }
.reaction .r-emoji { font-size: 1rem; line-height: 1; }
.poll { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-width: 520px; }
.poll-opt { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; border: 1px solid var(--rule-strong); background: var(--bg-1); color: var(--text); font: inherit; text-align: left; cursor: pointer; overflow: hidden; transition: border-color 0.15s ease; }
.poll-opt:hover { border-color: var(--text-dim); }
.poll-opt.mine { border-color: rgba(var(--accent-rgb), 0.7); }
.poll-bar { position: absolute; inset: 0 auto 0 0; background: rgba(var(--accent-rgb), 0.14); pointer-events: none; }
.poll-label { position: relative; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.poll-count { position: relative; font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-dim); white-space: nowrap; }
.poll-total { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }
.poll-options { display: flex; flex-direction: column; gap: 8px; }
.reaction img { width: 18px; height: 18px; object-fit: contain; }

.msg-actions { position: absolute; right: 18px; top: -20px; display: none; background: var(--bg-1); border: 1px solid var(--rule-strong); z-index: 5; box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.8); }
.msg:hover .msg-actions, .msg.menu-open .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 42px; height: 40px; border: 0; }
.msg-actions .icon-btn svg { width: 21px; height: 21px; }
.msg-actions .icon-btn.danger:hover { color: var(--danger); }

.edit-box textarea { font-family: var(--font-mono); font-size: var(--msg-size); min-height: 60px; }
.edit-box .hint { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

.jump-new { position: absolute; left: 50%; transform: translateX(-50%); bottom: 150px; z-index: 6; }

/* compact mode */
.compact .msg { grid-template-columns: 26px minmax(0, 1fr); column-gap: 10px; padding-top: 1px; padding-bottom: 1px; }
.compact .msg.head { margin-top: 6px; padding-top: 3px; }
.compact .msg .avatar { width: 24px; height: 24px; }
.compact .msg .gutter-time { display: none; }

/* COMPOSER */
.typing { height: 22px; padding: 0 24px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; flex-shrink: 0; overflow: hidden; white-space: nowrap; }
.typing .dots { display: inline-flex; gap: 3px; }
.typing .dots i { width: 4px; height: 4px; background: var(--accent); border-radius: 50%; animation: typingDot 1.2s ease-in-out infinite; }
.typing .dots i:nth-child(2) { animation-delay: 0.15s; } .typing .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.composer { padding: 0 20px 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); flex-shrink: 0; position: relative; }
.composer-box { border: 1px solid var(--rule-strong); background: var(--bg-1); transition: border-color 0.15s ease; }
.composer-box:focus-within { border-color: rgba(var(--accent-rgb), 0.55); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.12); }
.composer-box.drag { border-color: var(--accent); border-style: dashed; }
.composer-bar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--rule); font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-muted); }
.composer-bar b { color: var(--text-dim); font-weight: 500; }
.composer-bar span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-bar .icon-btn { width: 24px; height: 24px; }
.composer-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px 0; }
.file-chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--rule-strong); padding: 4px 4px 4px 8px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-dim); max-width: 240px; position: relative; overflow: hidden; background: var(--bg); }
.file-chip img { width: 28px; height: 28px; object-fit: cover; }
.file-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .icon-btn { width: 22px; height: 22px; }
.file-chip .progress { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); transition: width 0.2s ease; }
.file-chip.error { border-color: var(--danger); color: var(--danger); }
.composer-row { display: flex; align-items: flex-end; gap: 4px; padding: 4px 6px 4px 4px; }
.composer textarea { flex: 1; tab-size: 4; border: 0; background: transparent; resize: none; min-height: 0; max-height: 40vh; padding: 11px 8px; font-family: 'JetBrains Mono', 'Emoji Large', ui-monospace, 'SF Mono', Menlo, monospace; font-size: var(--msg-size); line-height: 1.6; box-shadow: none !important; }
.composer .icon-btn { margin-bottom: 5px; }
.composer .send { color: var(--accent); }
.composer-tools { display: flex; align-items: center; gap: 2px; padding: 0 6px 4px; border-top: 1px solid var(--rule); }
.composer-tools .icon-btn { width: 46px; height: 40px; margin: 3px 0 0; }
.composer-tools .icon-btn svg { width: 22px; height: 22px; }
.composer-tools .send { margin-left: auto; }
.composer-tools .send svg { width: 24px; height: 24px; }
.composer-tools .fmt { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 700; }
.composer-tools .icon-btn.active { color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }
.composer-preview { flex: 1; min-width: 0; min-height: 44px; max-height: 40vh; overflow-y: auto; padding: 11px 8px; cursor: text; }
.composer-preview > :last-child { margin-bottom: 0; }
.composer-box.collapsed { cursor: text; }
.composer-box.collapsed .topic-row, .composer-box.collapsed .composer-tools, .composer-box.collapsed .reply-bar, .composer-box.collapsed .composer-files { display: none !important; }
.composer-box.collapsed .composer-row { padding: 2px 6px 2px 4px; }
.composer-box.collapsed textarea { min-height: 0; padding: 8px 8px; overflow: hidden; }
.composer-box.collapsed .composer-row .icon-btn { margin-bottom: 2px; }
.composer-locked { padding: 14px; text-align: center; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); border: 1px dashed var(--rule-strong); letter-spacing: 0.06em; }

/* POPOVERS */
.popover { position: fixed; z-index: 300; background: var(--bg-1); border: 1px solid var(--rule-strong); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.9); }
.autocomplete { max-height: 280px; overflow-y: auto; width: min(360px, calc(100vw - 24px)); padding: 4px 0; }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 6px 12px; cursor: pointer; font-size: 0.86rem; color: var(--text-dim); }
.ac-item.sel, .ac-item:hover { background: rgba(var(--accent-rgb), 0.12); color: var(--text); }
.ac-item .avatar { width: 22px; height: 22px; }
.ac-item .ac-emoji { width: 28px; text-align: center; font-size: 1.45rem; line-height: 1; }
.ac-item img.ac-emoji { height: 26px; object-fit: contain; }
.ac-item small { margin-left: auto; font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); }

.emoji-picker { width: min(400px, calc(100vw - 16px)); height: min(440px, 62vh); display: flex; flex-direction: column; }
.emoji-picker .ep-search { padding: 10px; border-bottom: 1px solid var(--rule); }
.emoji-picker .ep-search input { padding: 8px 10px; font-size: 14px; }
.emoji-picker .ep-tabs { display: flex; border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.emoji-picker .ep-tabs button { flex: 1; min-width: 34px; background: transparent; border: 0; border-bottom: 1px solid transparent; color: var(--text-muted); padding: 7px 0; cursor: pointer; font-size: 1rem; filter: grayscale(1); opacity: 0.6; }
.emoji-picker .ep-tabs button.active, .emoji-picker .ep-tabs button:hover { filter: none; opacity: 1; border-bottom-color: var(--accent); }
.emoji-picker .ep-body { flex: 1; overflow-y: auto; padding: 6px 8px 10px; scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
.emoji-picker .ep-group { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.14em; color: var(--text-muted); padding: 8px 4px 4px; text-transform: lowercase; }
.emoji-picker .ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
.emoji-picker .ep-grid button { background: transparent; border: 1px solid transparent; font-size: 1.7rem; height: 44px; cursor: pointer; padding: 0; line-height: 1; display: flex; align-items: center; justify-content: center; }
.emoji-picker .ep-grid button:hover { border-color: var(--rule-strong); background: var(--bg-2); }
.emoji-picker .ep-grid img { width: 32px; height: 32px; object-fit: contain; }
.emoji-picker .ep-foot { border-top: 1px solid var(--rule); padding: 6px 12px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-dim); height: 32px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.color-picker { padding: 10px; width: 236px; }
.color-picker .cp-label { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.14em; color: var(--text-muted); margin: 0 0 6px; text-transform: lowercase; }
.color-picker .cp-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 10px; }
.color-picker .cp-grid button { height: 26px; border: 1px solid var(--rule-strong); cursor: pointer; }
.color-picker .cp-grid button:hover { outline: 1px solid var(--text); outline-offset: 1px; }
.color-picker .cp-custom { display: flex; gap: 6px; align-items: center; }
.color-picker .cp-custom input[type=color] { height: 30px; width: 40px; }

.menu { min-width: 200px; padding: 4px 0; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; background: transparent; border: 0; color: var(--text-dim); padding: 8px 14px; font-family: var(--font-sans); font-size: 0.86rem; text-align: left; cursor: pointer; }
.menu button:hover, .menu a:hover { background: rgba(var(--accent-rgb), 0.1); color: var(--text); }
.menu .danger { color: var(--danger); }
.menu svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.5; flex-shrink: 0; }
.menu hr { border: 0; border-top: 1px solid var(--rule); margin: 4px 0; }

/* MODALS */
.modal-back { position: fixed; inset: 0; z-index: 200; background: rgba(5, 5, 5, 0.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; }
.modal { width: min(560px, 100%); max-height: 84vh; display: flex; flex-direction: column; background: var(--bg-1); border: 1px solid var(--rule-strong); box-shadow: 0 30px 90px -30px #000; position: relative; }
.modal.wide { width: min(760px, 100%); }
.modal::before, .modal::after { content: ''; position: absolute; width: 10px; height: 10px; border-color: var(--accent); border-style: solid; pointer-events: none; }
.modal::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.modal::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px 22px; border-bottom: 1px solid var(--rule); }
.modal-head h3 { margin: 0; flex: 1; font-family: var(--font-serif); font-weight: 400; font-size: 1.3rem; }
.modal-body { padding: 18px 22px 22px; overflow-y: auto; }
.modal-body .msg { padding-left: 0; padding-right: 0; }
.modal-body .msg .msg-actions { display: none !important; }
.modal-search { display: flex; gap: 10px; }
.result { border: 1px solid var(--rule); margin-bottom: 10px; cursor: pointer; transition: border-color 0.15s ease; padding: 8px 12px 10px; background: var(--bg); }
.result:hover { border-color: var(--rule-strong); }
.result-chan { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.result-chan .chan-icon { width: 18px; height: 18px; font-size: 0.7rem; }
.result-chan .avatar { width: 18px; height: 18px; }
.result-chan b { color: var(--text-dim); font-weight: 500; }
.result-chan .jump { margin-left: auto; color: var(--text-muted); letter-spacing: 0.12em; }
.result:hover .result-chan .jump { color: var(--accent); }
.result mark { background: rgba(var(--accent-rgb), 0.35); color: var(--text); padding: 0 1px; }

/* SEARCH VIEW (replaces the chat column) */
.main.searching > .chat-head, .main.searching > .messages, .main.searching > .typing, .main.searching > .composer, .main.searching > .jump-new, .main.searching > .conn-banner { display: none !important; }
.search-view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.main.searching > .search-view { display: flex; }
.search-head { min-height: var(--header-h); display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 20px; border-bottom: 1px solid var(--rule); flex-shrink: 0; flex-wrap: wrap; }
.search-box { flex: 1 1 280px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--rule-strong); background: var(--bg-1); padding: 0 12px; min-width: 0; }
.search-box:focus-within { border-color: rgba(var(--accent-rgb), 0.6); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.12); }
.search-box svg { width: 16px; height: 16px; stroke: var(--text-muted); fill: none; stroke-width: 1.6; flex-shrink: 0; }
.search-box input { border: 0; background: transparent; padding: 10px 0; box-shadow: none !important; font-family: var(--font-mono); font-size: 15px; }
.search-head select { width: auto; flex: 0 1 190px; min-width: 0; padding: 9px 34px 9px 12px; font-size: 14px; }
.search-summary { padding: 14px 24px 6px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; color: var(--text-muted); text-transform: lowercase; display: flex; align-items: center; gap: 10px; }
.search-results { flex: 1; overflow-y: auto; padding: 4px 24px 24px; scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
.search-results .msg { padding-left: 0; padding-right: 0; }
.search-results .msg .msg-actions { display: none !important; }
.search-results .more { display: flex; justify-content: center; padding: 10px 0 4px; }

/* FORMATTING GUIDE POPOVER */
.format-guide { width: min(460px, calc(100vw - 16px)); max-height: min(560px, 70vh); overflow-y: auto; padding: 14px 16px 16px; }
.format-guide .fg-section { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.14em; color: var(--text-muted); text-transform: lowercase; margin: 12px 0 8px; display: flex; align-items: center; gap: 8px; }
.format-guide .fg-section:first-child { margin-top: 0; }
.format-guide .fg-section .rule-mark { width: 14px; }
.format-guide .cheatsheet { grid-template-columns: minmax(0, auto) 1fr; gap: 6px 14px; font-size: 0.8rem; }
.format-guide .cheatsheet code { font-size: 0.76rem; white-space: normal; word-break: break-word; }

/* TWO-FACTOR */
.totp-setup { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; margin-top: 8px; }
.totp-qr svg { display: block; width: 200px; height: 200px; border: 1px solid var(--rule-strong); }
.totp-setup .form { flex: 1 1 260px; }
.totp-secret { display: block; font-family: var(--font-mono); font-size: 0.86rem; letter-spacing: 0.08em; color: var(--text); background: var(--bg-2); border: 1px solid var(--rule); padding: 8px 12px; word-break: break-all; }
.code-input { font-family: var(--font-mono) !important; font-size: 1.3rem !important; letter-spacing: 0.3em; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 4px 0 18px; }
.recovery-codes span { border: 1px solid var(--rule-strong); background: var(--bg); padding: 8px 10px; text-align: center; color: var(--text); font-size: 0.92rem; letter-spacing: 0.06em; user-select: all; }
.empty-state { text-align: center; padding: 30px 10px; }
.empty-state .art { width: 160px; height: auto; margin: 0 auto 14px; display: block; }
.empty-state p { font-size: 0.9rem; margin: 0; }
.history-edge .empty-state p { max-width: none; }

.browse-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.browse-item:last-child { border-bottom: 0; }
.browse-item > div { flex: 1; min-width: 0; }
.browse-item > div > b { display: block; font-weight: 500; }
.browse-item > div > span { display: block; font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pick-list { max-height: 46vh; overflow-y: auto; margin-top: 12px; }
.pick-user { display: flex; align-items: center; gap: 12px; padding: 7px 4px; cursor: pointer; }
.pick-user:hover { background: var(--bg-2); }
.pick-user .check { flex: 1; align-items: center; }

.profile-card { text-align: left; }
.profile-top { display: flex; gap: 18px; align-items: center; margin-bottom: 16px; }
.profile-top .avatar { width: 84px; height: 84px; }
.profile-top .avatar .presence { width: 16px; height: 16px; border-width: 3px; }
.profile-top h2 { margin: 0 0 2px; }
.profile-top .handle { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); }
.profile-bio { font-size: 0.92rem; white-space: pre-wrap; }
.profile-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 0.84rem; margin: 14px 0 18px; }
.profile-facts dt { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; color: var(--text-muted); }
.profile-facts dd { margin: 0; color: var(--text-dim); }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.lightbox { position: fixed; inset: 0; z-index: 400; background: rgba(5, 5, 5, 0.94); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid var(--rule); }
.lightbox a { position: absolute; top: 18px; right: 22px; font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.12em; color: var(--text-dim); border: 1px solid var(--rule-strong); padding: 6px 12px; }

.toasts { position: fixed; z-index: 500; top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + 12px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100vw - 32px)); }
.toast { background: var(--bg-1); border: 1px solid var(--rule-strong); border-left: 2px solid var(--accent); padding: 10px 16px; font-size: 0.86rem; color: var(--text); box-shadow: 0 16px 40px -16px #000; animation: toastIn 0.25s ease; width: 100%; }
.toast.error { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.conn-banner { position: absolute; top: calc(var(--header-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 10px; background: var(--bg-1); border: 1px solid var(--rule-strong); padding: 6px 14px 6px 8px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; color: var(--text-dim); }
.conn-banner .art { width: 26px; height: 26px; }

.boot { position: fixed; inset: 0; z-index: 600; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; transition: opacity 0.35s ease; }
.boot .art { width: 120px; height: 120px; }
.boot.done { opacity: 0; pointer-events: none; }

/* RIGHT: members */
.member-filter { height: var(--header-h); display: flex; align-items: center; padding: 0 14px; border-bottom: 1px solid var(--rule); flex-shrink: 0; }
.member-filter input { padding: 8px 12px; font-size: 14px; font-family: var(--font-mono); background: var(--bg); border-color: var(--rule); }
.member { display: flex; align-items: center; gap: 12px; padding: 6px 14px 6px 18px; cursor: pointer; min-width: 0; }
.member:hover { background: var(--bg-2); }
.member .avatar { width: 40px; height: 40px; }
.member .avatar img, .msg .avatar img { border-radius: 8px; }
.member .avatar .presence { width: 13px; height: 13px; }
.member .m-text { min-width: 0; flex: 1; }
.member b { display: flex; align-items: center; gap: 7px; font-weight: 500; font-size: 1.12rem; color: var(--text); white-space: nowrap; overflow: hidden; }
.member b .nm { overflow: hidden; text-overflow: ellipsis; }
.member .m-status { display: block; font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member.offline { opacity: 0.42; }
.member.offline .avatar img { filter: grayscale(0.8); }
.member .role-tag { font-size: 0.55rem; padding: 0 4px; margin-left: auto; flex-shrink: 0; }

.backdrop { display: none; }

/* ================================================================ PAGES (settings / admin) */

.page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.page-head { position: sticky; top: 0; z-index: 50; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--rule); }
.page-head nav { display: flex; gap: 22px; align-items: center; }
.page-head nav a { color: var(--text-dim); font-size: 0.84rem; }
.page-head nav a:hover { color: var(--text); }
.page-wrap { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 48px 32px 80px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 56px; align-items: start; }
.page-nav { position: sticky; top: 112px; display: flex; flex-direction: column; gap: 2px; }
.page-nav a { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; border-left: 2px solid transparent; color: var(--text-dim); font-size: 0.9rem; }
.page-nav a:hover { color: var(--text); background: var(--bg-1); }
.page-nav a.active { color: var(--text); border-left-color: var(--accent); background: var(--bg-1); }
.page-nav .badge { margin-left: 8px; }
.page-nav .nav-label { margin: 22px 0 6px; padding: 0 14px; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.14em; color: var(--text-muted); }
.page-main { min-width: 0; }
.page-main > h1 { margin-bottom: 10px; }
.page-main > .lede { margin-bottom: 36px; max-width: 640px; }
.panel { border: 1px solid var(--rule); background: var(--bg-1); padding: 26px 28px; margin-bottom: 26px; }
.panel.accent { border-left: 2px solid var(--accent); }
.panel.danger { border-color: rgba(229, 72, 77, 0.3); }
.panel h3 { font-family: var(--font-serif); font-weight: 400; font-size: 1.25rem; margin-bottom: 4px; }
.panel > p { font-size: 0.9rem; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--rule); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th { text-align: left; font-family: var(--font-mono); font-weight: 400; font-size: 0.68rem; letter-spacing: 0.14em; text-transform: lowercase; color: var(--text-muted); padding: 12px 14px; border-bottom: 1px solid var(--rule); background: var(--bg-1); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; color: var(--text-dim); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: color-mix(in srgb, var(--text) 2%, transparent); }
table.data td.who { color: var(--text); min-width: 180px; }
table.data .who-cell { display: flex; align-items: center; gap: 12px; }
table.data .avatar { width: 30px; height: 30px; }
table.data .mono { font-size: 0.78rem; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { padding: 7px 10px; font-size: 14px; width: auto; }
.inline-form select { padding-right: 32px; }
#channel-table .group-row td { padding: 14px 14px 6px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: lowercase; color: var(--text-muted); background: transparent; }
#channel-table tr[draggable] { cursor: grab; }
#channel-table tr.dragging { opacity: 0.4; }
#channel-table .drag-cell { width: 28px; padding-right: 0; color: var(--text-muted); }
#channel-table .drag-cell svg { display: block; width: 16px; height: 16px; fill: currentColor; }
#channel-table .drop-row td { padding: 10px 14px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); text-align: center; border: 1px dashed var(--rule); }
#channel-table tbody:has(tr[draggable]) .drop-row { display: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.status-pill { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; padding: 1px 7px; border: 1px solid var(--rule-strong); color: var(--text-dim); white-space: nowrap; }
.status-pill.active { color: var(--online); border-color: rgba(76, 195, 138, 0.4); }
.status-pill.pending { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.5); }
.status-pill.banned, .status-pill.denied { color: var(--danger); border-color: rgba(229, 72, 77, 0.4); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filters a { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.08em; color: var(--text-dim); border: 1px solid var(--rule); padding: 5px 12px; }
.filters a.active { color: var(--text); border-color: var(--accent); }
.filters form { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.filters input { padding: 7px 12px; font-size: 14px; width: 220px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatches label { width: 28px; height: 28px; border: 1px solid var(--rule-strong); cursor: pointer; position: relative; }
.swatches input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatches label:has(input:checked) { outline: 1px solid var(--text); outline-offset: 2px; }
.avatar-edit { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.avatar-edit .avatar { width: 84px; height: 84px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.emoji-card { border: 1px solid var(--rule); padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.emoji-card img { width: 40px; height: 40px; object-fit: contain; }
.emoji-card code { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-dim); word-break: break-all; }
.empty-row { padding: 40px 16px; text-align: center; color: var(--text-muted); }
.empty-row .art { width: 150px; margin: 0 auto 12px; display: block; }
.pager { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.cheatsheet { display: grid; grid-template-columns: auto 1fr; gap: 8px 22px; font-size: 0.86rem; align-items: baseline; }
.cheatsheet code { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text); background: var(--bg-2); border: 1px solid var(--rule); padding: 1px 6px; white-space: nowrap; }
.cheatsheet span { color: var(--text-dim); }

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

@media (max-width: 1180px) {
	.app { grid-template-columns: var(--left-w) minmax(0, 1fr) 0; }
	.app .right { position: fixed; top: 0; right: 0; bottom: 0; width: min(300px, 86vw); z-index: 120; transform: translateX(100%); transition: transform 0.25s ease; display: flex; }
	.app.show-right .right { transform: none; box-shadow: -30px 0 60px -20px #000; }
	.app.hide-right .right { display: flex; }
	.app.show-right .backdrop { display: block; }
}

@media (max-width: 860px) {
	:root { --header-h: 56px; }
	.app, .app.hide-right { grid-template-columns: minmax(0, 1fr); }
	.app .left { position: fixed; top: 0; left: 0; bottom: 0; width: min(310px, 86vw); z-index: 120; transform: translateX(-100%); transition: transform 0.25s ease; }
	.app.show-left .left { transform: none; box-shadow: 30px 0 60px -20px #000; }
	.app.show-left .backdrop { display: block; }
	.backdrop { position: fixed; inset: 0; z-index: 110; background: rgba(5, 5, 5, 0.6); }
	.only-mobile { display: inline-flex !important; }
	.chat-head { padding: 0 8px; gap: 6px; }
	.chat-title .chan-icon.lg { width: 28px; height: 28px; font-size: 0.9rem; }
	.chat-title b { font-size: 1.02rem; }
	.msg { padding: 3px 12px 3px 10px; grid-template-columns: 34px minmax(0, 1fr); column-gap: 10px; }
	.msg .avatar { width: 34px; height: 34px; }
	.msg-actions { right: 8px; }
	.msg:hover .msg-actions { display: none; }
	.msg.menu-open .msg-actions { display: flex; }
	.day, .new-divider, .topic-bar { margin-left: 12px; margin-right: 12px; }
	.history-edge { padding: 24px 14px 14px; }
	.composer { padding: 0 8px 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
	.search-head { padding: 8px; gap: 8px; }
	.search-head select { flex: 1 1 40%; }
	.search-results { padding: 4px 10px 20px; }
	.search-summary { padding: 12px 12px 6px; }
	.typing { padding: 0 12px; }
	.modal-back { padding: 0; align-items: stretch; }
	.modal, .modal.wide { width: 100%; max-height: none; height: 100%; border: 0; }
	.auth { grid-template-columns: 1fr; }
	.auth-art { border-right: 0; border-bottom: 1px solid var(--rule); padding: 22px 22px 18px; flex-direction: row; align-items: center; gap: 18px; justify-content: flex-start; }
	.auth-art .art { width: 96px; margin: 0; flex-shrink: 0; order: 2; margin-left: auto; }
	.auth-art .art-caption h1 { font-size: 1.5rem; margin-bottom: 4px; }
	.auth-art .art-caption p, .auth-art .kicker { display: none; }
	.auth-art .art-brand { display: none; }
	.auth-panel { padding: 32px 22px 48px; justify-content: flex-start; }
	.page-head { padding: 0 16px; }
	.page-head nav { gap: 14px; }
	.page-wrap { grid-template-columns: 1fr; gap: 24px; padding: 24px 16px 60px; }
	.page-nav { position: static; flex-direction: row; overflow-x: auto; border-bottom: 1px solid var(--rule); gap: 0; scrollbar-width: none; }
	.page-nav a { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; padding: 10px 12px; }
	.page-nav a.active { border-bottom-color: var(--accent); background: transparent; }
	.page-nav .nav-label { margin: 0; padding: 10px 12px 10px 20px; align-self: center; white-space: nowrap; border-left: 1px solid var(--rule); }
	.panel { padding: 20px 18px; }
	.form-grid { grid-template-columns: 1fr; }
	.filters form { margin-left: 0; width: 100%; }
	.filters input { flex: 1; width: auto; }
	.preview img { display: none; }
}

@media (hover: none) {
	.group-head .add-chan { opacity: 1; }
	.chan.active .chan-manage { display: inline-flex; }
	.msg:hover .msg-actions { display: none; }
	.msg.menu-open .msg-actions { display: flex; }
	.msg:hover .gutter-time { opacity: 0; }
}
