:root {
  --bg: #120c24;
  --bg-2: #1a1233;
  --surface: #211843;
  --surface-2: #2b2056;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #f4f0ff;
  --muted: #a99fcc;
  --dim: #6f6596;
  --accent: #ff5d8f;
  --accent-2: #ffb347;
  --grad: linear-gradient(120deg, #ff5d8f, #ff8a5c 55%, #ffb347);
  --fav: #facc15;
  --yes: #4ade80;
  --maybe: #fb923c;
  --no: #f87171;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", var(--font);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(255, 93, 143, 0.18), transparent 60%),
    radial-gradient(700px 500px at -10% 10%, rgba(120, 90, 255, 0.18), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.45 var(--font);
}
body.sheet-open { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.01em; }

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 96px);
}

/* ---------- Buttons & Inputs ---------- */
.btn {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 650;
  background: var(--surface-2);
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--grad); color: #21102b; }
.btn.ghost { background: transparent; border: 1px solid var(--line-2); }
.btn.danger { background: rgba(248, 113, 113, 0.14); color: #ffb4b4; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }
.linklike { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 4px; font-size: 13px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, textarea.input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 64px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Gate / Wer bist du ---------- */
.center-screen { min-height: 80dvh; display: grid; place-items: center; text-align: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.welcome { width: 100%; max-width: 420px; display: grid; gap: 18px; }
.welcome .logo-big { width: 84px; height: 84px; margin: 0 auto; border-radius: 22px; box-shadow: 0 10px 40px rgba(255, 93, 143, .35); }
.welcome h1 { font-size: 30px; }
.welcome p { margin: 0; color: var(--muted); }
.welcome form { display: grid; gap: 10px; }
.member-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.member-pick {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px 8px 8px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
}
.member-pick:hover { border-color: var(--accent); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.avatar {
  --c: #888;
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c); color: #1a1030; font-size: 12px; font-weight: 800;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }

/* ---------- Kopf ---------- */
.top { display: flex; align-items: center; gap: 8px; padding: 6px 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-family: var(--display); font-weight: 800; font-size: 20px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 46%;
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 4px 12px 4px 4px;
}
.me-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }

.tabs { display: flex; gap: 4px; background: var(--surface); border-radius: 999px; padding: 4px; margin: 4px 0 16px; }
.tabs button { flex: 1; border: 0; background: none; border-radius: 999px; padding: 9px; font-weight: 650; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }

.fab {
  position: fixed; right: max(16px, calc((100vw - 960px) / 2 + 16px));
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  border: 0; border-radius: 999px; padding: 15px 22px; font-weight: 800; font-size: 16px;
  background: var(--grad); color: #21102b; box-shadow: 0 10px 30px rgba(255, 93, 143, .45); z-index: 20;
}
.offline {
  position: fixed; left: 16px; bottom: calc(env(safe-area-inset-bottom) + 24px); z-index: 20;
  background: #3a2a10; color: #ffd28a; border-radius: 999px; padding: 8px 14px; font-size: 13px;
}

/* ---------- Kalender ---------- */
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.cal-head h2 { flex: 1; font-size: 22px; text-transform: capitalize; }
.cal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-wd { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.cal-wd div { padding: 8px 0 6px; text-align: center; }
.week {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-height: 72px;
  border-top: 1px solid var(--line);
  row-gap: 3px;
  padding-bottom: 4px;
}
.day {
  position: relative; border: 0; background: none; padding: 0;
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
}
.day:first-child { border-left: 0; }
.day:hover { background: rgba(255, 255, 255, .03); }
.day .num { font-size: 12px; font-weight: 650; color: var(--muted); margin-top: 4px; width: 22px; height: 22px; line-height: 22px; border-radius: 50%; }
.day.out .num { color: var(--dim); opacity: .55; }
.day.today .num { background: var(--accent); color: #1a1030; }
.day.weekend { background: rgba(255, 255, 255, .015); }

.bar {
  position: relative; z-index: 1;
  margin: 0 2px;
  --fc: var(--accent);
  background: color-mix(in srgb, var(--fc) 22%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--fc) 55%, transparent);
  border-radius: 8px;
  padding: 2px 3px 3px;
  min-width: 0;
  cursor: pointer;
  outline-offset: 1px;
}
.bar:hover { background: color-mix(in srgb, var(--fc) 32%, var(--surface)); }
.bar.cl { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; border-left-style: dashed; }
.bar.cr { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; border-right-style: dashed; }
.bar-name {
  font-size: 11px; font-weight: 750; line-height: 14px; padding: 0 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: color-mix(in srgb, var(--fc) 40%, #fff);
}
.bar-days { display: grid; gap: 2px; margin-top: 2px; }
.seg {
  min-height: 12px; border-radius: 4px; padding: 2px;
  display: flex; flex-wrap: wrap; gap: 2px; align-content: flex-start; justify-content: center;
  background: rgba(0, 0, 0, .18);
}
.seg.all { background: rgba(74, 222, 128, .22); box-shadow: inset 0 0 0 1px rgba(74, 222, 128, .6); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.me { box-shadow: 0 0 0 1.5px #fff; }
.s-fav { --s: var(--fav); }
.s-yes { --s: var(--yes); }
.s-maybe { --s: var(--maybe); }
.s-no { --s: var(--no); }
.dot { background: var(--s, #888); }
.seg .more { font-size: 9px; line-height: 7px; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 2px 0; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); font-weight: 700; margin: 24px 2px 10px; font-family: var(--font); }
.empty { color: var(--muted); padding: 18px; text-align: center; background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--line-2); }
.empty .btn { margin-top: 10px; }

.fcard {
  display: flex; gap: 12px; align-items: stretch; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
}
.fcard:hover { border-color: var(--line-2); }
.fcard .stripe { width: 5px; border-radius: 4px; background: var(--fc, var(--accent)); flex: none; }
.fcard .body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.fcard .title { font-weight: 750; font-size: 16px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.fcard .meta { color: var(--muted); font-size: 13px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650;
  border-radius: 999px; padding: 2px 9px; background: rgba(255, 255, 255, .06); color: var(--muted); white-space: nowrap;
}
.pill.status { background: color-mix(in srgb, var(--s) 18%, transparent); color: color-mix(in srgb, var(--s) 70%, #fff); }
.pill.open { background: rgba(255, 93, 143, .16); color: #ffb3c8; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.avatars { display: flex; }
.avatars .avatar { width: 22px; height: 22px; font-size: 9px; margin-left: -5px; box-shadow: 0 0 0 2px var(--surface); }
.avatars .avatar:first-child { margin-left: 0; }

/* ---------- Ranking ---------- */
.rank {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.rank:hover { border-color: var(--line-2); }
.rank.top { border-color: rgba(250, 204, 21, .5); background: linear-gradient(160deg, rgba(250, 204, 21, .08), transparent 50%), var(--surface); }
.rank .pos { font-family: var(--display); font-weight: 800; font-size: 26px; width: 34px; text-align: center; color: var(--dim); }
.rank.top .pos { color: var(--fav); }
.rank .body { min-width: 0; display: grid; gap: 7px; }
.rank .title { font-weight: 750; font-size: 17px; }
.meter { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--grad); }
.rank .facts { font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.rank .facts b { color: var(--text); font-weight: 650; }
.rank.past { opacity: .6; }
details.past-list summary { cursor: pointer; color: var(--muted); margin: 20px 2px 10px; }

/* ---------- Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(5, 2, 15, .6); backdrop-filter: blur(3px); z-index: 40; animation: fade .15s; }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto;
  max-width: 640px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg-2); border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 24px);
  animation: up .2s ease-out;
}
@media (min-width: 700px) {
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 22px; border-bottom: 1px solid var(--line-2); animation: fade .15s; max-height: 88dvh; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 0 auto 6px; }
.sheet-close { position: absolute; right: 8px; top: 8px; font-size: 24px; }
.sheet h2 { font-size: 24px; padding-right: 40px; }
.sheet h3 { font-size: 16px; margin: 22px 0 10px; font-family: var(--font); font-weight: 750; }
.sheet .sub { color: var(--muted); margin-top: 4px; display: grid; gap: 2px; font-size: 14px; }
.sheet .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.sheet .actions .spacer { flex: 1; }
.notes { white-space: pre-wrap; background: var(--surface); border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-size: 14px; color: var(--muted); }

.status-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.status-btn {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 12px;
  padding: 10px 4px; display: grid; gap: 2px; justify-items: center; font-size: 12px; font-weight: 650; color: var(--muted);
}
.status-btn .ic { font-size: 20px; line-height: 1.1; }
.status-btn[aria-pressed="true"] { border-color: var(--s); background: color-mix(in srgb, var(--s) 18%, var(--surface)); color: var(--text); }

.mini-cal { margin-top: 12px; background: var(--surface); border-radius: 14px; padding: 8px; }
.mini-cal .wdrow, .mini-cal .wk { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mini-cal .wk { margin-top: 4px; }
.mini-cal .wdrow div { text-align: center; font-size: 11px; color: var(--dim); font-weight: 700; padding: 2px 0; }
.daytile {
  aspect-ratio: 1 / 1; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2);
  display: grid; place-content: center; text-align: center; line-height: 1.1; padding: 0;
}
.daytile .dn { font-weight: 800; font-size: 16px; }
.daytile .mo { font-size: 10px; color: var(--muted); }
.daytile.on { background: color-mix(in srgb, var(--s, var(--yes)) 28%, var(--bg-2)); border-color: var(--s, var(--yes)); }
.daytile.on .mo { color: var(--text); }
.daytile.off { opacity: .25; border-style: dashed; cursor: default; }
.daytile:disabled { cursor: default; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 2px 0; min-height: 18px; }
.save-state { font-size: 12px; color: var(--dim); margin-left: 6px; font-weight: 500; }
.save-state.ok { color: var(--yes); }
.save-state.err { color: var(--no); }

.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table.grp { border-collapse: collapse; width: 100%; font-size: 13px; }
.grp th, .grp td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.grp th { font-size: 11px; color: var(--dim); font-weight: 700; background: var(--surface); }
.grp th:first-child, .grp td:first-child { text-align: left; position: sticky; left: 0; background: var(--bg-2); z-index: 1; }
.grp th:first-child { background: var(--surface); }
.grp .who { display: flex; align-items: center; gap: 7px; }
.grp .who .nm { font-weight: 650; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.grp .cm { display: block; font-size: 11px; color: var(--muted); white-space: normal; max-width: 160px; }
.grp tr.me td:first-child .nm::after { content: " (du)"; color: var(--dim); font-weight: 400; }
.cell i { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: rgba(255, 255, 255, .05); font-style: normal; font-size: 12px; line-height: 1; }
.cell.on i { background: color-mix(in srgb, var(--s) 45%, transparent); box-shadow: inset 0 0 0 1px var(--s); }
.fill-row { display: flex; justify-content: flex-end; margin-top: 8px; }
.daytile .mo { line-height: 1.2; }
.grp tfoot td { font-weight: 750; color: var(--muted); border-bottom: 0; }
.grp tfoot td.best { color: var(--yes); }

.mem-list { display: grid; gap: 8px; }
.mem-row { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 12px; padding: 8px 10px; }
.mem-row .input { padding: 7px 10px; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { font-size: 13px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translate(-50%, 20px);
  background: #fff; color: #1a1030; padding: 10px 16px; border-radius: 999px; font-weight: 650; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #ffd0d0; }

@media (min-width: 700px) {
  .week { min-height: 92px; }
  .bar-name { font-size: 12px; }
  .dot { width: 9px; height: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
