/* Kurato Cockpit - Designsystem (UX-Konzept Kap. 8/9).
   Tagwache (hell) / Nachtwache (dunkel): automatisch nach System, per
   data-theme im Profil umschaltbar. Statusfarben immer doppelt kodiert
   (Farbe + Text/Symbol). Systemschrift, keine Dritt-Fonts zur Laufzeit. */

:root {
	--font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	--radius: 10px;
	--radius-sm: 6px;
	--gap: 16px;
	--motion: 180ms;

	/* Tagwache (hell) */
	--bg: #eef2f5;
	--surface: #ffffff;
	--surface-2: #f6f8fa;
	--text: #16232e;
	--muted: #5b6b78;
	--border: #d5dde3;
	--primary: #0f6e8c;
	--primary-ink: #ffffff;
	--primary-weak: #d9eef4;
	--focus: #1189ad;

	--gruen: #1f8a4c;
	--gruen-bg: #e2f4e9;
	--gelb: #9a6b00;
	--gelb-bg: #fbefcf;
	--rot: #b3261e;
	--rot-bg: #f8e0de;
}

@media (prefers-color-scheme: dark) {
	:root {
		/* Nachtwache (dunkel) */
		--bg: #0d151b;
		--surface: #14212b;
		--surface-2: #1b2b37;
		--text: #e7eef3;
		--muted: #9db0bd;
		--border: #29404f;
		--primary: #3fb3d4;
		--primary-ink: #05222c;
		--primary-weak: #143642;
		--focus: #6fd0ec;

		--gruen: #57c98a;
		--gruen-bg: #123021;
		--gelb: #e0b459;
		--gelb-bg: #33280d;
		--rot: #f0857e;
		--rot-bg: #3a1613;
	}
}

/* Explizite Umschaltung im Profil gewinnt in beide Richtungen. */
:root[data-theme='tag'] {
	--bg: #eef2f5; --surface: #ffffff; --surface-2: #f6f8fa; --text: #16232e;
	--muted: #5b6b78; --border: #d5dde3; --primary: #0f6e8c; --primary-ink: #ffffff;
	--primary-weak: #d9eef4; --focus: #1189ad;
	--gruen: #1f8a4c; --gruen-bg: #e2f4e9; --gelb: #9a6b00; --gelb-bg: #fbefcf; --rot: #b3261e; --rot-bg: #f8e0de;
}
:root[data-theme='nacht'] {
	--bg: #0d151b; --surface: #14212b; --surface-2: #1b2b37; --text: #e7eef3;
	--muted: #9db0bd; --border: #29404f; --primary: #3fb3d4; --primary-ink: #05222c;
	--primary-weak: #143642; --focus: #6fd0ec;
	--gruen: #57c98a; --gruen-bg: #123021; --gelb: #e0b459; --gelb-bg: #33280d; --rot: #f0857e; --rot-bg: #3a1613;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: 0 0 .5rem; }
.muted { color: var(--muted); font-size: .9rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; word-break: break-all; }

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

/* Fokus-Ringe sichtbar (A11y). */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
	outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm);
}

/* --- Buttons --- */
.btn { font: inherit; padding: .55rem .95rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
	background: var(--surface); color: var(--text); cursor: pointer; transition: background var(--motion) ease-out, transform var(--motion) ease-out; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover { filter: brightness(1.07); background: var(--primary); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--rot); border-color: var(--rot); }
.btn-primary.btn-danger { background: var(--rot); color: #fff; border-color: var(--rot); }

/* --- Fields --- */
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
input, select { font: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid var(--border);
	border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
input[type='checkbox'], input[type='radio'] { width: auto; }
.field-hint { color: var(--muted); font-size: .82rem; margin: .3rem 0 0; }
.field-msg { color: var(--rot); font-size: .85rem; margin: .3rem 0 0; }
.field-error input { border-color: var(--rot); }

/* --- Layout --- */
.app-shell { min-height: 100vh; }
.app-main { max-width: 1120px; margin: 0 auto; padding: var(--gap); }
.page { padding: .5rem 0 3rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: var(--gap); }
.boot-splash { min-height: 100vh; display: grid; place-items: center; }

/* --- Topbar --- */
.topbar { display: flex; align-items: center; gap: var(--gap); padding: .6rem var(--gap);
	background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-slim { justify-content: space-between; }
.topbar-brand { font-weight: 700; letter-spacing: .02em; color: var(--primary); }
.topbar-nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.site-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link { font: inherit; background: transparent; border: 0; color: var(--text); padding: .45rem .7rem; border-radius: var(--radius-sm); cursor: pointer; }
.nav-link:hover { background: var(--surface-2); }
.nav-link.is-active { background: var(--primary-weak); color: var(--primary); font-weight: 600; }

/* Verbindungs-Indikator */
.conn-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.conn-ok { background: var(--gruen); }
.conn-bad { background: var(--rot); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* --- Login --- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: var(--gap); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; }
.login-motif { color: var(--primary); display: grid; place-items: center; margin-bottom: .5rem; }
.login-title { text-align: center; margin-bottom: 1.1rem; }

/* --- Onboarding --- */
.onboard-screen { min-height: calc(100vh - 52px); display: grid; place-items: center; padding: var(--gap); }
.onboard-card { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; }
.onboard-step { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.onboard-card.success { text-align: center; }
.success-mark { font-size: 2.6rem; }
.pairing-block { margin-top: 1rem; }
.pairing-code { font-family: ui-monospace, monospace; font-size: 1.5rem; letter-spacing: .12em; text-align: center;
	background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: .8rem; }
.pairing-hint { text-align: center; color: var(--muted); font-size: .85rem; }
.pairing-steps { padding-left: 1.2rem; }
.pairing-wait { display: flex; align-items: center; gap: .6rem; color: var(--muted); margin-top: .6rem; }

/* --- Bridge --- */
.bridge-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--gap); flex-wrap: wrap; margin-bottom: 1rem; }
.greeting { font-size: 1.7rem; }
.briefing { color: var(--muted); }
.columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.column { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.column-soon { opacity: .85; }
.soon-card { background: var(--surface-2); border-radius: var(--radius-sm); padding: 1rem; color: var(--muted); }
.task-list, .mini-list, .sub-list, .task-checks, .agent-list { list-style: none; margin: 0 0 .8rem; padding: 0; }
.task-row { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.task-open, .mini-row { text-align: left; background: transparent; border: 0; color: var(--text); cursor: pointer; width: 100%; padding: .2rem 0; display: block; }
.task-title { display: block; font-weight: 600; }
.task-meta { display: block; color: var(--muted); font-size: .82rem; }
.mini-row span { display: block; }
.mini-list li { border-bottom: 1px solid var(--border); }

/* Segelwetter-Badge (doppelt kodiert) */
.weather { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .75rem; border-radius: 999px; border: 1px solid var(--border); cursor: pointer; font-weight: 600; }
.weather-symbol { font-size: 1.05rem; }
.weather-gruen { background: var(--gruen-bg); color: var(--gruen); border-color: var(--gruen); }
.weather-gelb { background: var(--gelb-bg); color: var(--gelb); border-color: var(--gelb); }
.weather-rot { background: var(--rot-bg); color: var(--rot); border-color: var(--rot); }

.badge { font-size: .72rem; padding: .12rem .45rem; border-radius: 999px; border: 1px solid; font-weight: 600; }
.badge-rot { color: var(--rot); background: var(--rot-bg); border-color: var(--rot); }

/* --- Empty / Lighthouse --- */
.empty { text-align: center; color: var(--muted); padding: 1rem .5rem; }
.empty-scene, .lighthouse-art { color: var(--primary); display: grid; place-items: center; }
.empty-title { color: var(--text); font-weight: 600; margin-top: .5rem; }
.lighthouse { max-width: 460px; margin: 4rem auto; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.lighthouse h2 { font-size: 1.25rem; }
.lighthouse-diag { color: var(--muted); font-size: .9rem; }

/* --- Board --- */
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--gap); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: var(--gap); overflow-x: auto; padding-bottom: 1rem; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; min-height: 120px; }
.col-won { border-color: var(--gruen); }
.col-lost { border-color: var(--border); opacity: .9; }
.board-col-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.col-label { font-weight: 700; }
.col-count { font-variant-numeric: tabular-nums; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 .5rem; font-size: .82rem; }
.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .55rem; cursor: grab; transition: transform 150ms ease-out, box-shadow var(--motion); }
.card.is-dragging { transform: rotate(2.5deg); box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.card-open { text-align: left; background: transparent; border: 0; color: var(--text); cursor: pointer; font-weight: 600; width: 100%; }
.card-move { display: block; margin-top: .4rem; }
.card-move select { font-size: .82rem; padding: .3rem .4rem; }
.card-empty { padding: .4rem; font-size: .85rem; }
.rollback-banner { display: flex; justify-content: space-between; align-items: center; gap: .8rem; background: var(--rot-bg); color: var(--rot); border: 1px solid var(--rot); border-radius: var(--radius-sm); padding: .6rem .8rem; margin-bottom: .8rem; }

/* Won-Zelebration */
.celebration { position: fixed; left: 0; right: 0; bottom: 24px; pointer-events: none; z-index: 20; }
.ship { font-size: 2.4rem; animation: sail 1.5s ease-in-out forwards; }
@keyframes sail { from { transform: translateX(-12vw); } to { transform: translateX(96vw); } }
@media (prefers-reduced-motion: reduce) {
	.ship { animation: none; }
	.card.is-dragging { transform: none; }
	.conn-bad { animation: none; }
}

/* --- Contact profile --- */
.back-link { background: transparent; border: 0; color: var(--primary); cursor: pointer; padding: 0; margin-bottom: .5rem; }
.contact-head { margin-bottom: 1rem; }
.stepper { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.step { font: inherit; padding: .35rem .7rem; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; cursor: pointer; font-size: .85rem; }
.step.is-active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.step[disabled] { cursor: default; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: .4rem; flex: none; }
.timeline p { margin: 0; }
.task-checks li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .3rem 0; }
.task-checks .is-done span { text-decoration: line-through; color: var(--muted); }
.task-checks label { display: flex; gap: .5rem; align-items: center; }
.task-add { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.task-add input[type='text'] { flex: 1; min-width: 140px; }
.inline-row { display: flex; align-items: center; gap: .5rem; }
.saved-check { color: var(--gruen); font-size: .82rem; white-space: nowrap; }

/* --- Contacts table --- */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type='search'] { flex: 1; min-width: 180px; }
.filters select { width: auto; }
.table-wrap { overflow-x: auto; }
.contact-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.contact-table th, .contact-table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--border); }
.contact-table th { background: var(--surface-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.row-click { cursor: pointer; }
.row-click:hover td { background: var(--surface-2); }

/* --- Team --- */
.agent-row { display: flex; justify-content: space-between; gap: .8rem; padding: .6rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.invite-link { margin-top: .3rem; font-size: .82rem; }
.buy-moment { margin-top: 1rem; background: var(--primary-weak); border: 1px solid var(--primary); border-radius: var(--radius); padding: 1rem; }
.radio-set { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
.radio, .switch { display: flex; align-items: center; gap: .5rem; cursor: pointer; }

/* --- Toasts --- */
.toasts { position: fixed; right: var(--gap); bottom: var(--gap); display: flex; flex-direction: column; gap: .5rem; z-index: 30; max-width: 90vw; }
.toast { display: flex; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-sm); padding: .6rem .8rem; box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.toast-success { border-left-color: var(--gruen); }
.toast-error { border-left-color: var(--rot); }
.toast-info { border-left-color: var(--primary); }
.toast-x { background: transparent; border: 0; font-size: 1.1rem; cursor: pointer; color: var(--muted); }

/* --- Command palette --- */
.palette-overlay { position: fixed; inset: 0; background: rgba(6,14,20,.45); display: grid; place-items: start center; padding-top: 12vh; z-index: 40; }
.palette { width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.palette-input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: .9rem 1rem; font-size: 1rem; }
.palette-list { list-style: none; margin: 0; padding: .3rem; max-height: 50vh; overflow-y: auto; }
.palette-item { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem .7rem; border-radius: var(--radius-sm); cursor: pointer; }
.palette-item.is-active { background: var(--primary-weak); }
.palette-hint { color: var(--muted); font-size: .82rem; }
.palette-empty { padding: .7rem; color: var(--muted); }
.palette-fab { position: fixed; right: var(--gap); bottom: var(--gap); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .5rem .8rem; cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,.14); font-weight: 600; }

/* --- Modal --- */
.modal { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* --- Spinner --- */
.spinner { display: grid; place-items: center; padding: 2rem; }
.spinner-ring { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner-ring { animation-duration: 2s; } }

/* --- Responsiv: Board wird zur Stufen-Liste (kein Touch-Drag-Zwang) --- */
@media (max-width: 860px) {
	.columns { grid-template-columns: 1fr; }
	.contact-grid { grid-template-columns: 1fr; }
	.board { grid-auto-flow: row; grid-auto-columns: auto; }
	.card { cursor: default; }
}
