@font-face {
	font-family: 'Bricolage';
	src: url('/fonts/bricolage.woff2') format('woff2');
	font-weight: 200 800;
	font-display: swap;
}
@font-face {
	font-family: 'Atkinson';
	src: url('/fonts/atkinson.woff2') format('woff2');
	font-weight: 200 800;
	font-display: swap;
}

:root {
	--night: #1c1530;
	--panel: #261d3f;
	--panel-raised: #2f2550;
	--line: #3d3263;
	--text: #f4f0ff;
	--muted: #a99fc8;
	--faint: #7d7299;
	--signal: #ffcf4d;
	--signal-ink: #2a1d00;
	--alert: #ff8a73;
	--ok: #7fe3b5;
	--display: 'Bricolage', 'Segoe UI', system-ui, sans-serif;
	--body: 'Atkinson', 'Segoe UI', system-ui, sans-serif;
	--gutter: 16px;
	--nav-h: 64px;
	color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
	background: var(--night);
	color: var(--text);
	font: 16px/1.5 var(--body);
	-webkit-font-smoothing: antialiased;
	min-height: 100dvh;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--signal); }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }

.visually-hidden {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Buttons und Felder ---------- */

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 44px; padding: 0 18px;
	border: 1px solid var(--line); border-radius: 12px;
	background: var(--panel-raised); cursor: pointer;
	font-family: var(--display); font-weight: 600; text-decoration: none; color: var(--text);
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--signal); color: var(--signal-ink); border-color: var(--signal); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--signal); }
.btn-twitch { background: #9146ff; border-color: #9146ff; color: #fff; }
.btn-danger { color: var(--alert); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }

.link-btn { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.field {
	width: 100%; min-height: 44px; padding: 0 14px;
	background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.field::placeholder { color: var(--faint); }

/* ---------- Login ---------- */

.welcome {
	max-width: 560px; margin: 0 auto;
	padding: max(48px, env(safe-area-inset-top)) var(--gutter) 48px;
	display: grid; gap: 28px;
}
.welcome-mark { width: 56px; height: 56px; border-radius: 14px; }
.welcome h1 { font-size: clamp(34px, 9vw, 52px); font-weight: 750; letter-spacing: -0.02em; }
.welcome p { color: var(--muted); margin: 0; max-width: 46ch; }
.welcome .demo { pointer-events: none; }
.welcome-actions { display: grid; gap: 10px; justify-items: start; }
.welcome-note { font-size: 14px; color: var(--faint); }

/* ---------- App-Gerüst ---------- */

.shell { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

.topbar {
	position: sticky; top: 0; z-index: 5;
	display: flex; align-items: center; gap: 12px;
	padding: max(12px, env(safe-area-inset-top)) var(--gutter) 12px;
	background: color-mix(in srgb, var(--night) 88%, transparent);
	backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 22px; font-weight: 700; flex: 1; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--panel); }

.scan-state { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.scan-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.scan-state[data-state='live'] .scan-dot { background: var(--ok); animation: pulse 2.4s ease-out infinite; }
.scan-state[data-state='error'] .scan-dot { background: var(--alert); }
@keyframes pulse {
	0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
	70%, 100% { box-shadow: 0 0 0 9px transparent; }
}

main { max-width: 720px; margin: 0 auto; padding: 16px var(--gutter) 32px; }

.tabs {
	position: fixed; inset: auto 0 0 0; z-index: 6;
	display: grid; grid-template-columns: repeat(5, 1fr);
	height: calc(var(--nav-h) + env(safe-area-inset-bottom));
	padding-bottom: env(safe-area-inset-bottom);
	background: var(--panel); border-top: 1px solid var(--line);
}
.tab {
	position: relative; display: grid; place-items: center; align-content: center; gap: 2px;
	background: none; border: 0; cursor: pointer; color: var(--muted);
	font-family: var(--display); font-size: 13px; font-weight: 600;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-current='page'] { color: var(--signal); }
.tab-count {
	position: absolute; top: 8px; left: calc(50% + 6px);
	min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
	background: var(--signal); color: var(--signal-ink); font-size: 11px; line-height: 18px; text-align: center;
}

@media (min-width: 900px) {
	.shell { padding-bottom: 0; padding-left: 96px; }
	.tabs {
		inset: 0 auto 0 0; width: 96px; height: auto;
		grid-template-columns: 1fr; grid-auto-rows: 84px; align-content: start;
		padding: 88px 0 0; border-top: 0; border-right: 1px solid var(--line);
	}
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 0 12px; }
.section-head h2 { font-size: 20px; font-weight: 700; }
.hint { color: var(--muted); font-size: 15px; margin: 0 0 16px; }

/* ---------- Banner (Push, iPhone) ---------- */

.banner {
	display: grid; gap: 10px; margin-bottom: 16px; padding: 16px;
	border: 1px solid var(--signal); border-radius: 16px;
	background: color-mix(in srgb, var(--signal) 9%, var(--night));
}
.banner h2 { font-size: 18px; }
.banner p { margin: 0; color: var(--muted); }
.banner ol { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.banner .share-icon { display: inline-block; vertical-align: -4px; width: 18px; height: 18px; color: var(--signal); }

/* ---------- Treffer ---------- */

.hits { display: grid; gap: 4px; }

.hit {
	position: relative; padding: 14px 14px 14px 16px;
	border-left: 3px solid var(--line); border-radius: 4px 14px 14px 4px;
	background: var(--panel);
}
.hit[data-priority='high'] { border-left-color: var(--signal); }
.hit[data-read='false']::after {
	content: ''; position: absolute; top: 18px; right: 14px;
	width: 8px; height: 8px; border-radius: 50%; background: var(--signal);
}

.hit-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding-right: 20px; }
.chatter { font-family: var(--display); font-weight: 700; }
.where { color: var(--muted); font-size: 14px; }
.when { color: var(--faint); font-size: 13px; margin-left: auto; }

.hit-text { margin: 6px 0 0; font-size: 17px; overflow-wrap: anywhere; }
.hit-text mark {
	background: none; color: var(--signal); font-weight: 700;
	text-decoration: underline 2px; text-underline-offset: 4px;
}

.reason { display: inline-block; font-size: 12.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }
.hit[data-priority='high'] .reason { border-color: color-mix(in srgb, var(--signal) 55%, transparent); color: var(--signal); }

.hit-actions { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 14px; }
.hit-actions a, .hit-actions button { color: var(--muted); }

.context { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 14px; color: var(--muted); }
.context li { overflow-wrap: anywhere; }
.context .ctx-name { font-weight: 700; }
.context .ctx-self { color: var(--text); padding: 2px 0; }

.empty { padding: 36px 8px; text-align: center; color: var(--muted); display: grid; gap: 14px; justify-items: center; }
.empty h2 { font-size: 22px; color: var(--text); }
.empty p { margin: 0; max-width: 36ch; }

/* ---------- Kanäle ---------- */

.list { list-style: none; margin: 0; padding: 0; display: grid; }
.row {
	display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0;
	border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-family: var(--display); font-weight: 650; }
.row-sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live { color: var(--alert); font-weight: 700; }
.tag { margin-left: 8px; padding: 0 7px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; color: var(--muted); }
.channel-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; background: var(--panel-raised); }
.channel-avatar-empty { display: grid; place-items: center; font-family: var(--display); font-weight: 700; color: var(--muted); }
.state-error { color: var(--alert); }
.capacity { color: var(--muted); font-size: 14px; }

.panel { background: var(--panel); border-radius: 16px; padding: 4px 16px; margin-bottom: 24px; }
.search { display: flex; gap: 8px; margin-bottom: 12px; }

/* ---------- Begriffe ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
	display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 6px 0 14px;
	border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
}
.chip-fixed { padding-right: 14px; color: var(--muted); }
.chip button { width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; cursor: pointer; color: var(--muted); }
.chip button:hover { background: var(--panel-raised); color: var(--text); }
.term-group { margin-bottom: 28px; }
.term-group h2 { font-size: 18px; margin-bottom: 4px; }
.term-group .hint { margin-bottom: 10px; }

/* ---------- Einstellungen ---------- */

.setting { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting-text { flex: 1; }
.setting-text strong { display: block; font-family: var(--display); font-weight: 650; }
.setting-text span { color: var(--muted); font-size: 14px; }

.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 15px; background: var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.switch input:checked + span { background: var(--signal); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--signal-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }

.time-range { display: flex; align-items: center; gap: 8px; }
.time-range input { width: 108px; }

.account { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ---------- Toast ---------- */

#toast {
	position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 10;
	transform: translateX(-50%); max-width: calc(100vw - 32px);
	padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--night); font-weight: 600;
}

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

/* ---------- Kopfzeile: Aktualisieren ---------- */

.icon-btn {
	display: grid; place-items: center; width: 36px; height: 36px; flex: none;
	border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--muted); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--text); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Antworten ---------- */

.composer { display: grid; gap: 8px; }
.composer-inline { margin-top: 12px; }
.composer-input { min-height: 44px; padding: 10px 14px; resize: vertical; line-height: 1.4; }
.composer-actions { display: flex; gap: 8px; }
.hit[data-highlight='true'], .moment[data-highlight='true'] { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---------- Kanalansicht ---------- */

main.main-channel { max-width: 960px; padding: 0; }
.channel-view {
	display: flex; flex-direction: column;
	height: calc(100dvh - 61px - max(0px, env(safe-area-inset-top) - 12px) - var(--nav-h) - env(safe-area-inset-bottom));
}
@media (min-width: 900px) { .channel-view { height: calc(100dvh - 61px); } }
.channel-head { display: flex; align-items: center; gap: 10px; padding: 10px var(--gutter); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.channel-head .row-main { min-width: 120px; }
.stream { position: relative; aspect-ratio: 16 / 9; max-height: 45dvh; background: #000; flex: none; }
.stream iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.clip-notice { margin: 0; padding: 10px var(--gutter); background: color-mix(in srgb, var(--signal) 12%, var(--night)); font-size: 14px; }
.chat { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 8px var(--gutter); display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.chat-line { padding: 3px 6px; border-radius: 6px; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; cursor: pointer; }
.chat-line:hover { background: var(--panel); }
.chat-line[data-own='true'] { background: color-mix(in srgb, var(--text) 6%, transparent); cursor: default; }
.chat-line[data-partner='true'] { box-shadow: inset 3px 0 0 var(--signal); }
.chat-line[data-me='true'] { background: color-mix(in srgb, var(--signal) 14%, transparent); }
.chat-name { font-weight: 700; }
.chat-mention { color: var(--signal); font-weight: 700; }
.chat-badge { display: inline-block; margin-right: 5px; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 700; background: var(--panel-raised); color: var(--muted); vertical-align: 1px; }
.chat-reply { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emote { height: 26px; vertical-align: middle; margin: -4px 1px; }
.composer-live { padding: 10px var(--gutter); border-top: 1px solid var(--line); background: var(--night); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row .composer-input { flex: 1; resize: none; }
.reply-bar { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--muted); }
.reply-bar em { color: var(--text); font-style: normal; }

/* ---------- Clip-Radar ---------- */

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 16px; }
.seg { min-height: 40px; padding: 0 14px; border: 0; background: var(--panel); color: var(--muted); cursor: pointer; font-family: var(--display); font-weight: 600; font-size: 14px; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg[aria-pressed='true'] { background: var(--signal); color: var(--signal-ink); }
.spark { vertical-align: middle; }
.spark-line { fill: none; stroke: var(--signal); stroke-width: 2; stroke-linejoin: round; }
.spark-base { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; }
.spark-empty { color: var(--faint); font-size: 13px; }
.moment { padding: 14px 14px 14px 16px; border-left: 3px solid var(--signal); border-radius: 4px 14px 14px 4px; background: var(--panel); }
.moment[data-fresh='true'] { background: color-mix(in srgb, var(--signal) 10%, var(--panel)); }
.moment-text { margin: 6px 0 10px; font-size: 17px; font-family: var(--display); font-weight: 650; }
.moment .chips { margin-bottom: 4px; }
.term-preset { display: grid; gap: 6px; justify-items: start; margin: -12px 0 28px; }
.term-preset .hint { margin: 0; font-size: 14px; }

@media (min-width: 900px) { .tabs { grid-auto-rows: 76px; } }

/* ---------- Emotes ---------- */

.hit-text .emote, .context .emote, .emote-preview .emote { height: 24px; }
.emote-suggest { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.emote-chip {
	display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 34px; padding: 0 10px 0 6px;
	border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); cursor: pointer; font-size: 14px;
}
.emote-chip .emote { height: 22px; margin: 0; }
.emote-preview { font-size: 14.5px; color: var(--text); overflow-wrap: anywhere; }
.emote-preview-label { color: var(--faint); }
.emote-picker { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.emote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; max-height: 220px; overflow-y: auto; }
.emote-btn { display: grid; place-items: center; height: 44px; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.emote-btn:hover, .emote-btn:focus-visible { background: var(--panel-raised); }
.emote-btn .emote { height: 28px; margin: 0; }
.emote-note { margin: 0; font-size: 12.5px; color: var(--faint); }
.composer-inline .composer-row { display: flex; gap: 8px; align-items: flex-start; }
.composer-inline .composer-row .composer-input { flex: 1; }
.stream-holder, .stream-holder iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Icons in Buttons ---------- */

.btn .i, .link-btn .i { display: inline-grid; place-items: center; }
.btn .i svg { width: 18px; height: 18px; }
.link-btn { display: inline-flex; align-items: center; gap: 5px; }
.link-btn .i svg { width: 16px; height: 16px; }
.hit-actions .link-btn, .hit-actions a.link-btn { text-decoration: none; color: var(--muted); }
.hit-actions .link-btn:hover .label { text-decoration: underline; text-underline-offset: 3px; }
.btn-clip { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 45%, var(--line)); }
.btn[aria-pressed='true'] { border-color: var(--signal); color: var(--signal); }
.label-busy { font-size: 13px; }

/* ---------- Einstellungen: lange Zeilen untereinander ---------- */

.setting-stack { flex-direction: column; align-items: stretch; gap: 10px; }
.setting-stack .time-range input { flex: 1; width: auto; min-width: 0; }
.setting .setting-text { min-width: 0; }

/* ---------- Startbildschirm mit Hintergrundgrafik ---------- */

.welcome { position: relative; }
body:has(.welcome) {
	background:
		linear-gradient(180deg, color-mix(in srgb, var(--night) 35%, transparent), var(--night) 70%),
		url('/img/hero.jpg') 70% 0 / cover no-repeat,
		var(--night);
	background-attachment: fixed;
}

/* ---------- Handy ---------- */

.channel-head .row-main { overflow: hidden; }
.channel-head .row-title, .channel-head .row-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 560px) {
	.topbar { gap: 10px; }
	.topbar h1 { font-size: 20px; }
	.scan-state { font-size: 13px; }
	.btn-compact { padding: 0; width: 40px; min-height: 40px; }
	.btn-compact .label { display: none; }
	.composer-live .btn-compact { width: 48px; min-height: 44px; }
	.channel-head { flex-wrap: nowrap; gap: 8px; }
	.row { gap: 10px; }
	.row .btn-compact { width: 38px; min-height: 38px; }
	.setting { flex-wrap: wrap; }
	.segmented { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
	.seg { padding: 0 6px; }
	.hit-actions { gap: 6px 14px; }
	.hit { padding: 12px 12px 12px 14px; }
	.hit-text { font-size: 16px; }
	main { padding-top: 12px; }
}

@media (max-width: 360px) {
	.scan-state { font-size: 0; gap: 0; }
}
