/* Amalthea — Basis-Layout (themenunabhängig).
   Themes setzen nur CSS-Variablen; die Struktur lebt hier.
   Optimiert für 1080×1920 Portrait (Wand-Konsole) und responsiv darunter. */

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

:root {
  --radius: 14px;
  --radius-lg: 22px;
  --gap: 16px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --maxw: 1180px;
}

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); }

/* ===================== Login ===================== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 34px 30px; box-shadow: 0 24px 70px rgba(0,0,0,.35);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-brand h1 { margin: 0; font-size: 28px; color: var(--accent); letter-spacing: .5px; }
.brand-motto { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }
.brand-mark {
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 28px;
  display: grid; place-items: center;
}
.login-card label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 13px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--field); color: var(--text); font-size: 16px;
}
.login-join { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.login-join summary { cursor: pointer; color: var(--text-dim); font-size: 14px; }
.form-error { color: var(--bad); font-size: 14px; margin: 12px 0 0; }

/* ===================== App-Shell ===================== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: var(--gap);
  padding: 14px clamp(14px, 3vw, 28px); background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.topbar-titles { display: flex; flex-direction: column; min-width: 0; }
.app-name { font-weight: 800; font-size: 19px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-motto { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-clock { text-align: center; line-height: 1.1; }
#clock-time { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.clock-date { display: block; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.topbar-user { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: flex-end; }
.user-progress { text-align: right; min-width: 0; }
.user-name { display: block; font-weight: 700; }
.user-level { font-size: 12px; color: var(--text-dim); }
.xpbar { height: 7px; width: 140px; max-width: 38vw; border-radius: 99px; background: var(--field); overflow: hidden; margin-top: 5px; }
.xpbar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.btn-icon {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--field); color: var(--text); font-size: 20px; flex: 0 0 auto;
}

/* ===================== Navigation ===================== */
.nav {
  display: flex; gap: 8px; padding: 12px clamp(14px, 3vw, 28px);
  overflow-x: auto; background: var(--surface-2); border-bottom: 1px solid var(--border);
  position: sticky; top: 73px; z-index: 15; scrollbar-width: thin;
}
.nav-btn {
  display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--field);
  color: var(--text); font-size: 16px; white-space: nowrap; transition: .15s;
}
.nav-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.nav-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--accent-2); color: var(--accent-ink); font-size: 12px; font-weight: 700;
  display: inline-grid; place-items: center;
}
.nav-btn.active .nav-count { background: var(--accent-ink); color: var(--accent); }

/* ===================== Board ===================== */
.board {
  flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding: clamp(16px, 3vw, 28px); padding-bottom: 90px;
}
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.view-head h2 { margin: 0; font-size: clamp(22px, 4vw, 30px); }
.view-sub { margin: 4px 0 0; color: var(--text-dim); }
.section-divider {
  margin: 26px 0 12px; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent-2); font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 6px;
}
.empty-state {
  padding: 34px; text-align: center; color: var(--text-dim);
  border: 1px dashed var(--border); border-radius: var(--radius-lg);
}

/* ===================== Task-Karten ===================== */
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.task-card {
  display: flex; align-items: flex-start; gap: 14px; position: relative;
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--accent);
  border-radius: var(--radius); padding: 16px 16px 16px 16px;
}
.task-card.is-done { opacity: .6; border-left-color: var(--good); }
.task-check {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid var(--accent); background: transparent; color: var(--good);
  font-size: 20px; font-weight: 800; display: grid; place-items: center; transition: .15s;
}
.task-check.done { background: var(--good); color: var(--accent-ink); border-color: var(--good); }
.task-check:disabled { opacity: .4; cursor: not-allowed; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 17px; font-weight: 600; line-height: 1.25; }
.is-done .task-title { text-decoration: line-through; }
.task-desc { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.task-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--field);
  color: var(--text-dim); white-space: nowrap; border: 1px solid var(--border);
}
.chip-xp { color: var(--accent); border-color: var(--accent); }
.chip-who { color: var(--accent-2); }
.chip-due { color: var(--bad); border-color: var(--bad); }
.task-edit {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--field); color: var(--text-dim);
}

/* ===================== Mitglieder ===================== */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.member-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.member-name { font-weight: 700; display: block; }
.member-level { font-size: 12px; color: var(--text-dim); }
.member-card .xpbar { width: 100%; max-width: none; margin-top: 8px; }
.member-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.member-row .member-name { flex: 1; }

/* ===================== Verlauf ===================== */
.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.log-title { font-weight: 500; }
.log-meta { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

/* ===================== Einstellungen ===================== */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; }
.settings-card h3 { margin: 0 0 16px; color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--text-dim); }
.field input, .field select, .dialog input, .dialog select, .dialog textarea {
  padding: 11px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--field); color: var(--text); font-size: 15px; width: 100%;
}
.field-hint { color: var(--text-dim); font-size: 13px; margin: 0 0 6px; }
.btn-row, .btn-row a, .btn-row button { }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-choice { display: flex; gap: 12px; flex-wrap: wrap; }
.theme-opt {
  flex: 1; min-width: 130px; text-align: left; padding: 14px; border-radius: var(--radius);
  border: 2px solid var(--border); background: var(--field); color: var(--text);
}
.theme-opt strong { display: block; }
.theme-opt span { font-size: 12px; color: var(--text-dim); }
.theme-opt.active { border-color: var(--accent); }

/* ===================== Buttons ===================== */
.btn-primary, .btn-ghost, .btn-danger {
  padding: 13px 22px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 16px; font-weight: 600;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--field); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 14px; }

/* ===================== Dialoge ===================== */
.dialog {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0;
  background: var(--surface); color: var(--text); width: min(560px, 94vw); max-height: 92vh;
}
.dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.dialog form { padding: 26px; overflow: auto; max-height: 92vh; }
.dialog h2 { margin: 0 0 18px; color: var(--accent); }
.dialog label { display: block; font-size: 14px; color: var(--text-dim); margin-bottom: 12px; }
.dialog label span { display: block; margin-bottom: 5px; }
.dialog .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.dialog label.check { display: flex; align-items: center; gap: 9px; }
.dialog label.check input { width: auto; }
.dialog-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.dialog-actions .spacer { flex: 1; }

/* ===================== Sonntag-Banner ===================== */
.sunday-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 18;
  padding: 12px clamp(14px, 3vw, 28px); text-align: center; font-size: 15px;
  background: var(--accent-2); color: var(--accent-ink);
}
.sunday-banner strong { margin-right: 8px; }

/* ===================== Toast ===================== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50;
  padding: 13px 22px; border-radius: 999px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: 0 12px 36px rgba(0,0,0,.3); font-weight: 600;
}
.toast.good { border-color: var(--good); color: var(--good); }
.toast.bad { border-color: var(--bad); color: var(--bad); }

/* ===================== Portrait / Wand-Konsole ===================== */
@media (min-aspect-ratio: 1/1) { /* Querformat: nichts Spezielles */ }
@media (max-aspect-ratio: 3/4) {
  /* Hochkant (z. B. 1080×1920): größere Touch-Ziele */
  .nav-btn { padding: 16px 26px; font-size: 18px; }
  .task-grid { grid-template-columns: 1fr; }
  .task-title { font-size: 19px; }
  .task-check { width: 44px; height: 44px; }
}
@media (max-width: 560px) {
  .topbar-clock { display: none; }
  .dialog .form-grid { grid-template-columns: 1fr; }
  .task-grid { grid-template-columns: 1fr; }
}
