/* Cremadura — Design-Sprache: Espresso-Kultur trifft Rennrad.
   Warm, taktil, italienisch; bewusster Gegenentwurf zum kalten Tech-Blau.
   Der Look verschönert Daten nie — die ehrlichen Kennzahlen bleiben sichtbar. */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* --- Rohpalette (Marken-Tokens) --- */
  --espresso:   #241813;   /* Röst-Grund: dunkle Surface, Text auf Hell */
  --coffee:     #4A2C1A;   /* mittleres Kaffeebraun: Sekundärflächen */
  --crema:      #C98A43;   /* SIGNATURFARBE: goldene Crema – primärer Akzent */
  --crema-lite: #E3B87A;   /* hellere Crema: Highlights/Hover */
  --foam:       #F4EBDD;   /* Milchschaum: heller Haupt-Hintergrund */
  --latte:      #E9DAC6;   /* Karten-/Sekundärflächen hell */
  --celeste:    #7FC9BC;   /* kühler Kontrast (Bianchi-Celeste): interaktive Elemente */

  /* --- Semantische Aliase (Default = "Latte", hell) --- */
  --bg:        var(--foam);
  --surface:   #fbf4e9;
  --surface-2: #ffffff;
  --text:      var(--espresso);
  --muted:     #7a6650;
  --border:    #e0cdb4;
  --accent:      var(--crema);
  --accent-lite: var(--crema-lite);
  --accent-2:    var(--celeste);
  --on-accent: #241813;
  --danger:    #c0392b;
  --success:   var(--celeste);
  --shadow: 0 1px 2px rgba(74,44,26,.06), 0 10px 26px rgba(74,44,26,.10);
  --shadow-sm: 0 1px 2px rgba(74,44,26,.10);
  --radius: 14px;

  /* Heatmap-„Röst-Rampe" */
  --hm-empty: #ead9c0;
  /* Chart-Farben (theme-aware, von tour-chart.js gelesen) */
  --chart-hr:   #b0492e;
  --chart-speed:#2e9e8c;
  --chart-alt:  rgba(74,44,26,.12);
  --chart-grid: rgba(36,24,19,.10);
  --chart-text: #7a6650;
}

/* --- Dark-Theme „Espresso" (via [data-theme=espresso]; Umschalter aktuell versteckt) --- */
:root[data-theme="espresso"] {
  --bg:        var(--espresso);
  --surface:   #33231a;
  --surface-2: #3d2a1f;
  --text:      var(--foam);
  --muted:     #b9a488;
  --border:    #4a3527;
  --on-accent: #241813;
  --danger:    #e06b5a;
  --shadow: 0 1px 2px rgba(0,0,0,.25), 0 10px 28px rgba(0,0,0,.28);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
  --hm-empty: #3a2a1f;
  --chart-hr:   #e8895b;
  --chart-speed:#7FC9BC;
  --chart-alt:  rgba(244,235,221,.10);
  --chart-grid: rgba(244,235,221,.12);
  --chart-text: #b9a488;
}

* { box-sizing: border-box; }
body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text); background: var(--bg); margin: 0; line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
}
.container { max-width: 64rem; width: 100%; margin: 0 auto; padding: 1.5rem 1.1rem 2rem; flex: 1; }
.container-narrow { max-width: 30rem; }

h1, h2, h3, h4, .display {
  font-family: "Fraunces", Georgia, "Times New Roman", serif; color: var(--text);
  line-height: 1.2; letter-spacing: -.01em;
}
h1 { font-size: 1.7rem; margin: .2rem 0 .1rem; font-weight: 600; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 .4rem; font-weight: 600; }
a { color: var(--accent-lite); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* Alle Messwerte: gleichmäßige Ziffern */
.stat .n, td.num, .metrics .n { font-variant-numeric: tabular-nums; }

/* ---------- Crema-Ring (Logo-Mark + Spinner) ---------- */
.crema-ring {
  display: inline-block; width: 1.15em; height: 1.15em; border-radius: 50%;
  border: .18em solid var(--crema); border-top-color: transparent;
  vertical-align: -.18em; box-shadow: 0 0 10px rgba(201,138,67,.5);
}
.crema-ring.spin { animation: crema-spin 1s linear infinite; }
@keyframes crema-spin { to { transform: rotate(360deg); } }

/* ---------- Topbar (immer Röst-Look, konsistente Marke) ---------- */
.topbar {
  background: linear-gradient(100deg, #1c120d 0%, var(--espresso) 45%, var(--coffee) 130%);
  color: var(--foam); box-shadow: var(--shadow-sm);
  border-bottom: 2px solid var(--crema);
}
.topbar-inner { max-width: 64rem; margin: 0 auto; padding: .65rem 1.1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--foam);
  font-family: "Fraunces", serif; font-weight: 700; font-size: 1.35rem; letter-spacing: .3px; }
.brand:hover { text-decoration: none; color: #fff; }
.brand .crema-ring { width: 1.1rem; height: 1.1rem; }
.topbar nav { display: flex; gap: .15rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #efe4d3; padding: .35rem .7rem; border-radius: 999px; font-size: .92rem; font-weight: 600; }
.topbar nav a:hover { background: rgba(244,235,221,.12); text-decoration: none; }
.topbar nav a.active { background: rgba(201,138,67,.22); color: var(--crema-lite); }
.topbar .who { color: #d8c7ad; font-size: .85rem; }
.theme-toggle {
  background: transparent; border: 1px solid rgba(244,235,221,.4); color: var(--foam);
  border-radius: 999px; padding: .25rem .6rem; font-size: .85rem; box-shadow: none; cursor: pointer;
}
.theme-toggle:hover { background: rgba(244,235,221,.12); filter: none; }

/* ---------- Footer ---------- */
.site-footer { text-align: center; color: var(--muted); font-size: .82rem;
  padding: 1.4rem 1rem 1.8rem; border-top: 1px solid var(--border); margin-top: 1rem; }
.site-footer .dot { color: var(--crema); }
.site-footer a { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn, button, input[type=submit] {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent; border-radius: 10px;
  padding: .5rem .95rem; background: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-sm); transition: filter .12s ease, transform .02s ease, background .12s ease;
}
.btn:hover, button:hover { filter: brightness(1.05); text-decoration: none; }
.btn:active, button:active { transform: translateY(1px); }
.btn:disabled, button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--celeste); outline-offset: 2px;
}
.btn-accent { background: var(--celeste); color: #10302b; }
.btn-success { background: var(--celeste); color: #10302b; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--foam); border-color: rgba(244,235,221,.5); box-shadow: none; }
.btn-ghost:hover { background: rgba(244,235,221,.14); }
.btn-outline { background: var(--surface); color: var(--accent-lite); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; color: var(--text); margin-top: .8rem; }
input, select, textarea {
  width: 100%; padding: .55rem .65rem; margin-top: .25rem; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); font: inherit; color: var(--text);
}
input::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--crema); box-shadow: 0 0 0 3px rgba(201,138,67,.25);
}
select { width: auto; }

/* ---------- Cards & messages ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.2rem; margin-top: 1rem; }
.msg { padding: .6rem .8rem; border-radius: 10px; margin: 1rem 0; border: 1px solid transparent; }
.msg.info  { background: rgba(127,201,188,.14); color: var(--text); border-color: rgba(127,201,188,.5); }
.msg.error { background: rgba(224,107,90,.14); color: var(--text); border-color: rgba(224,107,90,.55); }
.note { background: rgba(201,138,67,.12); border: 1px solid rgba(201,138,67,.4); color: var(--text);
  padding: .5rem .7rem; border-radius: 10px; font-size: .92rem; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); font-size: .93rem; }
th { color: var(--muted); font-weight: 600; }
tbody tr:hover { background: rgba(201,138,67,.07); }
td.num, th.num { text-align: right; }

/* ---------- Badges / tags ---------- */
.tag { font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; background: rgba(201,138,67,.18);
  color: var(--accent-lite); font-weight: 600; }
.badge { font-size: .7rem; padding: .12rem .5rem; border-radius: 999px; font-weight: 700; }
.badge.ok   { background: rgba(127,201,188,.2); color: var(--celeste); }
.badge.warn { background: rgba(224,107,90,.18); color: var(--danger); }
.badge.mut  { background: rgba(185,164,136,.2); color: var(--muted); }

/* ---------- Stat row ---------- */
.stats { display: flex; gap: 1.6rem; flex-wrap: wrap; }
.stat .n { font-size: 1.7rem; font-weight: 700; color: var(--text); font-family: "Fraunces", serif; }
.stat .n .u { font-size: .95rem; font-weight: 600; color: var(--muted); }
.stat .l { color: var(--muted); font-size: .82rem; }

/* ---------- Heatmap (Röst-Rampe: km/Tag) ---------- */
.heatmap { display: flex; gap: .5rem; align-items: flex-start; overflow-x: auto; padding-bottom: .3rem; }
.hm-daylabels { display: grid; grid-template-rows: repeat(7, 14px); gap: 3px; margin-top: 1.15rem; }
.hm-daylabels span { font-size: .62rem; color: var(--muted); height: 14px; line-height: 14px; }
.hm-body { display: flex; flex-direction: column; }
.hm-months { display: flex; gap: 3px; height: 1rem; }
.hm-month { width: 14px; font-size: .62rem; color: var(--muted); white-space: nowrap; }
.hm-weeks { display: flex; gap: 3px; }
.hm-week { display: grid; grid-template-rows: repeat(7, 14px); gap: 3px; }
.hm-months .gap, .hm-weeks .gap { margin-left: 10px; }
.hm-cell { width: 14px; height: 14px; border-radius: 3px; background: var(--hm-empty); }
.hm-1 { background: #E3B87A; } .hm-2 { background: #C98A43; }
.hm-3 { background: #9A6430; } .hm-4 { background: #5E3A1E; }
.hm-future { background: transparent; }
.hm-legend { display: flex; align-items: center; gap: .35rem; font-size: .72rem; color: var(--muted); margin-top: .5rem; }
.hm-legend .hm-cell { width: 12px; height: 12px; }

/* ---------- Auth (Login/Register) ---------- */
.auth { max-width: 23rem; margin: 3.5rem auto; padding: 0 1.1rem; width: 100%; }
.auth .card { padding: 1.4rem 1.5rem; }
.auth h1 { font-size: 1.5rem; }
.auth .brand-row { text-align: center; margin-bottom: 1rem; font-family: "Fraunces", serif;
  font-weight: 700; font-size: 1.7rem; color: var(--accent); display: flex; align-items: center;
  justify-content: center; gap: .5rem; }
.auth button { width: 100%; margin-top: 1.2rem; }

/* Externe Anmeldung (Google/GitHub): neutrale Provider-Buttons + „oder"-Trenner */
.btn-oauth { display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; padding: .7rem 1rem; border-radius: 10px; text-decoration: none;
  font-weight: 600; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.btn-oauth:hover { border-color: var(--accent); }
.btn-oauth .g-mark { display: inline-flex; align-items: center; justify-content: center;
  width: 1.4rem; height: 1.4rem; border-radius: 50%; background: #fff; color: #4285F4;
  font-family: "Fraunces", serif; font-weight: 700; line-height: 1; border: 1px solid #dadce0; }
.btn-oauth .gh-mark { display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); }
.or-divider { display: flex; align-items: center; gap: .7rem; margin: 1.1rem 0 .2rem;
  color: var(--muted); font-size: .82rem; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Simple row list ---------- */
.rows { list-style: none; padding: 0; margin: .3rem 0 0; }
.rows li { display: flex; justify-content: space-between; align-items: center;
  padding: .55rem .2rem; border-bottom: 1px solid var(--border); gap: 1rem; }
.rows li:last-child { border-bottom: none; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
