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

::selection { background: var(--accent); color: #0b1221; }

:root {
  --bg: #0b1221;
  --card: #162032;
  --border: #3d5068;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --accent: #e2a65c;
  --green: #4ade80;
  --red: #f87171;
  --warning: #ff9f0a;
  --danger: #ff453a;
  --success: #30d158;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
  min-height: 100dvh;
}

body { display: flex; flex-direction: column; }

#header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
}
.header-inner {
  max-width: 430px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.header-title { font-size: 20px; font-weight: 700; }
.header-user {
  color: var(--text-secondary); font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.header-user button { min-height: 0; padding: 6px 10px; font-size: 13px; }

#main {
  flex: 1; width: 100%; max-width: 430px; margin: 0 auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 80px);
  -webkit-overflow-scrolling: touch;
}

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar-inner { max-width: 430px; margin: 0 auto; display: flex; }
.tab {
  /* flex-basis 0 + min-width 0: six equal tabs that shrink instead of
     pushing the last one off narrow screens */
  flex: 1 1 0; min-width: 0; min-height: 56px; padding: 0 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; color: var(--text-secondary);
  font-size: 10px; cursor: pointer;
}
.tab-label { max-width: 100%; white-space: nowrap; overflow: hidden; }
.tab .tab-icon { font-size: 22px; line-height: 1; }
.tab.active { color: var(--accent); }

h2 { font-size: 18px; margin-bottom: 12px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.section-head h2 { margin-bottom: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.card.tappable { cursor: pointer; }

.card-title { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--text-secondary); font-size: 14px; margin-top: 6px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.badge {
  display: inline-block; padding: 3px 8px; border-radius: 8px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-blocked { background: rgba(255, 69, 58, 0.18); color: var(--danger); }
.badge-free { background: rgba(48, 209, 88, 0.15); color: var(--success); }
.badge-warn { background: rgba(255, 159, 10, 0.15); color: var(--warning); }
.badge-info { background: rgba(226, 166, 92, 0.15); color: var(--accent); }
.badge-muted { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }

button, .btn {
  min-height: 44px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b1221; }
.btn-danger { background: none; border-color: var(--danger); color: var(--danger); }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-bottom: 12px; }
.btn-row > * { flex: 1; }

input, select, textarea {
  width: 100%; min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  font-size: 16px; font-family: inherit;
}
textarea { resize: vertical; min-height: 80px; }
label { display: block; font-size: 13px; color: var(--text-secondary); margin: 10px 0 4px; }
.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; }
form .btn-row { margin-top: 12px; margin-bottom: 0; }

.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .muted { color: var(--text-secondary); font-size: 13px; }

.chip {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 14px; margin: 3px 4px 3px 0; cursor: pointer;
}

.empty { color: var(--text-secondary); text-align: center; padding: 24px 0; font-size: 14px; }

.check {
  width: 28px; height: 28px; min-height: 28px; padding: 0;
  border-radius: 50%; border: 2px solid var(--border);
  background: none; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--success);
}
.check.done { border-color: var(--success); background: rgba(48, 209, 88, 0.15); }

.done-title { text-decoration: line-through; color: var(--text-secondary); }

.back-link {
  display: inline-block; color: var(--accent); font-size: 15px;
  margin-bottom: 12px; cursor: pointer; padding: 4px 0; border: none; background: none;
  min-height: 0; font-weight: 600;
}

.date-group { color: var(--text-secondary); font-size: 13px; font-weight: 700; margin: 16px 0 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.date-group:first-child { margin-top: 0; }

.login-wrap { padding-top: 12dvh; text-align: center; }
.login-logo { font-size: 64px; margin-bottom: 8px; }
.login-wrap h1 { font-size: 24px; margin-bottom: 24px; }
.login-wrap form { text-align: left; }
.login-toggle { margin-top: 16px; background: none; border: none; color: var(--accent); font-size: 14px; }

.error-msg { color: var(--danger); font-size: 14px; margin-top: 10px; text-align: center; }

.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 12px; }
.check-item { display: flex; align-items: center; gap: 8px; font-size: 15px; min-height: 32px; }
.check-item input { width: 18px; min-height: 0; height: 18px; padding: 0; accent-color: var(--accent); }

/* Ritt: ein Auswahlfeld je Pferd — wer saß drauf? */
.mount-grid { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.mount-row { display: flex; align-items: center; gap: 10px; }
.mount-name { flex: 1; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mount-row select { flex: 0 0 58%; min-height: 40px; padding: 6px 10px; color: var(--text-secondary); }
.mount-row select.set { color: var(--text); border-color: var(--accent); }

.post-photo { width: 100%; border-radius: 10px; margin-top: 10px; display: block; }
input[type="file"] { padding: 8px 12px; }

.tab-icon { position: relative; }
.tab-badge {
  position: absolute; top: -4px; right: -14px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 3px 5px; border-radius: 9px; min-width: 17px; text-align: center;
}

/* Waagerechte Auswahlleiste (Protokoll-Register, Ritt-Zeitraum) */
.chip-row {
  display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px;
  padding-bottom: 4px; -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .chip { flex: 0 0 auto; margin: 0; white-space: nowrap; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #0b1221; font-weight: 600; }

/* Säulendiagramm der Ritt-Statistik — Nullzeilen bleiben sichtbar. */
.bar-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; }
.bar-name { flex: 0 0 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-rank { display: inline-block; min-width: 20px; color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.bar-track { flex: 1; height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; display: flex; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
/* Gestapelte Balken (Heu + Silo in einem Monat): die runden Enden macht die
   Spur per overflow, die Segmente selbst stoßen stumpf aneinander. */
.bar-seg { border-radius: 0; flex: none; }
.bar-fill.alt { background: var(--green); }
.bar-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  background: var(--accent); margin-right: 5px; vertical-align: -1px; }
.bar-key.alt { background: var(--green); }
.bar-val { flex: 0 0 auto; min-width: 88px; text-align: right; color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
