/* WebOS: Weltraum-Adapter. Nur index.html aktiviert diese Klasse.
   webos-theme.css bleibt für Spiele und eigenständige Dokumente unverändert. */
:root.webos-space {
  color-scheme: dark;
  --bg: #080f1c;
  --glass: rgba(13,24,42,.92);
  --glass-strong: #111d30;
  --glass-border: #354861;
  --surface-input: #15253b;
  --surface-subtle: #1c304a;
  --surface-hover: rgba(155,220,255,.10);
  --surface-pressed: rgba(155,220,255,.18);
  --text: #eef5ff;
  --text-dim: #b8c8dd;
  --text-faint: #99adc8;
  --accent: #9bdcff;
  --accent-2: #b8b4f2;
  --icon: #9bdcff;
  --chart-series-1: #9bdcff;
  --chart-series-2: #92dec0;
  --chart-series-3: #b8b4f2;
  --accent-soft: #203e58;
  --accent-border: #9bdcff;
  --on-accent: #ffffff;
  --danger: #ffb4b4;
  --danger-soft: #502b3a;
  --danger-fill: #963541;
  --warning: #f4d08b;
  --success: #92dec0;
  --success-soft: #183d38;
  --battery-reserve: #000000;
  --gradient: linear-gradient(135deg, #1b6295, #154e7d);
  --radius-xs: 4px;
  --radius-sm: 4px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --radius-xl: 8px;
  --radius-window: 8px;
  --blur: blur(24px) saturate(1.15);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.2);
  --shadow-md: 0 8px 24px rgba(0,0,0,.3);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.2);
  --shadow-dock: 0 -1px 24px rgba(0,0,0,.2);
  --shadow-accent: 0 2px 12px rgba(0,0,0,.2);
  --shadow-accent-hover: 0 4px 20px rgba(0,0,0,.3);
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono: 'Cascadia Code', Consolas, ui-monospace, monospace;
  --scrim: rgba(2,7,16,.7);
  --console-bg: #080f1c;
  --console-text: #eef5ff;
  --console-muted: #99adc8;
  --wallpaper: url('/assets/milky-way.webp');
}
.webos-space body { font-size: 14px; }
.webos-space ::selection { background: var(--accent-soft); color: var(--text); }
.webos-space :where(button, select, summary, a[href]) { cursor: pointer; }
.webos-space button:disabled { cursor: default; }
.webos-space input::placeholder, .webos-space textarea::placeholder { color: var(--text-faint); opacity: 1; }
.webos-space :where(input:not([type=checkbox]):not([type=range]):not([type=file]), textarea, select) {
  border-bottom-color: var(--text-faint);
}
.webos-space :where(input, textarea, select):focus { border-bottom-color: var(--accent); }
.webos-space .btn-secondary { background: var(--surface-input); box-shadow: var(--shadow-sm); }
.webos-space .btn-secondary:hover:not(:disabled) { background: var(--surface-subtle); }
.webos-space .dlg-backdrop { background: var(--scrim); backdrop-filter: none; -webkit-backdrop-filter: none; }
.webos-space .dlg-card { background: var(--glass-strong); text-align: left; padding: 24px; }
.webos-space .dlg-card .dlg-actions { justify-content: flex-end; margin-top: 24px; }
.webos-space .dlg-card button { min-height: 34px; }
.webos-space .dlg-card button.primary { color: var(--on-accent); }

/* Login und Desktop liegen über derselben Milchstraße. */
.webos-space #login-view { background: transparent; z-index: 1; flex-direction: column; gap: 24px; }
.webos-space #login-view .overlay { background: transparent; pointer-events: none; }
.webos-space #login-view .card { background: var(--glass); width: min(400px,100%); padding: 32px; }
.webos-space .brand svg { width: 64px; height: 64px; filter: none; color: var(--accent); }
.webos-space .brand h1 { font-size: 26px; font-weight: 600; }
.webos-space .card .field input:focus { background: var(--surface-input); }
.webos-space .card button:not(.btn-secondary) { color: var(--on-accent); }

/* Desktop und die zusätzliche WebOS-Kontingentleiste. */
.webos-space #desktop-view { background: transparent; z-index: 1; }
.webos-space #desktop-view::after { background: none; }
.webos-space #windows { inset: 36px 0 56px; }
.webos-space #statusbar { background: var(--glass); }
.webos-space #statusbar:hover { background: var(--glass); }
.webos-space .wb-frame { top: 56px; bottom: 76px; width: 244px; }
.webos-space #widgetbar { gap: 12px; }
.webos-space .wb-widget { box-shadow: var(--shadow-sm); background: var(--glass); padding: 16px; }
.webos-space .wb-title { text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--text-dim); }
.webos-space .wb-temp { font-weight: 600; }

/* Durchgehende Taskleiste. Apps bleiben in der Bildschirmmitte. */
.webos-space #taskbar {
  left: 0; right: 0; bottom: 0; transform: none; max-width: none; min-height: 56px;
  justify-content: center; gap: 4px; padding: 4px 150px; border: 0;
  border-top: 1px solid var(--glass-border); border-radius: 0; background: var(--glass);
}
.webos-space #taskbar-pinned, .webos-space #taskbar-apps { gap: 4px; }
.webos-space #taskbar.has-pinned #taskbar-pinned { border: 0; padding-left: 0; }
.webos-space .wm-taskbtn { width: 42px; height: 44px; flex-shrink: 0; border-radius: var(--radius-sm); }
.webos-space .wm-taskbtn:hover { transform: none; background: var(--surface-hover); }
.webos-space .wm-taskbtn:active { background: var(--surface-pressed); }
.webos-space .wm-taskbtn.active { background: var(--surface-input); box-shadow: var(--shadow-sm); }
.webos-space .wm-taskbtn.is-running::after { width: 6px; background: var(--text-dim); }
.webos-space .wm-taskbtn.active::after { width: 16px; box-shadow: none; background: var(--accent); }
.webos-space #start-button { background: transparent; }
.webos-space #start-button svg { color: var(--accent); fill: currentColor; stroke-width: 0; }
.webos-space #start-button:hover, .webos-space #start-button[aria-expanded=true] { background: var(--surface-hover); box-shadow: none; }
.webos-space .taskbar-label { position: absolute; left: 18px; display: flex; flex-direction: column; gap: 2px; width: 100px; font-size: 12px; font-weight: 600; line-height: 1.4; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.webos-space .taskbar-metric { display: flex; justify-content: space-between; }
.webos-space .taskbar-clock { position: absolute; right: 20px; text-align: right; font-size: 12px; line-height: 1.55; font-variant-numeric: tabular-nums; color: var(--text); }
.webos-space .taskbar-clock span { display: block; }

/* Start: Suchfeld, App-Raster und klare Pin-Schalter. */
.webos-space #start-menu { bottom: 68px; width: min(640px,calc(100vw - 32px)); max-height: min(700px,calc(100dvh - 120px)); padding: 28px; background: var(--glass); }
.webos-space .start-menu-header { margin-bottom: 20px; }
.webos-space .start-menu-mark { font-weight: 600; }
.webos-space .start-search { border-bottom: 2px solid var(--accent); background: var(--surface-input); }
.webos-space #start-menu-apps { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; padding: 4px; }
.webos-space .start-app-row { position: relative; flex-direction: column; min-height: 100px; }
.webos-space .start-app-launch { flex-direction: column; width: 100%; min-height: 100px; justify-content: center; gap: 8px; padding: 12px 4px 24px; text-align: center; }
.webos-space .start-app-icon { width: 36px; height: 36px; border: 0; background: transparent; }
.webos-space .start-app-icon svg { width: 30px; height: 30px; stroke-width: 1.6; }
.webos-space .start-app-name { max-width: 100%; font-size: 12px; }
.webos-space .start-app-pin { position: absolute; bottom: 0; right: 0; width: 28px; height: 28px; }
.webos-space .start-app-pin svg { height: 12px; width: 12px; }
.webos-space .start-menu-empty { grid-column: 1/-1; }

/* Instrumentenfenster mit ruhigen Titelzeilen. */
.webos-space .wm-window { background: var(--bg); border-color: var(--glass-border); backdrop-filter: none; -webkit-backdrop-filter: none; }
.webos-space .wm-window:focus-within { box-shadow: var(--shadow-lg); }
.webos-space .wm-titlebar { min-height: 38px; padding: 0 0 0 14px; gap: 0; background: var(--glass); border-bottom: 0; }
.webos-space .wm-title { font-size: 12px; color: var(--text); font-weight: 400; padding-right: 12px; }
.webos-space .wm-btn { width: 46px; height: 38px; flex-shrink: 0; border-radius: 0; color: var(--text); }
.webos-space .wm-btn:hover { background: var(--surface-hover); }
.webos-space .wm-btn-close:hover { background: var(--danger-fill); color: var(--on-accent); }
.webos-space .wm-btn-tile { width: auto; height: 28px; margin-right: 8px; border-radius: var(--radius-sm); }
.webos-space .wm-body { background: var(--glass-strong); border-top: 1px solid var(--glass-border); }
.webos-space .wm-resize { background: none; }

/* App-Familien: Befehlsleisten, Navigation, Karten und Inhaltsflächen. */
.webos-space :is(.fm-toolbar,.ed-toolbar,.svc-toolbar,.nt-toolbar,.logs-filter) { padding: 6px 0 12px; border-bottom: 1px solid var(--glass-border); }
.webos-space :is(.fm-list li,.svc-list li,.nt-list li) { padding: 10px 12px; }
.webos-space :is(.nt-side,.ch-side,.cx-side,.cx-agents) { background: var(--bg); }
.webos-space .nt-side { padding-right: 12px; border-right: 1px solid var(--glass-border); }
.webos-space :is(.ed-text,.nt-text) { padding: 16px; line-height: 1.65; }
.webos-space :is(.rf-card,.rf-section,.ll-item,.fs-item,.sg-item,.ag-kachel,.juno-card,.cad-list button,.cx-agent-card) { background: var(--surface-input); box-shadow: var(--shadow-sm); }
.webos-space :is(.rf-card,.rf-section,.sg-form,.fs-form,.ll-form) { border-radius: var(--radius-lg); }
.webos-space :is(.set-tabs,.ch-head,.cx-head,.juno-nav,.ag-tabs,.kb-tabs,.rf-tabs) { background: var(--bg); }
.webos-space :is(.set-tab,.ag-tab,.kb-tab,.rf-tab) { position: relative; border-radius: var(--radius-sm); }
.webos-space :is(.set-tab.active,.ag-tab[aria-selected=true],.kb-tab[aria-selected=true],.rf-tab[aria-selected=true]) { background: var(--surface-input); color: var(--accent); }
.webos-space :is(.set-switch,.set-switch::after) { box-shadow: none; }
.webos-space .set-toggle input:checked + .set-switch::after { background: var(--on-accent); }
.webos-space .kb-col { background: var(--bg); }
.webos-space .kb-card { background: var(--surface-input); box-shadow: var(--shadow-sm); }
.webos-space .kb-card[data-column=inprogress]::after { animation: none; }
.webos-space .kb-card[data-column=inprogress] { border-color: var(--accent); }
.webos-space .kb-idea-backdrop, .webos-space #palette-overlay { background: var(--scrim); }
.webos-space :is(.juno-user,.ch-msg-user,.cx-message-user) { background: var(--accent-soft); }
.webos-space .juno { background: var(--glass-strong); }
.webos-space :is(.ch-composer,.cx-compose,.juno-composer) { background: var(--glass-strong); }
.webos-space :is(.ll-save,.set-save,.ch-new,.ch-send,.cx-send,.cx-new,.cad-submit,.juno-send,.kb-detail-actions button.primary,.kb-idea-actions button.primary) { color: var(--on-accent); }
/* Die Konsole verwendet eigene, ebenfalls nachtblaue Tokens. */
.webos-space .ag-chart-grid { stroke: var(--glass-border); }

@media (max-width: 1100px) {
  .webos-space #taskbar { padding-left: 10px; padding-right: 10px; }
  .webos-space .taskbar-label, .webos-space .taskbar-clock { display: none; }
}
@media (max-width: 700px) {
  .webos-space #taskbar { min-height: 58px; bottom: 0; padding: 4px 8px max(4px,env(safe-area-inset-bottom)); justify-content: flex-start; overflow-x: auto; }
  .webos-space #start-menu { bottom: calc(68px + env(safe-area-inset-bottom)); padding: 18px; }
  .webos-space #start-menu-apps { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .webos-space .start-app-pin { width: 44px; height: 44px; }
  .webos-space .start-app-launch { padding-bottom: 40px; min-height: 120px; }
  .webos-space #desktop-view:not(.mobile-overview) #windows { bottom: calc(58px + env(safe-area-inset-bottom)); }
  .webos-space #mobile-home { background: transparent; }
  .webos-space .mobile-card { background: var(--surface-input); box-shadow: var(--shadow-sm); }
  .webos-space .wm-btn { width: 44px; height: 44px; }
}
@media (pointer: coarse) { .webos-space .wm-btn { min-width: 44px; min-height: 44px; } }
@media (prefers-reduced-motion: reduce) {
  .webos-space *, .webos-space *::before, .webos-space *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .webos-space :where(button,a,input,textarea,select):focus-visible { outline: 2px solid Highlight; }
  .webos-space .wm-window { border: 1px solid CanvasText; }
}
/* Primäraktionen in nachgeladenen App-Styles behalten weißen Text. */
.webos-space .cx-side-head button, .webos-space .rw-primary { color: var(--on-accent); }
.webos-space .set-tab-active { background: var(--surface-input); color: var(--accent); box-shadow: var(--shadow-sm); }
.webos-space .set-tab-active::before { content: ''; position: absolute; left: 0; top: 25%; height: 50%; width: 3px; background: var(--accent); border-radius: var(--radius-xs); }
.webos-space .ch-send { border-radius: var(--radius-sm); }
.webos-space .set-toggle input:focus-visible + .set-switch { outline: none; box-shadow: 0 0 0 2px var(--accent-border); }
.webos-space #start-search-input:focus-visible { box-shadow: none; }
.webos-space .start-search:focus-within { box-shadow: inset 0 0 0 1px var(--accent-border); }
.webos-space .start-app-pin { top: 0; bottom: auto; opacity: 0; }
.webos-space .start-app-pin svg { width: 15px; height: 15px; }
.webos-space .start-app-row:hover .start-app-pin,
.webos-space .start-app-row:focus-within .start-app-pin,
.webos-space .start-app-pin.is-pinned { opacity: 1; }
.webos-space .kb-prio-high { background: var(--danger-soft); color: var(--danger); }
.webos-space .kb-prio-medium { background: var(--accent-soft); color: var(--accent); }
.webos-space .kb-card[data-column=inprogress]::after { display: none; }
@media (pointer: coarse) { .webos-space .start-app-pin { opacity: 1; } }
@media (max-width: 700px) {
  .webos-space .start-app-pin { top: auto; bottom: 0; opacity: 1; }
  .webos-space .wm-body :is(input:not([type=checkbox]):not([type=range]),select,textarea) { font-size: 16px; }
}

.webos-space .taskbar-center { display: flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; }
.webos-space .taskbar-center.is-overflowing { overflow-x: auto; overflow-y: hidden; justify-content: flex-start; }
.webos-space .taskbar-center.is-overflowing .dock-preview { display: none; }
.webos-space .taskbar-center > div { flex-shrink: 0; }
@media (max-width: 700px) {
  .webos-space #taskbar { overflow: visible; padding-bottom: max(4px,env(safe-area-inset-bottom)); }
  .webos-space .taskbar-center { overflow-x: auto; }
  .webos-space #start-menu { max-height: min(700px,calc(100dvh - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom))); }
}

/* Zwei kontrastierende Ringe für Flächen und Primäraktionen. Spezifischer als aktive Taskbuttons und App-Fokusregeln. */
:root.webos-space :is(button,a,input,textarea,select,summary):focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--on-accent), 0 0 0 2px var(--accent-border);
}
.webos-space .rf-dose-submit { color: var(--on-accent); }

/* Das native hidden-Attribut gewinnt auch gegen App-Flex/Grid-Rezepte. */
.webos-space [hidden] { display: none !important; }
/* Schmale Appfenster erhalten dieselbe nutzbare Inhaltsbreite wie Telefone.
   Container statt Gerätebreite: funktioniert auch bei zwei Desktopfenstern. */
.webos-space .wm-body:has(> .ch, > .nt, > .set) { container: webos-app / inline-size; }
@container webos-app (max-width: 560px) {
  .webos-space :is(.ch,.nt,.set) { flex-direction: column; min-height: 0; }
  .webos-space :is(.ch-side,.nt-side) {
    width: auto; min-height: 0; max-height: 150px; padding: 10px; flex: none;
    border-right: 0; border-bottom: 1px solid var(--glass-border);
  }
  .webos-space :is(.ch-list,.nt-list) { max-height: 80px; min-height: 0; }
  .webos-space :is(.ch-main,.nt-main) { min-height: 0; }
  .webos-space .ch-head { flex-wrap: wrap; padding: 8px 12px; }
  .webos-space .ch-model { max-width: 100%; }
  .webos-space .ch-composer { padding: 12px; }
  .webos-space .ch-empty { min-height: 0; overflow-y: auto; padding: 16px; }
  .webos-space .ch-empty h2 { font-size: 22px; }
  .webos-space .ch-thread { padding: 16px; }
  .webos-space .nt-toolbar { flex-wrap: wrap; }
  .webos-space .nt-title { flex-basis: 100%; min-width: 0; }
  .webos-space .set-tabs {
    flex-direction: row; flex: none; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--glass-border); padding: 6px;
  }
  .webos-space .set-tab { flex-shrink: 0; min-height: 44px; }
  .webos-space .set-pane { padding: 12px; }
}
@media (max-width: 700px) {
  .webos-space .wm-body :is(button,.fm-upload) { min-height: 44px; }
}


/* Ein lokal gecachtes Bild, nur die sichtbare Ansicht animiert.
   Keine Video-/Canvas-Dauerschleife.
   Die vergrößerte Fläche deckt auch beim Schwenk alle Viewportkanten ab. */
.webos-space .space-backdrop { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; background: var(--bg); }
.webos-space .space-backdrop::before {
  content: ''; position: absolute; inset: -30%;
  background: var(--wallpaper) center / cover no-repeat;
  transform: rotate(-12deg) scale(1.05); transform-origin: 50% 50%;
  animation: space-drift 120s ease-in-out infinite alternate;
  animation-play-state: paused;
}
.webos-space[data-space-paused=false] .space-backdrop::before { animation-play-state: running; }
.webos-space .space-backdrop::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,15,28,.24), rgba(8,15,28,.05) 45%, rgba(8,15,28,.6)),
    radial-gradient(ellipse at 90% 10%, rgba(21,78,125,.22), transparent 65%);
}
@keyframes space-drift {
  from { transform: rotate(-12deg) scale(1.05) translate3d(-1%,1%,0); }
  to { transform: rotate(-9deg) scale(1.13) translate3d(1%,-1%,0); }
}
.webos-space .brand h1 { letter-spacing: -.04em; font-weight: 600; font-size: 30px; }
.webos-space .brand svg { width: 56px; height: 56px; stroke-width: 1.2; }
.webos-space #login-view .card { border-top-color: var(--accent-border); }
.webos-space .space-controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px;
  color: var(--text-dim); font-size: 11px; line-height: 1.6;
}
.webos-space #login-view > .space-controls { position: relative; z-index: 1; max-width: 400px; justify-content: center; text-align: center; }
.webos-space .space-motion-reason { flex-basis: 100%; margin: 0; padding: 8px; background: var(--glass); border-radius: var(--radius-sm); }
.webos-space .space-credit { margin: 0; padding: 4px 8px; background: var(--glass); border-radius: var(--radius-sm); }
.webos-space .space-credit a { color: var(--text-dim); text-underline-offset: 3px; }
.webos-space .space-credit a:hover { color: var(--accent); }
.webos-space [data-space-motion] { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 12px; font-size: 12px; background: var(--glass); }
.webos-space [data-space-motion] svg { width: 16px; height: 16px; color: var(--icon); }
.webos-space [data-space-motion]:active:not(:disabled) { background: var(--surface-pressed); }
.webos-space [data-space-motion]:disabled { opacity: .7; cursor: default; }
.webos-space .space-desktop-controls { position: absolute; right: 20px; bottom: 72px; z-index: 1; justify-content: flex-end; max-width: calc(100% - 40px); }
.webos-space .space-mobile-controls { margin-top: 24px; }
.webos-space .wm-window { border-top-color: var(--glass-border); }
.webos-space .wm-window:focus-within { border-top-color: var(--accent-border); }
.webos-space #taskbar { box-shadow: var(--shadow-dock); }
.webos-space .wm-titlebar { background: var(--bg); }
.webos-space .wb-widget { border-top-color: var(--glass-border); }
.webos-space .start-menu-mark { letter-spacing: -.02em; }
@media (max-width: 700px) {
  .webos-space #desktop-view.mobile-overview > .space-desktop-controls { display: none; }
  .webos-space .space-desktop-controls { right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); gap: 4px 8px; }
  .webos-space .space-credit { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { .webos-space .space-backdrop::before { animation: none; } }
@media (forced-colors: active) {
  .webos-space .space-backdrop { display: none; }
  .webos-space :is(#login-view,#desktop-view) { background: Canvas; }
  .webos-space [data-space-motion] { border: 1px solid ButtonText; }
}
