/*
 * Arbeitsbereiche, Werkzeugleiste, Bereichs-Startseite, Personenmenü (Makeover Schritt 1, 2026-10-08).
 * Nur bestehende Tokens (app.css Abschnitt 1) - damit gelten Hell/Dunkel und die drei Designs ohne Sonderregeln.
 * Rot nur für den aktiven Zustand (CD). Die Optik wird in Schritt 2 überarbeitet; hier steht die Struktur.
 */

/* --- Kopfzeile: Mitte = zwei Zeilen (Bereiche über Werkzeugen) --- */
.app-header--ws { align-items: center; }
.ws-nav { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ws-nav .app-header__cats { flex: 0 1 auto; max-width: 100%; }

.ws-areas { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px var(--sp-1); }
.ws-area {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--touch-sm); padding: 0 var(--sp-3); border-radius: var(--r-pill);
  color: var(--c-ink-2); font-weight: 700; font-size: var(--fs-2); text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease-out, color .15s ease-out, box-shadow .15s ease-out;
}
.ws-area svg { flex: 0 0 auto; opacity: .75; }
.ws-area:hover { color: var(--c-ink); background: var(--c-surface-2); }
.ws-area:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
/* Aktiver Bereich: erhaben + rote Unterkante (Zustand nie nur im Schatten). */
.ws-area.is-active { color: var(--c-ink); background: var(--nm-face); box-shadow: var(--nm-1); }
.ws-area.is-active::after { content: ""; position: absolute; left: var(--sp-3); right: var(--sp-3); bottom: 3px; height: 3px; border-radius: 3px; background: var(--c-brand); }
.ws-area.is-active svg { opacity: 1; color: var(--c-brand-deep); }
.ws-area__short { display: none; }

/* Werkzeugleiste: Chips wie bisher; Seiten-Werkzeuge (Ablauf, Bibliothek) und Links außerhalb des Studios im Chip-Look. */
.ws-tool {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 var(--sp-3); border-radius: var(--r-pill);
  background: var(--c-bg); box-shadow: var(--nm-1); color: var(--c-ink-2); font-weight: 600; font-size: var(--fs-2);
  text-decoration: none; white-space: nowrap;
}
.ws-tool:hover { color: var(--c-ink); }
.ws-tool:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.ws-tool.is-active { background: var(--nm-brand-face); color: var(--c-brand-ink); font-weight: 700; }
.app-header__cats .ws-off { display: none !important; }
/* Trennpunkt vor den Verknüpfungen (Werkzeuge, die zu einem anderen Bereich gehören). */
.ws-sep { flex: 0 0 auto; width: 5px; height: 5px; margin: 0 var(--sp-1); border-radius: 50%; background: var(--c-muted); }
.app-header__cats .ws-linked { font-style: normal; }
.app-header__cats .ws-linked:not(.chip--on):not(.is-active) { color: var(--c-muted-deep, var(--c-muted)); }

/* --- Personenmenü --- */
.person-menu { position: relative; display: inline-flex; }
.person-menu__btn { gap: 6px; padding-left: 4px; }
.person-menu__avatar {
  display: inline-grid; place-items: center; width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%;
  background: var(--c-brand-soft); color: var(--c-brand-deep); font-weight: 800; font-size: 13px;
}
.person-menu__name { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-menu__caret { transition: transform .2s ease-out; }
.person-menu.is-open .person-menu__caret { transform: rotate(180deg); }
.person-menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 290px; max-width: calc(100vw - 24px);
  padding: var(--sp-2); border-radius: var(--r-md); background: var(--nm-face, var(--c-bg)); box-shadow: var(--nm-3);
  display: flex; flex-direction: column; gap: 2px;
}
.person-menu__panel[hidden] { display: none; }
.person-menu__who { margin: 0 0 var(--sp-1); padding: var(--sp-2) var(--sp-2) var(--sp-2); border-bottom: 1px solid var(--c-line); display: flex; flex-direction: column; }
.person-menu__who small { color: var(--c-muted); font-size: var(--fs-1); }
.person-menu__item {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: var(--touch-sm); padding: 6px var(--sp-2);
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--c-ink); font: inherit; font-weight: 600;
  font-size: var(--fs-2); text-align: left; text-decoration: none; cursor: pointer;
}
.person-menu .app-header__user { color: var(--c-ink); padding-right: var(--sp-2); }
.person-menu__item:hover { background: var(--c-surface-2); color: var(--c-ink); }
.person-menu__item:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 1px; }
.person-menu__item svg { flex: 0 0 auto; color: var(--c-muted); }
.person-menu__row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: var(--touch-sm); padding: 2px var(--sp-2); }
.person-menu__label { font-size: var(--fs-2); font-weight: 600; color: var(--c-ink-2); }
.person-menu__row .design-select { max-width: 150px; }
.person-menu__sep { height: 1px; margin: var(--sp-1) 0; background: var(--c-line); }
.person-menu .app-header__logout { display: block; margin: 0; }

/* --- Startseite je Arbeitsbereich --- */
body.ws-home-on .studio-shell { display: none; }
.ws-home { max-width: 1100px; margin: 0 auto var(--sp-6); padding: var(--sp-5) var(--sp-2) 0; animation: ws-fade .2s ease-out; }
.ws-home[hidden] { display: none; }
.ws-home__head { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.ws-home__icon { display: inline-grid; place-items: center; width: 56px; height: 56px; flex: 0 0 56px; border-radius: var(--r-md); background: var(--nm-face); box-shadow: var(--nm-2); color: var(--c-brand-deep); }
.ws-home__kicker { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); }
.ws-home__title { margin: 0; font-size: var(--fs-6, 1.75rem); line-height: 1.15; }
.ws-home__purpose { margin: 4px 0 0; color: var(--c-ink-2); font-size: var(--fs-3); }
.ws-home__intro { max-width: 70ch; margin: 0 0 var(--sp-4); color: var(--c-ink-2); line-height: 1.5; }
.ws-home__sub { margin: var(--sp-5) 0 var(--sp-2); font-size: var(--fs-2); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--c-muted); }
.ws-home__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.ws-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "icon body" "icon go"; gap: 4px var(--sp-3);
  padding: var(--sp-4); border-radius: var(--r-md); background: var(--nm-face); box-shadow: var(--nm-2);
  color: var(--c-ink); text-decoration: none; transition: box-shadow .15s ease-out, transform .15s ease-out;
}
.ws-card:hover { box-shadow: var(--nm-3); color: var(--c-ink); }
.ws-card:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 3px; }
.ws-card__icon { grid-area: icon; display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-sm); background: var(--c-bg); box-shadow: var(--nm-in); color: var(--c-ink-2); }
.ws-card__body { grid-area: body; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ws-card__name { font-size: var(--fs-3); }
.ws-card__says { color: var(--c-ink-2); font-size: var(--fs-2); line-height: 1.4; }
.ws-card__go { grid-area: go; align-self: end; justify-self: start; margin-top: var(--sp-2); font-weight: 700; font-size: var(--fs-2); color: var(--c-brand-deep); }
.ws-card--link { box-shadow: var(--nm-1); }
.ws-card--link .ws-card__icon { box-shadow: none; }
.ws-home__recent { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ws-recent { display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch-sm); padding: 0 var(--sp-3); border-radius: var(--r-pill); background: var(--nm-face); box-shadow: var(--nm-1); color: var(--c-ink); font-weight: 600; font-size: var(--fs-2); text-decoration: none; }
.ws-recent:hover { color: var(--c-ink); background: var(--c-surface-2); }
.ws-home__empty { margin: 0; color: var(--c-muted); }
@keyframes ws-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* --- Schmal --- */
@media (max-width: 900px) {
  .ws-nav { order: 3; flex-basis: 100%; align-items: stretch; }
  .ws-areas { justify-content: flex-start; }
  .ws-nav .app-header__cats { justify-content: flex-start; }
}
@media (max-width: 599px) {
  .ws-area__label { display: none; }
  .ws-area__short { display: inline; }
  .ws-area { padding: 0 var(--sp-2); gap: 0; }
  .ws-area svg { display: none; }
  .ws-areas { gap: 2px; }
  .person-menu__name { display: none; }
  .ws-home { padding-top: var(--sp-3); }
  .ws-home__title { font-size: var(--fs-5, 1.4rem); }
}

@media (prefers-reduced-motion: reduce) {
  .ws-home, .ws-area, .ws-card, .person-menu__caret { animation: none !important; transition: none !important; }
}

/* --- UI/UX-Knopf (2026-10-08): Oberflächen-Vorlage + Hell/Dunkel --- */
.ws-admin-link { display: none; align-items: center; min-height: var(--touch-sm); padding: 0 var(--sp-2); font-size: var(--fs-2); font-weight: 600; color: var(--c-ink-2); text-decoration: none; }
.ws-admin-link:hover { color: var(--c-ink); }
.ux-menu { position: relative; display: inline-flex; }
.ux-menu__btn { gap: 6px; }
.ux-menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 320px; max-width: calc(100vw - 24px);
  padding: var(--sp-3); border-radius: var(--r-md); background: var(--nm-face, var(--c-bg)); box-shadow: var(--nm-3);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.ux-menu__panel[hidden] { display: none; }
.ux-menu__title { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); }
.ux-menu__list { display: flex; flex-direction: column; gap: 4px; }
.ux-menu__select { display: none; } /* #designSlot bleibt als Anker im DOM, bedient wird über die Knöpfe */
.ux-opt {
  display: flex; align-items: flex-start; gap: var(--sp-2); width: 100%; padding: var(--sp-2); border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--c-ink); font: inherit; text-align: left; cursor: pointer;
}
.ux-opt:hover { background: var(--c-surface-2); }
.ux-opt:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 1px; }
.ux-opt__dot { flex: 0 0 14px; width: 14px; height: 14px; margin-top: 2px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--c-muted); }
.ux-opt.is-on .ux-opt__dot { box-shadow: inset 0 0 0 4px var(--c-brand); }
.ux-opt__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ux-opt__body strong { font-size: var(--fs-3); }
.ux-opt__body small { font-size: var(--fs-1); color: var(--c-muted); line-height: 1.35; }
@media (max-width: 599px) { .ux-menu__btn span { display: none; } }

/* --- UI/UX → Farben (2026-10-08, assets/js/palette.js) --- */
.ux-menu__panel { max-height: calc(100vh - 90px); overflow-y: auto; }
.ux-pal__counts { display: flex; flex-wrap: wrap; gap: 4px; }
.ux-pal__count { min-height: 30px; min-width: 34px; padding: 0 10px; border: 0; border-radius: var(--r-pill); background: var(--c-surface-2); color: var(--c-ink); font: inherit; font-size: var(--fs-1); font-weight: 700; cursor: pointer; }
.ux-pal__count.is-on { background: var(--c-brand); color: var(--c-brand-ink); }
.ux-pal__count:disabled { opacity: .45; cursor: not-allowed; }
.ux-pal__count:focus-visible, .ux-pal__opt:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.ux-pal__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: var(--sp-2); }
.ux-pal__opt { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--c-ink); font: inherit; font-size: var(--fs-1); text-align: left; cursor: pointer; box-shadow: inset 0 0 0 1px var(--c-line); }
.ux-pal__opt:hover { background: var(--c-surface-2); }
.ux-pal__opt.is-on { box-shadow: inset 0 0 0 2px var(--c-brand); font-weight: 700; }
.ux-pal__opt:disabled { opacity: .4; cursor: not-allowed; }
.ux-pal__sw { display: flex; height: 18px; border-radius: 4px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.ux-pal__sw i { flex: 1; }
.ux-pal__hint { margin: var(--sp-2) 0 0; font-size: var(--fs-1); color: var(--c-muted); line-height: 1.4; }

/* Mit Palette: fest eingetragene Weiß-/Rot-Werte der Module auf die Tokens ziehen (Schrift auf Akzentflächen kann dunkel sein). */
html.kib-palette .pl-nav__item.is-active, html.kib-palette .og-nav__item.is-active { color: var(--c-brand-ink); }
html.kib-palette .pl-badge, html.kib-palette .og-badge { color: var(--c-brand-ink); }
html.kib-palette .pl-nav__item.is-active .pl-badge, html.kib-palette .og-nav__item.is-active .og-badge { background: var(--c-brand-ink); color: var(--c-brand); }
/* Kontrast-Regel (2026-10-08): das kleine „F1“-Schild am Hilfe-Knopf lag in allen Vorlagen unter 4,5:1. */
.app-header .help-btn__key { background: var(--c-surface-2); color: var(--c-ink-2); box-shadow: inset 0 0 0 1px var(--c-line); }
/* Mittlere Breiten: UI/UX und Personenmenü nur als Symbol, damit die Kopfzeile nicht umbricht (Name/Text stehen im Tooltip bzw. Menü). */
@media (max-width: 1640px) { .ux-menu__btn span, .person-menu__name { display: none; } }
.ux-menu__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.ux-menu__close { min-height: 30px; padding: 0 10px; border: 0; border-radius: var(--r-pill); background: var(--c-surface-2); color: var(--c-ink); font: inherit; font-size: var(--fs-1); font-weight: 700; cursor: pointer; }
.ux-menu__close:hover { box-shadow: inset 0 0 0 1px var(--c-line); }
.ux-menu__close:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.ux-pal__note { margin-top: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--c-warn-soft); color: var(--c-ink); font-size: var(--fs-1); line-height: 1.45; }
.ux-pal__fit { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.ux-pal__fitbtn { min-height: 28px; padding: 0 10px; border: 0; border-radius: var(--r-pill); background: var(--c-brand); color: var(--c-brand-ink); font: inherit; font-size: var(--fs-1); font-weight: 700; cursor: pointer; }
.ux-pal__opt.is-limited { opacity: .55; }
.ui-save-toast { position: fixed; left: 50%; bottom: var(--sp-5); transform: translateX(-50%); z-index: 90; max-width: min(560px, calc(100vw - 32px)); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--c-ink); color: var(--c-bg); font-size: var(--fs-2); line-height: 1.45; box-shadow: var(--nm-3); }
.ui-save-toast[hidden] { display: none; }
