:root {
  --bg: #161c27;
  --surface: #1f2735;
  --surface-2: #283244;
  --line: #36425a;
  --text: #ece5d3;
  --muted: #a3abba;
  --gold: #c9a227;
  --gold-soft: #3a3320;
  --gold-ink: #1a1406;
  --danger: #d4695d;
  --ok: #74b382;
  --warn: #dcaa4c;
  --radius: 10px;
  --radius-sm: 6px;
  --serif: 'Palatino Linotype', Palatino, 'Book Antiqua', 'URW Palladio L', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.9em; }
a { color: var(--gold); }
a:hover { color: #e3c25a; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error-text { color: var(--danger); }
.ok-text { color: var(--ok); }

/* ---------- Kopfzeile ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand span { color: var(--gold); }
.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; flex: 1; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--gold); }
.who { display: flex; margin-left: auto; gap: 0.75rem; align-items: center; color: var(--muted); font-size: 0.9rem; }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
  outline: none;
}

.head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.head h1 { margin: 0; }

/* ---------- Bedienelemente ---------- */

.btn {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 600; }
.btn.primary:hover { background: #dbb437; }
.btn.danger { color: var(--danger); border-color: #6b3a35; }
.btn.danger:hover { background: #3a2422; }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }

.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row > input { flex: 1 1 16rem; width: auto; min-width: 0; }
.stack > * + * { margin-top: 1rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.panel + .panel { margin-top: 1rem; }

.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.tabs a { padding: 0.4rem 0.9rem; color: var(--muted); text-decoration: none; }
.tabs a.active { background: var(--surface-2); color: var(--text); }

/* ---------- Formulare ---------- */

label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.3rem; }
.field { margin-bottom: 1rem; }
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 0.3rem; }

input[type='text'], input[type='password'], input[type='number'], input[type='datetime-local'], input[type='url'],
select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 2px var(--gold-soft); }
input[type='color'] {
  width: 3.2rem;
  height: 2.4rem;
  padding: 0.15rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
input[type='checkbox'] { accent-color: var(--gold); width: 1rem; height: 1rem; }
.check { display: flex; gap: 0.5rem; align-items: center; color: var(--text); font-size: 0.95rem; margin: 0; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 0.25rem;
  margin: 0 0 1.25rem;
}
legend { font-family: var(--serif); font-size: 1.1rem; padding: 0 0.4rem; }

.picker {
  max-height: 11rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.4rem 0.6rem;
}
.picker .check { padding: 0.15rem 0; }

.form-error {
  border: 1px solid #6b3a35;
  background: #2c1e1d;
  color: #f0b8b0;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

/* ---------- Anmeldung ---------- */

.login {
  max-width: 380px;
  margin: 12vh auto 0;
}
.login h1 { text-align: center; }
.login .brandmark {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
}

/* ---------- Eventliste ---------- */

.events { list-style: none; margin: 0; padding: 0; }
.event-row {
  display: grid;
  grid-template-columns: 5.2rem 1fr auto;
  gap: 1.1rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}
.event-row + .event-row { margin-top: 0.6rem; }
.event-row:hover { border-color: var(--gold); }
.event-row .title { font-family: var(--serif); font-size: 1.15rem; display: block; color: var(--text); }
.event-row .meta { font-size: 0.875rem; color: var(--muted); }
.datebox {
  text-align: center;
  border-left: 3px solid var(--event-color, var(--gold));
  padding-left: 0.6rem;
  line-height: 1.1;
}
.datebox .day { font-family: var(--serif); font-size: 1.9rem; display: block; }
.datebox .mon { font-size: 0.8rem; color: var(--muted); display: block; }
.datebox .time { font-size: 0.85rem; display: block; margin-top: 0.2rem; }

.counts { display: flex; gap: 0.4rem 0.9rem; font-size: 0.9rem; color: var(--muted); flex-wrap: wrap; justify-content: flex-end; }
.counts b { color: var(--text); font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { border-color: #3d6347; color: var(--ok); }
.badge.warn { border-color: #6a5427; color: var(--warn); }
.badge.bad { border-color: #6b3a35; color: var(--danger); }

.empty {
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty p { margin-bottom: 1rem; }

/* ---------- Eventdetails und Aufstellung ---------- */

.detail-head { border-left: 4px solid var(--event-color, var(--gold)); padding-left: 1rem; margin-bottom: 1.25rem; }
.detail-head h1 { margin-bottom: 0.3rem; }
.facts { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; color: var(--muted); font-size: 0.95rem; margin: 0; padding: 0; list-style: none; }
.facts li b { color: var(--text); font-weight: 500; }
.description { white-space: pre-wrap; margin: 1rem 0 0; }

.notice {
  border: 1px solid #6a5427;
  background: #2b2617;
  color: #ecd49a;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}
.notice.bad { border-color: #6b3a35; background: #2c1e1d; color: #f0b8b0; }

.roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}
.role-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 0.6rem;
}
.role-col h3 { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.45rem; }
.role-col h3 .num { font-family: var(--sans); font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.role-col h3 .num.full { color: var(--gold); }
.meter { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-bottom: 0.6rem; }
.meter > span { display: block; height: 100%; background: var(--gold); width: 0; transition: width 0.3s ease; }
.people { list-style: none; margin: 0; padding: 0; }
.people li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-top: 1px solid var(--surface-2);
  font-size: 0.95rem;
}
.people li:first-child { border-top: 0; }
.people .icon { width: 1.4rem; text-align: center; }
.people .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .spec { color: var(--muted); font-size: 0.85rem; }
.people .none { color: var(--muted); font-style: italic; border: 0; }
.people .x {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.2rem;
  border-radius: 4px;
}
.people .x:hover { color: var(--danger); }

.side-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.side-lists .role-col { padding-bottom: 0.4rem; }

/* ---------- Tabellen ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: 0.875rem; }
.table td .row { justify-content: flex-end; }

/* ---------- Vorlagen-Editor ---------- */

.editor-row { display: grid; grid-template-columns: 4.5rem 1fr 6rem auto; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.editor-row.noemoji { grid-template-columns: 1fr auto; }
.editor-row.nolimit { grid-template-columns: 4.5rem 1fr auto; }

/* ---------- Discord-Einrichtung ---------- */

.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 1.4rem 2.6rem;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -0.1rem;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  color: var(--muted);
}
.steps > li.done::before { content: '✓'; border-color: var(--ok); color: var(--ok); }
.steps h3 { margin-bottom: 0.35rem; }
code, .code {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  word-break: break-all;
}

/* ---------- Meldungen und Dialog ---------- */

.toasts { position: fixed; bottom: 1rem; right: 1rem; display: grid; gap: 0.5rem; z-index: 20; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.toast.error { border-left-color: var(--danger); }

.dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 420px;
  width: calc(100% - 2rem);
}
.dialog::backdrop { background: rgba(8, 10, 15, 0.7); }

@media (max-width: 720px) {
  h1 { font-size: 1.55rem; }
  .grid, .grid.three { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .event-row { grid-template-columns: 4.2rem 1fr; }
  .event-row .counts { grid-column: 1 / -1; justify-content: flex-start; }
  .topbar { gap: 0.5rem 1rem; padding: 0.6rem 1rem 0; }
  .nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -0.25rem; padding-bottom: 0.4rem; }
  .nav a { white-space: nowrap; }
  .table .hide-sm { display: none; }
  .editor-row { grid-template-columns: 3.5rem 1fr 4.5rem auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
