:root {
  --bg: #141311;
  --card: #1d1c19;
  --card2: #24221e;
  --line: #2e2b26;
  --text: #ece8e1;
  --dim: #9d978c;
  --faint: #67625a;
  --accent: #e3a35f;
  --accent-ink: #1b140c;
  --ok: #93c28d;
  --warn: #e3a35f;
  --bad: #e07c6c;
  --r: 16px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom);
  --safe-t: env(safe-area-inset-top);
  --serif: "New York", ui-serif, "Iowan Old Style", Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%; outline: none; }
input:focus, textarea:focus { border-color: var(--faint); }
[hidden] { display: none !important; }

.app { max-width: 540px; margin: 0 auto; padding: calc(var(--safe-t) + 20px) 20px calc(var(--nav-h) + var(--safe-b) + 24px); }
.view { display: none; }
.view.on { display: block; }

h1 { font-family: var(--serif); font-size: 32px; line-height: 1.15; margin: 2px 0 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 6px; font-weight: 600; }
h2.section { font-family: inherit; font-size: 13px; color: var(--dim); font-weight: 600; margin: 28px 2px 10px; text-transform: uppercase; letter-spacing: .08em; }
.eyebrow { color: var(--dim); font-size: 14px; }
.muted { color: var(--dim); margin: 6px 0 12px; font-size: 15px; }
.tiny { font-size: 12px; margin-top: 8px; }
b { font-weight: 600; }

.hello, .page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--dim); }

/* Hauptknopf */
.hero { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; padding: 20px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); transition: transform .12s; }
.hero:active { transform: scale(.985); }
.hero-text { flex: 1; display: flex; flex-direction: column; }
.hero-title { font-family: var(--serif); font-size: 23px; font-weight: 600; }
.hero-sub { font-size: 14px; opacity: .75; margin-top: 2px; }
.hero-arrow { opacity: .7; }

/* Karten */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-top: 12px; }
.card.active { border-color: rgba(227,163,95,.45); }
.card.alert { background: transparent; border-color: rgba(224,124,108,.3); margin-top: 28px; }
.card.alert b { color: var(--bad); }
.card.alert p { margin: 4px 0 0; color: var(--dim); font-size: 14px; }
.card.warn { border-color: rgba(227,163,95,.4); color: #e8c9a3; font-size: 15px; }
.card-head { display: flex; align-items: center; gap: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.dot.live { animation: live 2s ease-in-out infinite; }
@keyframes live { 50% { opacity: .3; } }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat-tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 12px; }
.stat-tile .v { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.stat-tile .k { color: var(--dim); font-size: 12px; line-height: 1.3; margin-top: 2px; }

/* Knöpfe */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 18px; border-radius: 12px; font-weight: 600; font-size: 15px; transition: opacity .2s; }
.btn:active { opacity: .7; }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--card2); border: 1px solid var(--line); }
.btn.text { color: var(--dim); padding: 12px; }
.btn.small { padding: 8px 14px; font-size: 14px; background: var(--card2); border: 1px solid var(--line); }
.btn.wide { width: 100%; margin-top: 4px; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row > .btn:not(.text) { flex: 1; }
.btn-row.wrap { flex-wrap: wrap; }
.btn-row.wrap > .btn { flex: 1 1 auto; }

/* Checkliste */
.steps { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.step { display: flex; gap: 14px; align-items: center; padding: 14px 16px; text-align: left; width: 100%; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step .t { font-weight: 600; font-size: 15px; }
.step .d { color: var(--dim); font-size: 13px; line-height: 1.35; margin-top: 1px; }
.step .chk { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--faint); display: grid; place-items: center; }
.step.done .t { color: var(--dim); text-decoration: line-through; text-decoration-color: var(--faint); }
.step.done .chk { background: var(--ok); border-color: var(--ok); }
.step.done .chk::after { content: ""; width: 10px; height: 6px; border: solid var(--bg); border-width: 0 0 2px 2px; transform: rotate(-45deg) translate(1px, -1px); }
.step .when { color: var(--ok); font-size: 12px; }

/* Tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; padding: 6px 12px calc(6px + var(--safe-b)); background: var(--bg); border-top: 1px solid var(--line); }
.tabs button { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--faint); font-size: 11px; font-weight: 500; }
.tabs button.on { color: var(--accent); }

/* Chat */
#v-chat.on { display: flex; flex-direction: column; height: calc(100dvh - var(--nav-h) - var(--safe-b) - var(--safe-t) - 44px); }
.bar { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.bar-title b { font-family: var(--serif); font-size: 22px; }
.bar-title small { display: block; color: var(--dim); font-size: 13px; }
.chat { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 84%; padding: 10px 14px; border-radius: 18px; font-size: 16px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.ai { align-self: flex-start; background: var(--card2); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg.err { align-self: center; background: transparent; border: 1px solid rgba(224,124,108,.35); color: #e8b2a8; font-size: 14px; border-radius: 12px; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.empty-chat { margin: auto; text-align: center; color: var(--dim); padding: 20px 10px; }
.empty-chat b { font-family: var(--serif); font-size: 20px; color: var(--text); font-weight: 600; }
.proposal { align-self: stretch; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; padding: 14px; }
.proposal .ph { font-size: 12px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.proposal .big { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 2px 0 4px; }
.proposal.saved { opacity: .65; }
.quick { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 11px 16px; }
.send { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.send:disabled { opacity: .4; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; user-select: none; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); margin: 6px 5px 0 0; }
.pill.g { color: var(--ok); border-color: rgba(147,194,141,.3); }
label.l { display: block; color: var(--dim); font-size: 13px; font-weight: 600; margin: 18px 0 8px; }
.range { -webkit-appearance: none; appearance: none; height: 4px; padding: 0; border: 0; border-radius: 2px; background: var(--line); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); }
.range::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); border: 0; }
.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.scale button { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); font-weight: 600; font-size: 15px; color: var(--dim); }
.scale button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
details.more summary { color: var(--dim); font-size: 14px; margin-top: 18px; cursor: pointer; list-style: none; }
details.more summary::before { content: "+ "; }
details.more[open] summary::before { content: "– "; }

/* Tagebuch */
.day { color: var(--dim); font-size: 13px; font-weight: 600; margin: 22px 2px 8px; }
.entry { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.entry .lvl { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-family: var(--serif); font-weight: 600; font-size: 19px; border: 1px solid var(--line); }
.entry .body { flex: 1; min-width: 0; }
.entry .top { display: flex; justify-content: space-between; gap: 8px; }
.entry .note { color: var(--dim); font-size: 14px; margin-top: 4px; }
.entry .del { color: var(--faint); padding: 0 4px; font-size: 20px; line-height: 1; }
.empty { text-align: center; color: var(--dim); padding: 50px 20px; }

/* Analyse */
.bars { margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: 118px 1fr 44px; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.bar-row .track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 3px; background: var(--accent); }
.bar-row .fill.g { background: var(--ok); }
.bar-row .n { color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 12px; }
.cal div { aspect-ratio: 1; border-radius: 6px; background: var(--card2); }
.cal-legend { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; margin-top: 8px; }
.ai-out { margin: 4px 0 12px; font-size: 15px; }
.ai-out h3 { font-family: var(--serif); font-size: 17px; font-weight: 600; margin: 18px 0 4px; }
.ai-out h3:first-child { margin-top: 4px; }
.ai-out p { margin: 6px 0; }
.ai-out ul { margin: 6px 0; padding-left: 20px; }
.ai-out li { margin: 4px 0; }
.loading { color: var(--dim); font-size: 15px; }
.loading::after { content: "…"; animation: blink 1.2s infinite; }

/* Sheets */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 30; }
.sheet-bg.on { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-width: 540px; margin: 0 auto; max-height: 92dvh; overflow-y: auto; background: var(--card); border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; padding: 10px 20px calc(20px + var(--safe-b)); transform: translateY(105%); visibility: hidden; transition: transform .3s cubic-bezier(.2,.8,.2,1), visibility 0s .3s; }
.sheet.on { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--faint); margin: 0 auto 16px; }

.ring-wrap { position: relative; width: 180px; height: 180px; margin: 18px auto 10px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset 1s linear; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-time { font-family: var(--serif); font-size: 40px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ring-step { color: var(--dim); font-size: 13px; }
.ex-name { text-align: center; font-weight: 600; font-size: 18px; }
.ex-desc { text-align: center; color: var(--dim); font-size: 15px; min-height: 46px; margin-top: 4px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translate(-50%, 20px); opacity: 0; background: var(--card2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 40; transition: all .25s; pointer-events: none; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
