/* Flow – ruhiges, dunkles Design; Farbe kommt nur von den Zielen. */

:root {
  --bg: #0e0e0f;
  --bg-2: #141416;
  --card: #18181a;
  --card-2: #212124;
  --line: #2a2a2e;
  --line-2: #3a3a40;
  --text: #ededee;
  --text-2: #b4b4b9;
  --muted: #84848b;
  --muted-2: #5a5a61;
  --accent: #e3b25c;
  --accent-ink: #1c1407;
  --danger: #e06c6c;
  --radius: 14px;
  --tab-h: 62px;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f6f5f2;
  --bg-2: #efeee9;
  --card: #ffffff;
  --card-2: #f0efea;
  --line: #e3e1da;
  --line-2: #cfccc3;
  --text: #1b1b1d;
  --text-2: #45454a;
  --muted: #76767d;
  --muted-2: #a8a8ae;
  --accent: #c48a1e;
  --accent-ink: #ffffff;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root[data-theme='system'] {
    --bg: #f6f5f2;
    --bg-2: #efeee9;
    --card: #ffffff;
    --card-2: #f0efea;
    --line: #e3e1da;
    --line-2: #cfccc3;
    --text: #1b1b1d;
    --text-2: #45454a;
    --muted: #76767d;
    --muted-2: #a8a8ae;
    --accent: #c48a1e;
    --accent-ink: #ffffff;
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100dvh; padding-top: env(safe-area-inset-top); }
body.sheet-open { overflow: hidden; }
body.dragging { -webkit-user-select: none; user-select: none; }

#view {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px);
}

a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button:disabled { opacity: 0.4; cursor: default; }
svg { width: 20px; height: 20px; flex: none; }

input, textarea, select {
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf dem iPhone */
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
input:focus, textarea:focus, select:focus { border-color: var(--line-2); }
textarea { resize: vertical; line-height: 1.45; }
input[type='date'], input[type='time'] { min-height: 44px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.lead { margin: -6px 0 16px; font-size: 15px; }
.warn { color: var(--accent); font-size: 14px; }
.error { color: var(--danger); padding: 20px; }

/* ---------- Kopf ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 6px 0 16px; }
.eyebrow { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
h1 { font-size: 27px; font-weight: 600; letter-spacing: -0.02em; margin: 3px 0 0; line-height: 1.15; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; color: var(--text-2);
}
.icon-btn:active { background: var(--card-2); }

/* ---------- Navigation unten ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
#tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 0; font-size: 11px; color: var(--muted); text-decoration: none;
}
#tabbar a svg { width: 23px; height: 23px; }
#tabbar a.active { color: var(--text); }
#tabbar a.active svg { color: var(--accent); }
body[data-route='fokus'] #tabbar { display: none; }
body[data-route='fokus'] #view { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }

/* ---------- Heute: Kennzahlen ---------- */
.today-stats { display: flex; align-items: center; gap: 16px; margin: -4px 0 16px; }
.today-stats .big { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.today-stats .big small { font-size: 14px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.week-meter { flex: 1; min-width: 0; }
.meter { height: 5px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s; }
.week-meter .lbl { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Umschalter ---------- */
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 8px; border-radius: 9px; font-size: 14px; color: var(--muted); text-align: center; }
.seg button.on { background: var(--card-2); color: var(--text); }
.seg.small { margin: 0; display: inline-flex; }
.seg.small button { padding: 6px 14px; font-size: 13px; }

/* ---------- Schnellerfassung ---------- */
.add { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 6px 8px 8px; margin-bottom: 14px; background: var(--bg-2); }
.add-row { display: flex; align-items: center; gap: 6px; }
.add input[name='title'] { border: 0; background: transparent; padding: 9px 6px; }
.add-btn { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.add-opts { display: flex; gap: 6px; align-items: center; }
.add-opts select { flex: 1; min-width: 0; width: auto; padding: 7px 26px 7px 10px; background-color: var(--card); }
.pos { display: flex; flex: none; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pos button { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); }
.pos button svg { width: 17px; height: 17px; }
.pos button.on { background: var(--card-2); color: var(--text); }

.hint {
  display: block; width: 100%; text-decoration: none; font-size: 14px; color: var(--text-2);
  background: color-mix(in srgb, var(--accent) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
}
.hint b { color: var(--text); }

/* ---------- Aufgabenkarte ---------- */
.task {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px 8px 9px 16px; margin-bottom: 8px;
}
.task::before {
  content: ''; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--c);
}
.task.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent), 0 10px 30px -14px color-mix(in srgb, var(--accent) 45%, transparent);
}
.task-title { display: block; width: 100%; font-size: 16px; line-height: 1.3; margin: 0 0 8px; padding-right: 8px; word-break: break-word; }
.task-meta { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.task-meta .spacer { flex: 1; }
.check {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--line-2); display: grid; place-items: center; color: transparent;
}
.check svg { width: 15px; height: 15px; stroke-width: 2.4; }
.check:active { border-color: var(--c); }
.task.done { opacity: 0.55; }
.task.done .check { background: var(--c); border-color: var(--c); color: #fff; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task.pop .check { animation: pop 0.4s ease-out; }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

.pill {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 170px;
  font-size: 13px; color: var(--text-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pill.big { font-size: 15px; padding: 6px 14px; border-color: color-mix(in srgb, var(--c) 45%, var(--line)); max-width: 90%; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; display: inline-block; }

.time { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.time.live { color: var(--text); }
.time.live::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); margin: 0 6px 2px 0; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.play { width: 34px; height: 34px; color: var(--text-2); }
.play svg { width: 17px; height: 17px; }

.drag-handle {
  width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted-2);
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: grab;
}
.task.ghost { position: fixed; z-index: 50; margin: 0; pointer-events: none; transform: scale(1.02); box-shadow: 0 18px 40px -10px rgba(0, 0, 0, 0.55); opacity: 0.96; }
.placeholder { border: 1.5px dashed var(--line-2); border-radius: var(--radius); margin-bottom: 8px; }
.dnd-list { min-height: 8px; }

.empty { color: var(--muted); font-size: 14px; padding: 16px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.empty.slim { padding: 8px; font-size: 13px; color: var(--muted-2); }

.section-h {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  margin: 20px 2px 8px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}
.section-h.toggle { padding: 4px 0; }
.chev { display: grid; transition: transform 0.2s; }
.chev svg { width: 18px; height: 18px; }
.chev.open { transform: rotate(180deg); }

/* ---------- Logbuch ---------- */
.log-sum { font-size: 13px; color: var(--muted); margin: 0 2px 10px; }
.timeline { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); overflow: hidden; }
.tl-inner { position: absolute; inset: 8px 0; }
.tl-hour { position: absolute; left: 52px; right: 0; border-top: 1px solid var(--line); }
.tl-hour span { position: absolute; left: -46px; top: -8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-block {
  position: absolute; left: 58px; right: 8px; overflow: hidden;
  border-radius: 8px; padding: 3px 8px; font-size: 13px; line-height: 1.25; color: var(--text);
  border-left: 3px solid var(--c);
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 26%, transparent) 0 6px, color-mix(in srgb, var(--c) 13%, transparent) 6px 12px);
}
.tl-block .tl-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-block small { color: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.tl-block.live { outline: 1px dashed var(--c); outline-offset: -1px; }
.tl-now { position: absolute; left: 52px; right: 0; height: 2px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.tl-now::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---------- Woche ---------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin: -6px 0 14px; }
.chip { padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; color: var(--text-2); }
.chip.on { color: var(--text); border-color: var(--line-2); background: var(--card); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.day { margin-bottom: 18px; }
.day-h { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 8px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.day-h b { font-weight: 600; }
.day-h .num { color: var(--muted); font-size: 14px; }
.day-h .hrs { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.day.today .day-h { border-bottom: 2px solid var(--accent); }
.day.today .day-h .num { color: var(--accent); }
.day.past { opacity: 0.6; }
.day.inbox .day-h b { color: var(--text-2); }
.done-list .task { margin-bottom: 6px; }

/* ---------- Fokus ---------- */
.focus { min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 30px); display: flex; flex-direction: column; }
.focus-top { display: flex; align-items: center; justify-content: space-between; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.focus-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 16px; padding: 20px 0; }
.focus-title { font-size: 24px; font-weight: 500; line-height: 1.25; max-width: 24ch; text-align: center; }
.clock { font-size: min(25vw, 132px); font-weight: 600; letter-spacing: -0.045em; line-height: 1; font-variant-numeric: tabular-nums; margin-top: 6px; }
.focus.break .clock { color: var(--accent); }
.clock-status { font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.focus.running .clock-status { color: var(--text-2); }
.rounds { display: flex; gap: 7px; }
.rounds i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.rounds i.on { background: var(--accent); }
.focus-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.focus-sub { min-height: 40px; display: flex; gap: 6px; justify-content: center; }
.big-check { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.big-check svg { width: 30px; height: 30px; stroke-width: 2.2; }
.notes { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 8px; font-size: 15px; color: var(--text-2); }
.notes summary { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.notes-body p { margin: 6px 0 0; }
.notes-body ul { margin: 6px 0 0; padding-left: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 132px; padding: 13px 20px; border-radius: 14px; text-align: center;
  border: 1px solid var(--line-2); background: var(--card); font-size: 17px; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.ghost { min-width: 0; border: 0; background: none; color: var(--muted); font-size: 15px; padding: 8px 12px; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; margin: 4px 0 8px; }

/* ---------- Ziele ---------- */
.quest {
  display: flex; gap: 14px; align-items: center; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.quest.archived { opacity: 0.55; }
.swatch { width: 10px; align-self: stretch; min-height: 42px; border-radius: 6px; background: var(--c); flex: none; }
.quest-body { flex: 1; min-width: 0; display: block; }
.quest-title { display: block; font-size: 17px; font-weight: 500; }
.quest-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.progress { display: block; height: 6px; background: var(--card-2); border-radius: 99px; overflow: hidden; margin-top: 9px; }
.progress span { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.colors { display: flex; flex-wrap: wrap; gap: 10px; }
.colors button { width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 2px solid transparent; box-shadow: inset 0 0 0 3px var(--bg-2); }
.colors button.on { border-color: var(--text); }

/* ---------- Rückblick ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.tile, .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card { margin-bottom: 10px; }
.tile.wide { grid-column: 1 / -1; }
.label { display: block; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.val { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.val small { font-size: 15px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.val.accent { color: var(--accent); }
.tile .meter { margin-top: 8px; }
.sub { font-size: 13px; color: var(--muted); margin-top: 6px; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; margin-top: 18px; }
.bars .col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; }
.bars .bar { width: 100%; max-width: 32px; min-height: 3px; background: var(--line-2); border-radius: 6px 6px 3px 3px; }
.bars .col.today .bar { background: var(--accent); }
.bars .col.future .bar { background: var(--line); }
.bars .v { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; min-height: 14px; }
.bars .col.today .v { color: var(--accent); }
.bar-labels { display: flex; gap: 8px; margin-top: 6px; }
.bar-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.bar-labels span.today { color: var(--accent); }

.qrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 10px; margin-top: 14px; font-size: 15px; }
.qname { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qbar { grid-column: 1 / -1; grid-row: 2; position: relative; height: 7px; background: var(--card-2); border-radius: 99px; }
.qbar > span { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.qbar .tick { position: absolute; top: -3px; width: 2px; height: 13px; background: var(--text-2); border-radius: 1px; margin-left: -1px; }
.qval { font-variant-numeric: tabular-nums; text-align: right; min-width: 52px; }
.qval small { color: var(--muted); }

.split { height: 26px; border-radius: 8px; overflow: hidden; background: var(--card-2); margin-top: 12px; }
.split span { display: block; height: 100%; background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { margin-left: auto; }
.card textarea { margin-top: 10px; background: var(--bg-2); }

/* ---------- Blatt (Sheet) ---------- */
#sheet-root { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#sheet-root.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); animation: fade 0.2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  max-height: 90dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
  animation: up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 8px; background: var(--bg-2); }
.sheet h2 { font-size: 18px; font-weight: 600; margin: 0; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.sheet-actions { display: flex; gap: 10px; margin-top: 10px; }
.sheet-actions .btn { flex: 1; min-width: 0; }
.switch { display: flex; align-items: center; gap: 10px; margin: 4px 0; font-size: 15px; }
.switch input { width: 22px; height: 22px; padding: 0; accent-color: var(--accent); -webkit-appearance: auto; appearance: auto; }
.version { margin-top: 18px; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; z-index: 60; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: 0.25s;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; white-space: nowrap;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
}
#toast > span { overflow: hidden; text-overflow: ellipsis; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.show.has-undo { pointer-events: auto; padding: 4px 6px 4px 16px; }
#toast button {
  flex: none; font: inherit; font-weight: 600; color: var(--accent-ink, var(--bg)); background: transparent;
  border: 0; padding: 8px 10px; margin: 0; border-radius: 8px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
#toast button:active { background: rgba(127, 127, 127, 0.2); }
body[data-route='fokus'] #toast { bottom: calc(env(safe-area-inset-bottom) + 24px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
