/* Anspannungs-Tagebuch – gemeinsame Grundlagen, helles Design */
:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1e2330;
  --ink-2: #4f5563;
  --muted: #6b7080;          /* ≥ 4.5:1 auf Weiß */
  --line: #e7e4dc;
  --line-2: #d6d2c8;
  --accent: #4a52c9;
  --accent-soft: #eceefc;
  --accent-ink: #343bb0;
  --danger: #b3362b;

  --z-low: #5f7fa8;  --z-low-bg: #e9eff7;  --z-low-ink: #3d5a80;
  --z-mid: #2f9a68;  --z-mid-bg: #e2f3ea;  --z-mid-ink: #1f6e4a;
  --z-high: #d9622b; --z-high-bg: #fbe9df; --z-high-ink: #a6461a;

  /* Typo-Skala: 13 / 15 / 16 / 18 / 26 px – Gewichte 400 / 600 / 700 */
  --fs-s: .8125rem; --fs-m: .9375rem; --fs-l: 1.125rem; --fs-xl: 1.625rem;

  --radius: 16px;
  --radius-sm: 10px;
  --card-pad: 20px;
  --tabbar-h: 0px;
  --shadow: 0 1px 2px rgba(30, 35, 48, .04), 0 4px 16px rgba(30, 35, 48, .05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.5; font-size: 16px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; font-weight: 700; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-l); }
h3 { font-size: 1rem; }
a { color: var(--accent-ink); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-s); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* ---------- Icons ---------- */
.ic { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.ic svg { width: 100%; height: 100%; }

/* ---------- Navigation: oben (Desktop) ---------- */
.topnav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(var(--z-low) 0 30%, var(--z-mid) 30% 70%, var(--z-high) 70% 100%); }
.topnav-links { display: flex; gap: 4px; margin-left: auto; }
.topnav-links a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-size: var(--fs-m); font-weight: 600; }
.topnav-links a:hover { background: var(--surface-2); color: var(--ink); }
.topnav-links a.active { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Navigation: Tab-Leiste unten (Mobile) ---------- */
.tabbar { display: none; }
@media (max-width: 720px) {
  :root { --tabbar-h: calc(56px + env(safe-area-inset-bottom)); --card-pad: 16px; }
  .topnav { display: none; }
  body { padding-bottom: var(--tabbar-h); }
  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
  .tabbar a .ic { width: 24px; height: 24px; }
  .tabbar a.active { color: var(--accent); }
}

/* ---------- Layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }
.wrap.narrow { max-width: 680px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--card-pad); }
.stack > * + * { margin-top: 16px; }
.pagehead { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.pagehead h1 { margin: 0; }
.pagehead .actions { margin-left: auto; display: flex; gap: 8px; }
.foot-links { text-align: center; color: var(--muted); font-size: var(--fs-s); margin-top: 28px; }
.foot-links a { color: var(--ink-2); }
@media (max-width: 720px) { .wrap { padding: 18px 14px 40px; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  padding: 10px 16px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: var(--fs-m);
  text-decoration: none; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: rgba(0,0,0,.04); }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 50px; padding: 12px 22px; font-size: 1.0625rem; }
.btn.icon { padding: 10px; width: 44px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.saved:disabled { opacity: 1; background: var(--z-mid-bg); border-color: transparent; color: var(--z-mid-ink); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: var(--fs-s); }
.linkbtn:hover { color: var(--ink-2); }
.chipbtn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: var(--fs-s); font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 32px; }

/* Segment-Umschalter */
.segmented { display: flex; background: #efede7; border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { flex: 1; border: 0; background: transparent; padding: 8px 6px; min-height: 38px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: var(--fs-m); color: var(--ink-2); white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- Formularfelder ---------- */
.lbl { display: block; font-weight: 600; font-size: var(--fs-m); margin-bottom: 8px; }
input[type="text"], input[type="date"], textarea, select {
  width: 100%; border: 1px solid var(--line-2); background: var(--surface);
  border-radius: var(--radius-sm); padding: 11px 12px; font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.45; }
::placeholder { color: #9a9ea8; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Anspannungs-Regler ---------- */
.tension { --thumb: 28px; }
.tension-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; min-height: 44px; }
.tension-value { font-size: 2.25rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2ch; line-height: 1; }
.tension[data-zone="none"] .tension-value { color: #b9bcc4; font-weight: 600; }
.zone-badge { font-size: var(--fs-s); font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tension-clear { margin-left: auto; }
.tension[data-zone="low"] .tension-value { color: var(--z-low-ink); }
.tension[data-zone="mid"] .tension-value { color: var(--z-mid-ink); }
.tension[data-zone="high"] .tension-value { color: var(--z-high-ink); }
.tension[data-zone="low"] .zone-badge { background: var(--z-low-bg); color: var(--z-low-ink); border-color: transparent; }
.tension[data-zone="mid"] .zone-badge { background: var(--z-mid-bg); color: var(--z-mid-ink); border-color: transparent; }
.tension[data-zone="high"] .zone-badge { background: var(--z-high-bg); color: var(--z-high-ink); border-color: transparent; }
.tension input[type="range"] {
  -webkit-appearance: none; appearance: none; display: block;
  width: 100%; height: 16px; border-radius: 999px; margin: 14px 0 8px;
  background: linear-gradient(to right, var(--z-low-bg) 0 30%, var(--z-mid-bg) 30% 70%, var(--z-high-bg) 70% 100%);
  box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; touch-action: pan-y;
}
.tension input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: var(--thumb); height: var(--thumb); border-radius: 50%;
  background: #fff; border: 3px solid var(--ink-2); box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
.tension input[type="range"]::-moz-range-thumb { width: var(--thumb); height: var(--thumb); border-radius: 50%; background: #fff; border: 3px solid var(--ink-2); box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }
.tension[data-zone="low"] input[type="range"]::-webkit-slider-thumb { border-color: var(--z-low); }
.tension[data-zone="mid"] input[type="range"]::-webkit-slider-thumb { border-color: var(--z-mid); }
.tension[data-zone="high"] input[type="range"]::-webkit-slider-thumb { border-color: var(--z-high); }
.tension[data-zone="low"] input[type="range"]::-moz-range-thumb { border-color: var(--z-low); }
.tension[data-zone="mid"] input[type="range"]::-moz-range-thumb { border-color: var(--z-mid); }
.tension[data-zone="high"] input[type="range"]::-moz-range-thumb { border-color: var(--z-high); }
.tension input[type="range"].unset::-webkit-slider-thumb { opacity: 0; }
.tension input[type="range"].unset::-moz-range-thumb { opacity: 0; }
.tension-scale { display: grid; grid-template-columns: 30fr 40fr 30fr; font-size: var(--fs-s); color: var(--muted); }
.tension-scale span { white-space: nowrap; }
.tension-scale span:nth-child(2) { text-align: center; }
.tension-scale span:nth-child(3) { text-align: right; }
.tension-scale b { font-weight: 600; }
.tension-scale .z-low b { color: var(--z-low-ink); }
.tension-scale .z-mid b { color: var(--z-mid-ink); }
.tension-scale .z-high b { color: var(--z-high-ink); }
@media (max-width: 720px) { .tension-scale .rng { display: none; } }
.tension.big { --thumb: 38px; }
.tension.big .tension-value { font-size: 4.5rem; }
.tension.big input[type="range"] { height: 22px; }
.tension.big .zone-badge { font-size: 1rem; padding: 5px 14px; }

/* ---------- Gefühls-Tags ---------- */
.tag-field { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 6px 8px; background: var(--surface); cursor: text; min-height: 48px; }
.tag-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag-chips { display: contents; }
.tag-text { flex: 1; min-width: 140px; border: 0 !important; box-shadow: none !important; padding: 6px 4px !important; background: transparent !important; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 2px; min-height: 36px; padding: 4px 4px 4px 12px; border-radius: 999px; font-size: var(--fs-m); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; width: 30px; height: 30px; border-radius: 50%; line-height: 1; font-size: 1.15rem; }
.chip button:hover { background: rgba(74, 82, 201, .14); }
.chip-suggest, .chip-new, .chip-more { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); padding: 4px 13px; font-weight: 500; cursor: pointer; }
.chip-suggest:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.chip-new { border-color: var(--accent); color: var(--accent-ink); }
.chip-more { border-color: transparent; background: transparent; color: var(--accent-ink); font-weight: 600; }

/* ---------- Zonen-Pille ---------- */
.zpill { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-s); font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.zpill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.zpill.low { background: var(--z-low-bg); color: var(--z-low-ink); }
.zpill.mid { background: var(--z-mid-bg); color: var(--z-mid-ink); }
.zpill.high { background: var(--z-high-bg); color: var(--z-high-ink); }
.znum { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 30px; padding: 0 8px; border-radius: 9px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface-2); color: #b9bcc4; }
.znum.low { background: var(--z-low-bg); color: var(--z-low-ink); }
.znum.mid { background: var(--z-mid-bg); color: var(--z-mid-ink); }
.znum.high { background: var(--z-high-bg); color: var(--z-high-ink); }
.znum.any { color: var(--ink-2); }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 84px); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Dialog / Bottom-Sheet ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(30, 35, 48, .32); display: flex; align-items: center; justify-content: center; padding: 16px; animation: mfade .15s ease; }
@keyframes mfade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25); width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px 22px 22px; }
.modal-grip { display: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.modal-head h2 { margin: 0; font-size: var(--fs-l); }
.modal-x { border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; font-size: 1.25rem; line-height: 1; cursor: pointer; color: var(--ink-2); }
.modal p { color: var(--ink-2); }
.modal-actions { display: flex; flex-direction: row-reverse; gap: 10px; justify-content: flex-start; flex-wrap: wrap; margin-top: 16px; }
@media (max-width: 720px) {
  .modal-back { align-items: flex-end; padding: 0; }
  .modal { width: 100%; border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); animation: msheet .22s ease; max-height: 92vh; }
  @keyframes msheet { from { transform: translateY(40px); opacity: .6; } }
  .modal-grip { display: block; width: 40px; height: 5px; border-radius: 9px; background: var(--line-2); margin: 0 auto 12px; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; }
}

/* Teilen */
.share-range { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0 12px; }
.share-range button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 6px; min-height: 52px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 12px; cursor: pointer; font-weight: 600; font-size: var(--fs-m); color: var(--ink-2); }
.share-range button small { font-weight: 400; color: var(--muted); font-size: var(--fs-s); }
.share-range button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
@media (max-width: 720px) { .share-range { grid-template-columns: repeat(2, 1fr); } }
.share-summary { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); min-height: 48px; align-items: center; }
.share-summary span { color: var(--ink-2); }
.share-warn { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: #fff7ed; color: #7a3d12 !important; font-size: var(--fs-m); }
.share-warn .ic { margin-top: 2px; }
.share-details { margin-top: 14px; }
.share-details summary { cursor: pointer; color: var(--ink-2); font-size: var(--fs-s); }
.share-link { margin-top: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px !important; word-break: break-all; background: var(--surface-2); min-height: 0; }
@media print { .modal-back, .tabbar, #toast { display: none !important; } body { padding: 0 !important; } }
