/* ==========================================================================
   GymnastPlanner – Design-System
   Mobile first; ab 900px erscheint die Seitenleiste, darunter eine Tab-Leiste.
   ========================================================================== */

:root {
  --bg:            #f5f6fa;
  --surface:       #ffffff;
  --surface-2:     #eef0f7;
  --surface-3:     #e4e7f2;
  --border:        #dcdfeb;
  --border-strong: #c3c8dc;
  --text:          #171a26;
  --text-muted:    #626880;
  --text-faint:    #8b90a6;

  --primary:       #4c3ce0;
  --primary-hover: #3f2fce;
  --primary-soft:  #ecebfd;
  --on-primary:    #ffffff;

  --success:       #16875a;
  --success-soft:  #dcf4e8;
  --warning:       #a3661a;
  --warning-soft:  #fbeed6;
  --danger:        #c0304a;
  --danger-hover:  #a3253c;
  --danger-soft:   #fce8ec;

  --sprung:        #b06a13;
  --barren:        #6d3ec2;
  --balken:        #0f7d84;
  --boden:         #b23a68;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 26px;

  --shadow-1: 0 1px 2px rgba(20, 22, 40, .06), 0 1px 3px rgba(20, 22, 40, .04);
  --shadow-2: 0 4px 14px rgba(20, 22, 40, .09);
  --shadow-3: 0 18px 48px rgba(20, 22, 40, .18);

  --sidebar-w: 264px;
  --tabbar-h: 60px;
  --topbar-h: 58px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0e1017;
    --surface:       #171a24;
    --surface-2:     #1f2331;
    --surface-3:     #282d3e;
    --border:        #2c3143;
    --border-strong: #3b4257;
    --text:          #eceef6;
    --text-muted:    #a2a8bd;
    --text-faint:    #7d8398;

    --primary:       #8b7cff;
    --primary-hover: #9d90ff;
    --primary-soft:  #241f47;
    --on-primary:    #12101f;

    --success:       #4bd39a;
    --success-soft:  #12301f;
    --warning:       #e6b055;
    --warning-soft:  #33260f;
    --danger:        #ff7a8f;
    --danger-hover:  #ff92a3;
    --danger-soft:   #38141d;

    --sprung:        #e0a45a;
    --barren:        #a98bf0;
    --balken:        #52c4c9;
    --boden:         #ef85ab;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, .55);
    --shadow-3: 0 20px 52px rgba(0, 0, 0, .7);
  }
}

/* --------------------------------------------------------------- Reset -- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* Eigene display-Regeln würden die UA-Regel für [hidden] sonst aushebeln. */
[hidden] { display: none !important; }

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

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

.noscript {
  margin: 2rem auto; max-width: 34rem; padding: 1rem 1.25rem;
  background: var(--warning-soft); color: var(--warning);
  border-radius: var(--radius); text-align: center;
}

.icon {
  width: 1.35em; height: 1.35em;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}
.icon--filled { fill: currentColor; stroke: none; }

/* --------------------------------------------------------------- Shell -- */
.shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1fr;
}

.sidebar { display: none; }

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .5rem;
  min-height: var(--topbar-h);
  padding: .5rem max(.9rem, env(safe-area-inset-left)) .5rem max(.9rem, env(safe-area-inset-right));
  padding-top: max(.5rem, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar__title {
  font-size: 1.16rem; font-weight: 700; letter-spacing: -.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}

.topbar__actions { display: flex; align-items: center; gap: .4rem; flex: none; }

.view {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem max(.9rem, env(safe-area-inset-left)) 2.5rem max(.9rem, env(safe-area-inset-right));
}
.view:focus { outline: none; }

/* ------------------------------------------------------------- Tabbar -- */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--border);
}

.tabbar__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: .3rem .2rem;
  font-size: .68rem; font-weight: 600; letter-spacing: .01em;
  color: var(--text-faint); text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.tabbar__item:hover { text-decoration: none; }
.tabbar__item .icon { width: 1.5rem; height: 1.5rem; stroke-width: 1.65; }
.tabbar__item[aria-current="page"] { color: var(--primary); }
.tabbar__item[aria-current="page"] .icon { stroke-width: 2.1; }

/* ------------------------------------------------------------ Buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .62rem 1.05rem;
  font-size: .95rem; font-weight: 650; letter-spacing: -.005em;
  border: 1px solid transparent; border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; text-decoration: none;
  transition: background .14s ease, border-color .14s ease, transform .06s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; background: var(--surface-3); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 1.15em; height: 1.15em; }

.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); }

.btn--outline { background: transparent; border-color: var(--border-strong); }
.btn--outline:hover { background: var(--surface-2); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-hover); }
@media (prefers-color-scheme: dark) { .btn--danger { color: #2a0d14; } }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }

.btn--block { width: 100%; }
.btn--sm { padding: .4rem .7rem; font-size: .85rem; border-radius: var(--radius-sm); }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.4rem; height: 2.4rem; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text-muted);
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.icon-button .icon { width: 1.35rem; height: 1.35rem; }

/* --------------------------------------------------------------- Card -- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 1rem; }
.card__head {
  display: flex; align-items: center; gap: .6rem;
  padding: .95rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: .95rem; font-weight: 700; letter-spacing: -.01em; }
.card__meta { margin-left: auto; font-size: .82rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.card__body { padding: 1.1rem; }
.card__body--flush { padding: 0; }

.section-title {
  margin: 1.75rem 0 .7rem;
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-faint);
}
.section-title:first-child { margin-top: .25rem; }

/* -------------------------------------------------------------- Forms -- */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }

.label {
  display: block; margin-bottom: .32rem;
  font-size: .85rem; font-weight: 620; color: var(--text-muted);
}

.input, .select, .textarea {
  width: 100%;
  padding: .65rem .8rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color .14s ease, box-shadow .14s ease;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 6rem; resize: vertical; }

.select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 1.05rem center, right .8rem center;
  background-size: .3rem .3rem, .3rem .3rem;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

.field__error { margin-top: .32rem; font-size: .82rem; color: var(--danger); }
.field__hint  { margin-top: .32rem; font-size: .82rem; color: var(--text-muted); }

.form-alert {
  display: flex; align-items: flex-start; gap: .55rem;
  margin-bottom: 1rem; padding: .7rem .85rem;
  font-size: .88rem; border-radius: var(--radius);
  background: var(--danger-soft); color: var(--danger);
}
.form-alert--info { background: var(--primary-soft); color: var(--primary); }
.form-alert--success { background: var(--success-soft); color: var(--success); }
.form-alert .icon { margin-top: .1rem; }

/* -------------------------------------------------------------- Chips -- */
.chip {
  display: inline-flex; align-items: center; gap: .34rem;
  padding: .3rem .62rem;
  font-size: .78rem; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid transparent; border-radius: 999px;
}
.chip .icon { width: .95rem; height: .95rem; }
.chip--sprung { color: var(--sprung); background: color-mix(in srgb, var(--sprung) 13%, transparent); }
.chip--barren { color: var(--barren); background: color-mix(in srgb, var(--barren) 13%, transparent); }
.chip--balken { color: var(--balken); background: color-mix(in srgb, var(--balken) 13%, transparent); }
.chip--boden  { color: var(--boden);  background: color-mix(in srgb, var(--boden) 13%, transparent); }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.6rem; padding: .26rem .5rem;
  font-size: .84rem; font-weight: 750; font-variant-numeric: tabular-nums;
  color: #fff; background: var(--text-muted);
  border-radius: 999px;
}
@media (prefers-color-scheme: dark) { .badge { color: #10121b; } }
.badge--v1 { background: #16875a; }
.badge--v2 { background: #2f6fd0; }
.badge--v3 { background: #b5741a; }
.badge--v4 { background: #c0304a; }
.badge--a  { background: #16875a; }
.badge--b  { background: #109a86; }
.badge--c  { background: #2f6fd0; }
.badge--d  { background: #5a4bd0; }
.badge--e  { background: #b5741a; }
.badge--f  { background: #c0304a; }
.badge--x  { background: #8244b8; }
@media (prefers-color-scheme: dark) {
  .badge--v1, .badge--a { background: #4bd39a; }
  .badge--v2, .badge--c { background: #7fb0f5; }
  .badge--v3, .badge--e { background: #e6b055; }
  .badge--v4, .badge--f { background: #ff8fa2; }
  .badge--b { background: #4fd8c4; }
  .badge--d { background: #a99bff; }
  .badge--x { background: #d29bf0; }
}

/* --------------------------------------------------------- Toolbar/Filter */
.toolbar { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }

.searchbar { position: relative; }
.searchbar .icon {
  position: absolute; left: .78rem; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
}
.searchbar .input { padding-left: 2.5rem; padding-right: 2.5rem; }
.searchbar__clear { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); }

.segmented {
  display: flex; gap: .25rem; padding: .25rem;
  background: var(--surface-2); border-radius: var(--radius);
  overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented__item {
  flex: 1 0 auto; min-width: 4.4rem;
  padding: .45rem .7rem;
  font-size: .87rem; font-weight: 640; text-align: center; white-space: nowrap;
  border: 0; border-radius: calc(var(--radius) - 3px);
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.segmented__item:hover { color: var(--text); }
.segmented__item[aria-pressed="true"] {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-1);
}

.filterbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.filterbar__count { margin-left: auto; font-size: .82rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.control {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .42rem .7rem .42rem .6rem;
  font-size: .85rem; font-weight: 620;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid transparent; border-radius: 999px;
  cursor: pointer;
}
.control:hover { background: var(--surface-3); color: var(--text); }
.control--active { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }
.control .icon { width: 1rem; height: 1rem; }
.control select {
  border: 0; background: transparent; color: inherit; font: inherit; font-weight: inherit;
  cursor: pointer; -webkit-appearance: none; appearance: none; padding-right: .1rem;
}
.control select:focus { outline: none; }

/* --------------------------------------------------------------- Lists -- */
.list { display: flex; flex-direction: column; }
.list__item {
  display: flex; align-items: center; gap: .85rem;
  width: 100%; padding: .7rem 1.1rem;
  background: transparent; border: 0; border-top: 1px solid var(--border);
  color: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.list__item:first-child { border-top: 0; }
.list__item:hover { background: var(--surface-2); text-decoration: none; }
.list__item--static { cursor: default; }
.list__item--static:hover { background: transparent; }

.thumb {
  width: 60px; height: 60px; flex: none;
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb--sm { width: 44px; height: 44px; border-radius: 10px; }

.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  overflow: hidden; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 72px; height: 72px; font-size: 1.4rem; }
.avatar--xl { width: 112px; height: 112px; font-size: 2rem; }

.item__body { flex: 1; min-width: 0; }
.item__title {
  font-size: .93rem; font-weight: 640; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
a.item__title { color: inherit; text-decoration: none; }
a.item__title:hover { text-decoration: underline; }
.item__sub {
  margin-top: .18rem; font-size: .79rem; color: var(--text-muted);
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
}
.item__trail { display: flex; align-items: center; gap: .45rem; flex: none; }
.item__chevron { color: var(--text-faint); }

/* --------------------------------------------------------- Empty state -- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: .5rem; padding: 2.75rem 1.25rem;
}
.empty__icon {
  display: flex; align-items: center; justify-content: center;
  width: 3.5rem; height: 3.5rem; margin-bottom: .3rem;
  border-radius: 50%; background: var(--surface-2); color: var(--text-faint);
}
.empty__icon .icon { width: 1.7rem; height: 1.7rem; }
.empty__title { font-size: 1.02rem; font-weight: 680; }
.empty__text { font-size: .88rem; color: var(--text-muted); max-width: 30rem; }
.empty .btn { margin-top: .7rem; }

.spinner {
  width: 1.4rem; height: 1.4rem; margin: 2.5rem auto;
  border: 2.5px solid var(--border-strong); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* --------------------------------------------------------------- Hero -- */
.hero {
  padding: 1.5rem 1.25rem;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 140% at 12% 0%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 62%),
    var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}
.hero h2 { font-size: 1.45rem; font-weight: 760; letter-spacing: -.025em; line-height: 1.2; }
.hero p { margin-top: .5rem; color: var(--text-muted); font-size: .94rem; max-width: 42rem; }
.hero__actions { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: 1.1rem; }

.tiles { display: grid; gap: .75rem; grid-template-columns: repeat(2, 1fr); margin-top: 1rem; }
.tile {
  display: flex; flex-direction: column; gap: .3rem;
  padding: .95rem 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: inherit; text-decoration: none;
}
.tile:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-2); }
.tile__icon { color: var(--primary); }
.tile__label { font-size: .93rem; font-weight: 680; }
.tile__hint { font-size: .8rem; color: var(--text-muted); }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.stat {
  padding: .75rem .85rem; text-align: center;
  background: var(--surface-2); border-radius: var(--radius);
}
.stat__value { font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat__label { font-size: .74rem; color: var(--text-muted); font-weight: 600; }

/* ------------------------------------------------------------- Detail -- */
.detail-hero {
  display: flex; flex-direction: column; gap: 1rem;
}
.detail-hero__image {
  width: 100%; aspect-ratio: 4 / 3; max-height: 380px;
  background: var(--surface-2); border-radius: var(--radius-lg);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
}
.detail-hero__image img { width: 100%; height: 100%; object-fit: contain; }
.detail-title { font-size: 1.3rem; font-weight: 740; letter-spacing: -.02em; line-height: 1.25; }
.detail-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .55rem; }
.detail-block { margin-top: 1.25rem; }
.detail-block__label {
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin-bottom: .25rem;
}
.detail-actions { display: flex; flex-direction: column; gap: .55rem; margin-top: 1.5rem; }

/* ------------------------------------------------------------ Profile -- */
.profile-head {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem; margin-bottom: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
}
.profile-head__body { min-width: 0; flex: 1; }
.profile-head__name { font-size: 1.2rem; font-weight: 730; letter-spacing: -.02em; }
.profile-head__meta { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin-top: .4rem; }

.dnote {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.1rem;
}
.dnote__value {
  font-size: 2rem; font-weight: 780; font-variant-numeric: tabular-nums;
  letter-spacing: -.03em; line-height: 1; color: var(--primary);
}
.dnote__body { flex: 1; min-width: 0; }
.dnote__label { font-size: .95rem; font-weight: 700; }
.dnote__hint { font-size: .81rem; color: var(--text-muted); margin-top: .15rem; }
.dnote__warn { color: var(--warning); }

.progress {
  height: 5px; margin-top: .5rem; border-radius: 999px;
  background: var(--surface-3); overflow: hidden;
}
.progress__bar { height: 100%; border-radius: 999px; background: var(--primary); transition: width .25s ease; }
.progress__bar--done { background: var(--success); }

.check-row {
  display: flex; align-items: flex-start; gap: .7rem;
  width: 100%; padding: .65rem 1.1rem;
  background: transparent; border: 0; border-top: 1px solid var(--border);
  text-align: left; cursor: pointer; color: inherit;
}
.check-row:first-child { border-top: 0; }
.check-row:hover { background: var(--surface-2); }
.check-row__icon { color: var(--text-faint); margin-top: .05rem; }
.check-row[aria-pressed="true"] .check-row__icon { color: var(--success); }
.check-row[aria-pressed="true"] .check-row__text { color: var(--text-muted); text-decoration: line-through; }
.check-row__text { font-size: .9rem; line-height: 1.4; }

.counted-flag { color: var(--success); }

/* -------------------------------------------------------------- Modal -- */
.modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(12, 14, 24, .5);
  backdrop-filter: blur(3px);
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px); opacity: .6; } }

.modal {
  width: 100%; max-width: 520px; max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-3);
  animation: rise .2s cubic-bezier(.2, .8, .3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.modal__head {
  display: flex; align-items: center; gap: .6rem;
  padding: 1rem 1.1rem .7rem;
}
.modal__title { font-size: 1.05rem; font-weight: 720; flex: 1; }
.modal__body { padding: 0 1.1rem 1.1rem; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal__foot {
  display: flex; gap: .55rem; padding: .85rem 1.1rem 1.1rem;
  border-top: 1px solid var(--border);
}
.modal__foot .btn { flex: 1; }

/* ------------------------------------------------------------- Toasts -- */
.toaster {
  position: fixed; z-index: 200;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + .8rem);
  display: flex; flex-direction: column; gap: .5rem;
  width: min(30rem, calc(100vw - 1.6rem));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: .55rem;
  padding: .7rem .9rem;
  font-size: .89rem; font-weight: 550;
  color: #fff; background: #22263a;
  border-radius: var(--radius); box-shadow: var(--shadow-2);
  animation: rise .18s ease;
}
@media (prefers-color-scheme: dark) { .toast { background: #eceef6; color: #171a26; } }
.toast--error { background: var(--danger); color: #fff; }
.toast--success { background: var(--success); color: #fff; }

/* ------------------------------------------------------------ Kür-Grid -- */
.routine-tabs { margin-bottom: 1rem; }

.routine-item__order { display: flex; flex-direction: column; gap: .1rem; }
.routine-item__order .icon-button { width: 1.9rem; height: 1.9rem; }
.routine-item__order .icon-button .icon { width: 1.05rem; height: 1.05rem; }

.auth-wrap {
  max-width: 26rem; margin: 1.5rem auto;
}
.auth-wrap .card__body { padding: 1.4rem; }
.auth-switch { margin-top: 1.1rem; font-size: .88rem; color: var(--text-muted); text-align: center; }

.legal { margin-top: 2rem; font-size: .78rem; color: var(--text-faint); text-align: center; }

/* ------------------------------------------------------ Rechtliches -- */
.legal-bar {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: 1.25rem 1rem 1.75rem;
  font-size: .8rem; color: var(--text-faint);
  border-top: 1px solid var(--border);
}
.legal-bar a { color: var(--text-muted); }

.legal-page { max-width: 46rem; margin: 0 auto; }
.legal-page__section { margin-top: 1.75rem; }
.legal-page__section:first-of-type { margin-top: 1.25rem; }
.legal-page__heading {
  font-size: 1rem; font-weight: 700; letter-spacing: -.01em;
  margin-bottom: .45rem;
}
.legal-page__text { margin-bottom: .6rem; font-size: .92rem; line-height: 1.65; }
.legal-page__text:last-child { margin-bottom: 0; }
.legal-page__list {
  margin: .4rem 0 0; padding-left: 1.1rem;
  font-size: .92rem; line-height: 1.6; list-style: disc;
}
.legal-page__list li { margin-bottom: .45rem; }
.legal-page__defs { margin: .3rem 0 0; font-size: .92rem; }
.legal-page__defs dt { font-weight: 640; color: var(--text-muted); }
.legal-page__defs dd { margin: 0 0 .5rem; }

/* --------------------------------------------- Pflicht-Einwilligung -- */
.consent {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .85rem .95rem;
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--radius);
  cursor: pointer;
}
.consent:hover { border-color: color-mix(in srgb, var(--primary) 50%, transparent); }
.consent input[type="checkbox"] {
  flex: none; width: 1.15rem; height: 1.15rem; margin: .1rem 0 0;
  accent-color: var(--primary); cursor: pointer;
}
.consent__text { font-size: .87rem; line-height: 1.5; }
.consent input[aria-invalid="true"] { outline: 2px solid var(--danger); outline-offset: 2px; }

/* ====================================================== Desktop ≥ 900px == */
@media (min-width: 900px) {
  .shell { grid-template-columns: var(--sidebar-w) 1fr; }

  .tabbar { display: none; }

  .main { padding-bottom: 0; }

  .sidebar {
    display: flex; flex-direction: column; gap: .4rem;
    position: sticky; top: 0; height: 100vh;
    padding: 1.1rem .8rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }

  .brand {
    display: flex; align-items: center; gap: .65rem;
    padding: .45rem .55rem 1.1rem;
    color: var(--text); text-decoration: none;
  }
  .brand:hover { text-decoration: none; }
  .brand__mark {
    display: flex; align-items: center; justify-content: center;
    width: 2.3rem; height: 2.3rem; flex: none;
    border-radius: 11px; background: var(--primary); color: var(--on-primary);
  }
  .brand__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
  .brand__text strong { font-size: .98rem; font-weight: 720; letter-spacing: -.02em; }
  .brand__text small { font-size: .74rem; color: var(--text-muted); }

  .nav { display: flex; flex-direction: column; gap: .12rem; }
  .nav__item {
    display: flex; align-items: center; gap: .7rem;
    padding: .58rem .7rem;
    font-size: .92rem; font-weight: 620;
    color: var(--text-muted); border-radius: var(--radius);
    text-decoration: none;
  }
  .nav__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
  .nav__item[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
  .nav__item .icon { width: 1.25rem; height: 1.25rem; }

  .sidebar__foot { margin-top: auto; padding-top: .8rem; border-top: 1px solid var(--border); }
  .sidebar__user {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .6rem; border-radius: var(--radius);
    color: inherit; text-decoration: none;
  }
  .sidebar__user:hover { background: var(--surface-2); text-decoration: none; }
  .sidebar__user .avatar { width: 34px; height: 34px; font-size: .9rem; }
  .sidebar__user-body { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
  .sidebar__user-name {
    display: block; font-size: .87rem; font-weight: 650;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sidebar__user-mail {
    display: block; font-size: .74rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sidebar__foot .btn { margin-top: .35rem; }

  .topbar {
    padding-left: 1.6rem; padding-right: 1.6rem;
    min-height: 66px;
  }
  .topbar__title { font-size: 1.32rem; letter-spacing: -.025em; }
  .topbar__back { display: none; }

  .view { padding: 1.35rem 1.6rem 3rem; }

  .toolbar { flex-direction: row; align-items: center; flex-wrap: wrap; gap: .6rem; }
  .searchbar { flex: 1 1 18rem; order: -1; }
  .segmented { flex: 0 0 auto; }
  .filterbar { flex: 1 1 100%; }

  .tiles { grid-template-columns: repeat(4, 1fr); }
  .hero { padding: 2rem 2.1rem; }
  .hero h2 { font-size: 1.85rem; }

  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius-xl); max-height: 84vh; }

  .toaster { bottom: 1.4rem; }

  /* Zweispaltige Übungsliste ab Desktop */
  .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 .list__item { border-top: 1px solid var(--border); }
  .grid-2 .list__item:nth-child(-n+2) { border-top: 0; }
  .grid-2 .list__item:nth-child(odd) { border-right: 1px solid var(--border); }

  .detail-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 2rem; align-items: start; }
  .detail-hero__image { aspect-ratio: 1 / 1; max-height: none; }
  .detail-actions { flex-direction: row; }
  .detail-actions .btn { flex: 1; }

  .profile-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
  .profile-layout .profile-head { flex-direction: column; text-align: center; position: sticky; top: 84px; }
  .profile-layout .profile-head__meta { justify-content: center; }

  .stat-row { gap: .8rem; }
}

@media (min-width: 1280px) {
  .grid-2 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 .list__item:nth-child(-n+3) { border-top: 0; }
  .grid-2 .list__item:nth-child(odd) { border-right: 0; }
  .grid-2 .list__item:not(:nth-child(3n)) { border-right: 1px solid var(--border); }
}
