:root {
  box-sizing: border-box;
  --bg: #2b0f30; --w1: #ff4f8b; --w2: #ff9a5a; --w3: #8b5cf6;
  --ink: #fff3f7; --ink-soft: #f2bdd0;
  --win: #fffafb; --win-ink: #331020; --win-bar: #ffe9f0; --win-line: #f7cfdc; --muted: #8c5a6e; --field: #ffffff;
  --shadow: 0 18px 50px rgba(40, 5, 30, .5);
  --menu-h: 30px; --dock-space: 88px;
  --top: calc(var(--menu-h) + env(safe-area-inset-top, 0px));
  --toast-top: calc(var(--top) + 10px);
  --bottom: calc(var(--dock-space) + env(safe-area-inset-bottom, 0px));
  --font: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --win: #2c1226; --win-ink: #ffeef4; --win-bar: #3b1a31; --win-line: #56294a; --muted: #d6a3bd; --field: #210c1b;
  }
}
:root[data-theme="dark"] {
  --win: #2c1226; --win-ink: #ffeef4; --win-bar: #3b1a31; --win-line: #56294a; --muted: #d6a3bd; --field: #210c1b;
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #ffd23f; outline-offset: 2px; }

/* Hintergrund */
.wallpaper { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--bg); transition: background .6s; }
.blob { position: absolute; border-radius: 50%; opacity: .8; will-change: transform; }
.b1 { width: 70vmax; height: 70vmax; left: -20vmax; top: -26vmax; background: radial-gradient(circle closest-side, var(--w1), transparent); animation: drift1 38s ease-in-out infinite alternate; }
.b2 { width: 56vmax; height: 56vmax; right: -16vmax; top: 4vmax; background: radial-gradient(circle closest-side, var(--w2), transparent); opacity: .7; animation: drift2 44s ease-in-out infinite alternate; }
.b3 { width: 52vmax; height: 52vmax; left: 20vw; bottom: -26vmax; background: radial-gradient(circle closest-side, var(--w3), transparent); opacity: .65; animation: drift3 50s ease-in-out infinite alternate; }
.wm { position: absolute; inset: 0; background: url("/logo.svg") center / min(78vmin, 780px) no-repeat; opacity: .16; pointer-events: none; }
.logo { width: 18px; height: 18px; margin-right: 6px; vertical-align: -3px; }
@keyframes drift1 { to { transform: translate(14vmax, 10vmax) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-16vmax, 8vmax) scale(.9); } }
@keyframes drift3 { to { transform: translate(-10vmax, -12vmax) scale(1.15); } }

.desktop { position: fixed; left: 0; right: 0; top: var(--top); bottom: var(--bottom); z-index: 1; }

/* Menüleiste */
.menubar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9000; height: var(--top);
  padding: env(safe-area-inset-top, 0px) 8px 0; display: flex; align-items: center; gap: 2px;
  background: rgba(42, 10, 34, .5); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.08); font-size: 13px; color: var(--ink);
}
.mb { height: 24px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; }
.mb:hover, .mb.open { background: rgba(255,255,255,.18); }
.mb.strong { font-weight: 800; }
.mb .k { opacity: .6; margin-left: 6px; font-size: 12px; }
.mspace { flex: 1; }
.mclock { padding: 0 10px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }

.dd {
  position: fixed; z-index: 9600; min-width: 220px; padding: 5px; border-radius: 12px;
  background: rgba(52, 16, 42, .94); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(255,255,255,.14); box-shadow: var(--shadow); color: var(--ink); animation: pop .12s ease-out;
}
.ddi { display: flex; justify-content: space-between; gap: 18px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-size: 13px; text-align: left; }
.ddi:hover:not(:disabled) { background: #ff4f8b; }
.ddi:disabled { opacity: .5; cursor: default; }
.ddi .k { opacity: .6; }
.dd hr { border: 0; border-top: 1px solid rgba(255,255,255,.14); margin: 5px 6px; }

/* Desktop-Verknüpfungen */
.shortcuts {
  position: absolute; top: 14px; right: 12px; height: calc(100% - 14px); direction: rtl;
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 104px); grid-auto-columns: 96px; gap: 6px; align-content: start;
}
.sc {
  direction: ltr; width: 96px; height: 104px; background: transparent; border: 0; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 8px 4px; cursor: pointer;
  color: #fff; text-shadow: 0 1px 8px rgba(10,6,40,.75);
}
.sc .tile, .di .tile { position: relative; }
.locked .tile::after { content: "🔒"; position: absolute; right: -5px; top: -5px; font-size: 14px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.sc .tile { width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center; font-size: 28px; box-shadow: 0 6px 16px rgba(8,5,30,.4), inset 0 0 0 1px rgba(255,255,255,.25); }
.sc .name { font-size: 13px; font-weight: 600; line-height: 1.15; text-align: center; }
.sc[aria-pressed="true"] { background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }

/* Fenster */
.win {
  position: absolute; display: flex; flex-direction: column; background: var(--win); color: var(--win-ink);
  border-radius: 12px; overflow: hidden; min-width: 280px; min-height: 180px;
  box-shadow: 0 10px 30px rgba(8,5,30,.3), 0 0 0 1px rgba(255,255,255,.07); animation: pop .18s ease-out;
}
.win.focus { box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.14); }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }
.win.closing { animation: out .14s ease-in forwards; }
@keyframes out { to { transform: scale(.95); opacity: 0; } }
.win.min { display: none; }
.win.max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; }
.bar { flex: none; height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--win-bar); border-bottom: 1px solid var(--win-line); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.win.dragging .bar { cursor: grabbing; }
.lights { display: flex; gap: 8px; width: 60px; }
.lights button { position: relative; width: 13px; height: 13px; padding: 0; border: 0; border-radius: 50%; background: #9a94bf; color: transparent; font-size: 10px; line-height: 13px; font-weight: 800; cursor: pointer; }
.lights button::after { content: ""; position: absolute; inset: -6px -3px; }
.win.focus .lights .r { background: #ff5f57; }
.win.focus .lights .y { background: #febc2e; }
.win.focus .lights .g { background: #28c840; }
.lights:hover button { color: rgba(0,0,0,.6); }
.ttl { flex: 1; text-align: center; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win:not(.focus) .ttl { opacity: .55; }
.spacer { width: 60px; }
.body { flex: 1; overflow: auto; padding: 18px; }
.body.frame { padding: 0; overflow: hidden; }
.body.frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.win.dragging iframe, .win.resizing iframe { pointer-events: none; }
.grip { position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; cursor: nwse-resize; touch-action: none; }
.win.max .grip { display: none; }

/* Dock */
.dockwrap { position: fixed; left: 0; right: 0; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 8000; display: flex; justify-content: center; pointer-events: none; padding: 0 8px; }
.dock {
  pointer-events: auto; display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px 12px; height: 72px; border-radius: 22px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.24);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow);
}
.di { --s: 1; --x: 0px; position: relative; display: flex; align-items: flex-end; justify-content: center; width: 50px; height: 52px; padding: 0; border: 0; background: transparent; cursor: pointer; transform: translateX(var(--x)); transition: transform .1s ease-out; }
.di .tile {
  width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; font-size: 27px;
  box-shadow: 0 4px 12px rgba(8,5,30,.35), inset 0 0 0 1px rgba(255,255,255,.28);
  transform: scale(var(--s)); transform-origin: 50% 100%; transition: transform .1s ease-out; will-change: transform;
}
.di .dot { position: absolute; bottom: -8px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: #fff; display: none; }
.di.run .dot { display: block; }
.di.mn .dot { opacity: .45; }
.di .tip {
  position: absolute; bottom: calc(100% + 12px + 50px * (var(--s) - 1)); left: 50%; transform: translateX(-50%); padding: 5px 10px; border-radius: 8px; white-space: nowrap;
  background: rgba(42, 10, 34, .92); border: 1px solid rgba(255,255,255,.14); font-size: 12px; font-weight: 600; color: var(--ink); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.di:hover .tip, .di:focus-visible .tip { opacity: 1; }
.di.launch .tile { animation: bounce .55s ease-out 2; }
@keyframes bounce { 40% { transform: translateY(-22px) scale(var(--s)); } 70% { transform: translateY(-4px) scale(var(--s)); } }

/* Suche */
.spot { position: fixed; inset: 0; z-index: 9900; display: none; align-items: flex-start; justify-content: center; padding-top: 16vh; background: rgba(8,5,25,.35); }
.spot.open { display: flex; }
.spot .panel { width: min(560px, 92%); border-radius: 18px; overflow: hidden; background: rgba(52, 16, 42, .95); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,.16); box-shadow: var(--shadow); animation: pop .14s ease-out; }
.spot input { width: 100%; padding: 18px 20px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 20px; outline: none; }
.spot ul { list-style: none; margin: 0; padding: 0 8px 8px; }
.spot li button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-size: 15px; font-weight: 600; text-align: left; }
.spot li button.sel, .spot li button:hover { background: #ff4f8b; }
.spot .mini { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; }
.spot .none { padding: 10px 20px 18px; color: var(--ink-soft); font-size: 14px; }

/* Konto */
.lbl { display: grid; gap: 5px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.form { max-width: 320px; }
.msg { min-height: 20px; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.msg.err { color: #d9304f; }
.prof { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.prof h3 { margin: 0; }
.prof p { margin: 2px 0 0; }
.avatar { flex: none; width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--w2), var(--w1)); }

/* App-Inhalte */
.body h3 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.body h4 { margin: 18px 0 8px; font-size: 14px; font-weight: 800; }
.body p { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 60ch; }
.btn { border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 700; font-size: 14px; background: var(--accent); color: #fff; }
.btn.dark-text { color: #221a00; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: var(--win-line); color: var(--win-ink); }
.btn.on { outline: 3px solid var(--accent); outline-offset: 1px; }
.field { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--win-line); background: var(--field); color: var(--win-ink); font: inherit; font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.sw { display: grid; gap: 6px; justify-items: center; border: 0; background: transparent; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--win-ink); }
.sw i { display: block; width: 76px; height: 50px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.sw.on i { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Vollbild: Menüleiste und Dock fahren weg, das Fenster füllt den ganzen Bildschirm */
.menubar { transition: transform .25s ease; }
.dockwrap { transition: transform .25s ease; }

/* Im Dock stehen der Such-Knopf, angeheftete Apps (dock: true) und Apps mit offenem Fenster */
.di:not(.run):not(.pinned):not(.launcher) {
    display: none;
}
.di.launcher .tile {
    background: linear-gradient(135deg, var(--w1), var(--w2));
}
.dsep {
    flex: none;
    align-self: flex-end;
    width: 1px;
    height: 38px;
    margin: 0 2px 6px;
    background: rgba(255, 255, 255, .28);
}
body.fs .menubar { transform: translateY(-100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
body.fs .dockwrap { transform: translateY(calc(100% + 24px)); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
.win.fsw { position: fixed; padding-bottom: env(safe-area-inset-bottom, 0px); }
.win.fsw .bar { height: calc(42px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); }

/* Handy: wie ein Startbildschirm. Raster aus App-Symbolen, eine offene App füllt den ganzen Bildschirm. */
@media (max-width: 640px), (pointer: coarse) and (max-height: 500px) {
  :root { --menu-h: 40px; --dock-space: 92px; }
  body { overscroll-behavior: none; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
  .mb.hide-m, .mclock .dt { display: none; }
  .menubar { padding-left: calc(6px + env(safe-area-inset-left, 0px)); padding-right: calc(6px + env(safe-area-inset-right, 0px)); }
  .mb { height: 34px; padding: 0 12px; font-size: 14px; }
  .mb .k { display: none; }
  .logo { width: 22px; height: 22px; vertical-align: -5px; }

  /* Raster */
  .desktop { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .shortcuts {
    position: static; direction: ltr; height: auto; display: grid; grid-auto-flow: row; grid-template-rows: none;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); grid-auto-columns: auto; gap: 8px 4px; align-content: start;
    padding: 18px calc(10px + env(safe-area-inset-right, 0px)) 24px calc(10px + env(safe-area-inset-left, 0px));
  }
  .sc { width: 100%; height: auto; min-height: 96px; padding: 6px 2px; gap: 8px; }
  .sc .tile { width: 62px; height: 62px; border-radius: 17px; font-size: 32px; }
  .sc .name { font-size: 12px; }
  .sc:active .tile { transform: scale(.94); }
  .sc[aria-pressed="true"] { background: transparent; box-shadow: none; }

  /* Dock: feste Leiste unten, ohne Vergrößerung */
  .dockwrap { left: 0; right: 0; padding: 0 10px; }
  .dock { max-width: 100%; overflow-x: auto; height: 76px; padding: 10px 12px; gap: 12px; align-items: center; border-radius: 24px; scrollbar-width: none; }
  .dock::-webkit-scrollbar { display: none; }
  .di { flex: none; --s: 1 !important; --x: 0px !important; width: 54px; height: 54px; }
  .di .tile { width: 54px; height: 54px; font-size: 28px; border-radius: 15px; }
  .di .tip { display: none; }
  .di .dot { bottom: -7px; }
  .dsep { height: 40px; margin: 0; align-self: center; }

  /* Offene App: ganzer Bildschirm mit eigener Kopfzeile, Menüleiste und Dock sind weg */
  body.mopen .menubar { transform: translateY(-100%); visibility: hidden; }
  body.mopen .dockwrap { transform: translateY(calc(100% + 24px)); visibility: hidden; }
  .win, .win.max, .win.fsw {
    position: fixed; left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important;
    height: 100dvh !important; min-width: 0; min-height: 0; border-radius: 0; box-shadow: none; padding-bottom: 0;
  }
  .bar, .win.fsw .bar { height: calc(52px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) calc(12px + env(safe-area-inset-right, 0px)) 0 calc(12px + env(safe-area-inset-left, 0px)); cursor: default; }
  .lights { width: 84px; gap: 12px; }
  .lights .g { display: none; }
  .lights button { width: 32px; height: 32px; font-size: 18px; line-height: 32px; }
  .lights button::after { inset: -6px; }
  .lights button { color: rgba(0,0,0,.55); }
  .spacer { width: 84px; }
  .ttl { font-size: 16px; }
  .body { padding: 16px calc(16px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px)); }
  .body.frame { padding: 0; }
  .grip { display: none; }

  /* Menüs und Suche */
  .dd { min-width: 240px; max-width: calc(100vw - 12px); }
  .ddi { padding: 12px 12px; font-size: 15px; }
  .spot { padding-top: calc(env(safe-area-inset-top, 0px) + 10vh); align-items: flex-start; }
  .spot .panel { width: calc(100% - 20px); max-height: 75dvh; display: flex; flex-direction: column; }
  .spot input { font-size: 18px; padding: 16px; }
  .spot ul { overflow-y: auto; }
  .spot li button { padding: 12px; font-size: 16px; }
  .spot .mini { width: 34px; height: 34px; }
  .field, .form input { font-size: 16px; }
  .btn { padding: 12px 18px; min-height: 44px; }
  .form { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .blob, .win, .win.closing, .dd, .di.launch .tile, .spot .panel { animation: none !important; }
  .di .tile { transition: none; }
  .menubar, .dockwrap { transition: none !important; }
}