/* SandyGym - Helles Theme in Markenfarben, mobil zuerst */
:root {
  --bg: #F7F8FA;
  --bg2: #FFFFFF;
  --bg3: #EEF1F4;
  --line: #D9DEE5;
  --text: #1F2933;
  --mut: #667085;
  --acc: #0F766E;
  --acc-dark: #0B5A54;
  --mint: #8FE3CF;
  --ok: #22A06B;
  --warn: #E6A23C;
  --red: #D64545;
  --blue: #0F766E;
  --radius: 14px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; height: 100%; overscroll-behavior-y: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }
#main { flex: 1; padding: calc(var(--sat) + 12px) 14px calc(140px + var(--sab)); max-width: 640px; width: 100%; margin: 0 auto; }

h1 { font-size: 24px; margin: 6px 0 14px; }
h2 { font-size: 18px; margin: 18px 0 10px; }
h3 { font-size: 15px; margin: 12px 0 8px; color: var(--mut); font-weight: 600; }
p { line-height: 1.45; }
a { color: var(--acc); text-decoration: none; }
.mut { color: var(--mut); }
.small { font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

/* Karten und Listen */
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--bg3); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; min-height: 56px; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.list-item:active { background: var(--bg3); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--bg3); color: var(--text);
  border-radius: var(--radius); padding: 0 18px; height: 50px; font-size: 16px; font-weight: 600;
  cursor: pointer; width: 100%; }
.btn:active { opacity: .8; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #FFFFFF; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { height: 40px; font-size: 14px; width: auto; padding: 0 14px; }
.btn.big { height: 62px; font-size: 19px; }
.btn:disabled { opacity: .45; }

/* Formulare */
label.fld { display: block; margin-bottom: 12px; }
label.fld span { display: block; font-size: 13px; color: var(--mut); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 13px 12px; font-size: 16px; height: 50px; appearance: none; }
textarea { height: auto; min-height: 84px; resize: vertical; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--mut) 50%), linear-gradient(135deg, var(--mut) 50%, transparent 50%);
  background-position: calc(100% - 18px) 22px, calc(100% - 13px) 22px; background-size: 5px 5px; background-repeat: no-repeat; }

/* Chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--bg2); color: var(--text); border-radius: 999px;
  padding: 9px 14px; font-size: 14px; white-space: nowrap; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; }
.chip.on { background: var(--acc); border-color: var(--acc); color: #FFFFFF; font-weight: 600; }
.chip.done { border-color: var(--acc-dark); color: var(--acc); }

/* Tabbar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; z-index: 40;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: var(--sab); }
.tabbar button { flex: 1; background: none; border: none; color: var(--mut); padding: 10px 0 8px;
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--acc); }

/* Restbar (Pausentimer) */
.restbar { position: fixed; left: 10px; right: 10px; bottom: calc(64px + var(--sab)); z-index: 45;
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(16,24,40,.16); }
.restbar .time { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 84px; }
.restbar.over .time { color: var(--acc); }

/* Sheet (Bottom Sheet) */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--bg2);
  border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); padding: 10px 16px calc(18px + var(--sab));
  max-height: 88dvh; overflow-y: auto; animation: up .18s ease-out; max-width: 640px; margin: 0 auto; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 2px auto 12px; }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(78px + var(--sab)); z-index: 60;
  background: var(--bg3); border: 1px solid var(--line); color: var(--text); padding: 12px 18px;
  border-radius: 999px; font-size: 15px; box-shadow: 0 6px 24px rgba(0,0,0,.5); max-width: 90vw; text-align: center; }
.toast.pr { border-color: var(--ok); color: var(--ok); font-weight: 600; }

/* Workout: Satz-Editor */
.ex-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.ex-strip::-webkit-scrollbar { display: none; }
.ex-pill { border: 1px solid var(--line); border-radius: 999px; background: var(--bg2); color: var(--mut);
  padding: 8px 13px; font-size: 13px; white-space: nowrap; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.ex-pill.on { border-color: var(--acc); color: var(--text); background: var(--bg3); }
.ex-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.ex-pill.full .dot { background: var(--acc); }
.ss-badge { font-size: 11px; font-weight: 700; background: var(--mint); color: var(--acc-dark); border-radius: 6px; padding: 2px 6px; }

.setrow { display: flex; align-items: center; gap: 8px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 15px; }
.setrow:last-child { border-bottom: none; }
.setrow .n { width: 26px; height: 26px; border-radius: 50%; background: var(--bg3); display: inline-flex;
  align-items: center; justify-content: center; font-size: 13px; color: var(--mut); flex: none; }
.setrow.done .n { background: var(--acc); color: #FFFFFF; font-weight: 700; }
.setrow.cur { background: var(--bg3); border-radius: 10px; }
.setrow .vals { flex: 1; font-variant-numeric: tabular-nums; }
.setrow .type { font-size: 11px; color: var(--warn); }

.bigval { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 4px 0 2px; }
.bigval .v { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.bigval .u { color: var(--mut); font-size: 16px; }
.quickrow { display: flex; gap: 6px; justify-content: center; margin: 6px 0 2px; }
.qbtn { flex: 1; max-width: 84px; height: 52px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg3); color: var(--text); font-size: 15px; font-weight: 700; cursor: pointer; }
.qbtn:active { background: var(--acc-dark); }
.qbtn.minus { color: var(--red); }
.qbtn.plus { color: var(--acc); }
.step-lbl { text-align: center; color: var(--mut); font-size: 12px; margin-top: 2px; }

.rir-row { display: flex; gap: 6px; margin: 10px 0; }
.rir-row .chip { flex: 1; justify-content: center; padding: 0; height: 46px; font-weight: 700; }

.prevline { background: var(--bg3); border-radius: 10px; padding: 9px 12px; font-size: 13px; color: var(--mut);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.prevline b { color: var(--text); font-weight: 600; }
.hint { border-left: 3px solid var(--warn); background: var(--bg3); border-radius: 8px; padding: 9px 12px;
  font-size: 13px; margin-bottom: 10px; }
.hint.ok { border-color: var(--acc); }

/* Kalender */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 10px 0; }
.cal .dow { text-align: center; font-size: 11px; color: var(--mut); padding: 4px 0; }
.cal .day { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 14px; color: var(--text); position: relative; cursor: default; }
.cal .day.out { color: var(--line); }
.cal .day.today { border: 1px solid var(--acc); }
.cal .day.has { background: var(--bg3); cursor: pointer; }
.cal .day.has::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--acc); position: absolute; bottom: 5px; }

/* Diff-Anzeige */
.diff-up { color: var(--acc); }
.diff-down { color: var(--red); }
.diff-eq { color: var(--mut); }

/* Statistik-Kacheln */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 8px; text-align: center; }
.stat .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--mut); margin-top: 2px; }

/* Auth-Seiten (login/register/reset) */
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-card .logo-mark, .auth-box .logo-mark { display: block; margin: 0 auto 12px; width: min(250px, 74%); height: auto; }
.auth-box .logo { text-align: center; font-size: 30px; font-weight: 800; margin-bottom: 4px; letter-spacing: -.5px; }
.auth-box .logo span { color: var(--acc); }
.auth-box .sub { text-align: center; color: var(--mut); margin-bottom: 26px; font-size: 14px; }
.auth-box .tagline { text-align: center; color: var(--mut); font-size: 12px; letter-spacing: .22em; margin: 0 0 22px; }
.auth-box .err { background: rgba(214,69,69,.08); border: 1px solid var(--red); color: var(--red);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.auth-box .ok { background: rgba(34,160,107,.08); border: 1px solid var(--ok); color: var(--ok);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.auth-links { margin-top: 18px; text-align: center; font-size: 14px; display: flex; flex-direction: column; gap: 10px; }
.auth-note { margin-top: 20px; color: var(--mut); font-size: 12px; line-height: 1.5; }

@media (min-width: 700px) {
  .restbar { max-width: 620px; left: 50%; transform: translateX(-50%); }
}

/* Drag and Drop im Vorlagen-Editor */
.drag-handle { display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 34px; border-radius: 8px; color: var(--mut);
  border: 1px solid var(--line); background: var(--bg2);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; font-size: 15px; }
.drag-ghost { position: fixed; z-index: 300; pointer-events: none; opacity: .92;
  box-shadow: 0 12px 28px rgba(16,24,40,.22); transform: scale(1.02); }
.drag-placeholder { opacity: .35; border-style: dashed; }

/* Logo oben rechts, auf allen Seiten ausser im laufenden Training */
#brandmark { position: fixed; top: calc(var(--sat) + 16px); right: 14px; height: 24px; width: auto;
  z-index: 30; pointer-events: none; }
body.in-workout #brandmark { display: none; }
