:root {
  --bg: #f6f7fb; --panel: #ffffff; --panel2: #f0f2f8; --line: #e2e5ee;
  --text: #1c2030; --muted: #6b7185; --accent: #4f6df5; --accent-weak: #e6eafe;
  --ok: #2f9e6e; --warn: #d9534f; --shadow: 0 1px 3px rgba(20,25,50,.08), 0 4px 14px rgba(20,25,50,.05);
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c; --panel: #1b1e29; --panel2: #232736; --line: #2e3344;
    --text: #e8eaf2; --muted: #9298ad; --accent: #7b91ff; --accent-weak: #262d52;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.fehler { background: #fde8e7; color: #9b1c17; padding: 8px 12px; border-radius: 8px; }

/* Anmeldung */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-box { background: var(--panel); padding: 28px; border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 360px; }
.auth-box form { display: grid; gap: 12px; margin-top: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.brand img { width: 30px; height: 30px; }

label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }

.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--warn); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-align: left; }
.link:hover { color: var(--text); text-decoration: underline; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 4px 6px; border-radius: 6px; font-size: 15px; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }

/* Aufbau */
.layout { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); background: var(--panel); }
.nav .brand { padding: 0 8px 16px; }
.nav-btn { display: flex; gap: 10px; align-items: center; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: left; font-size: 15px; color: var(--muted); }
.nav-btn:hover { background: var(--panel2); color: var(--text); }
.nav-btn.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.nav-foot { margin-top: auto; display: grid; gap: 8px; padding: 8px; }
.main { min-width: 0; padding: 26px 30px 110px; max-width: 1400px; width: 100%; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.head .sub { color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; }

/* Aufgaben */
.tasklist { display: grid; gap: 6px; min-height: 30px; }
.task { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); cursor: grab; }
.task:hover { border-color: var(--accent); }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task.dragging { opacity: .4; }
.task .t-main { flex: 1; min-width: 0; cursor: pointer; }
.task .t-title { overflow-wrap: anywhere; }
.task .t-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); background: none; cursor: pointer; flex: none; display: grid; place-items: center; color: #fff; font-size: 12px; padding: 0; }
.task.done .check { background: var(--ok); border-color: var(--ok); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.play { background: none; border: 1px solid var(--line); color: var(--accent); border-radius: 50%; width: 28px; height: 28px; cursor: pointer; flex: none; font-size: 11px; }
.play:hover { background: var(--accent); color: #fff; }
.task.running { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }
.addline { display: flex; gap: 8px; margin-top: 8px; }
.addline input { flex: 1; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; font-weight: 600; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }

/* Ziele */
.goal-card { border-left: 5px solid var(--c, var(--accent)); }
.goal-card .gname { font-weight: 600; font-size: 16px; }
.bar { height: 8px; background: var(--panel2); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--c, var(--accent)); border-radius: 6px; }
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.goal-mini { display: grid; gap: 3px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.goal-mini:last-child { border-bottom: 0; }
.goal-mini .row { justify-content: space-between; }

/* Woche */
.week { display: grid; grid-template-columns: 200px repeat(7, minmax(170px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.daycol { background: var(--panel2); border-radius: var(--radius); padding: 10px; min-height: 300px; display: flex; flex-direction: column; gap: 6px; }
.daycol.today { outline: 2px solid var(--accent); }
.daycol.over { background: var(--accent-weak); }
.daycol h3 { margin: 0; font-size: 14px; display: flex; justify-content: space-between; }
.daycol .dsum { font-size: 12px; color: var(--muted); font-weight: 400; }
.daycol .task { font-size: 13px; padding: 7px 8px; }
.daycol .add { margin-top: auto; }
.daycol .add input { padding: 6px 8px; font-size: 13px; background: transparent; border-style: dashed; }

/* Auswertung */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 200px; padding-top: 10px; }
.chart .col { display: flex; flex-direction: column-reverse; height: 100%; border-radius: 6px 6px 0 0; overflow: hidden; background: var(--panel2); }
.chart .seg { width: 100%; }
.chart-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list td, table.list th { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Fokus */
.focus { position: fixed; inset: 0; background: var(--bg); z-index: 50; display: grid; place-items: center; padding: 20px; }
.focus-inner { text-align: center; max-width: 640px; width: 100%; }
.focus .fgoal { color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.focus .ftitle { font-size: 30px; font-weight: 700; margin: 10px 0 24px; overflow-wrap: anywhere; }
.focus .clock { font-size: 76px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.focus .fnotes { color: var(--muted); white-space: pre-wrap; margin: 12px auto 0; max-width: 520px; }
.focus .row { justify-content: center; margin-top: 28px; }
.focus .hint { margin-top: 26px; font-size: 12px; color: var(--muted); }

.timerbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 40; background: var(--text); color: var(--bg); border-radius: 30px; padding: 8px 10px 8px 18px; display: flex; align-items: center; gap: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: calc(100vw - 24px); }
.timerbar .tb-title { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timerbar .tb-clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.timerbar button { background: rgba(255,255,255,.15); border: 0; color: inherit; border-radius: 20px; padding: 5px 12px; cursor: pointer; }
@media (prefers-color-scheme: dark) { .timerbar button { background: rgba(0,0,0,.12); } }

/* Fenster */
.modal-back { position: fixed; inset: 0; background: rgba(10,12,20,.45); z-index: 60; display: grid; place-items: start center; padding: 8vh 14px 14px; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.3); width: 100%; max-width: 520px; padding: 20px; display: grid; gap: 12px; }
.modal h2 { margin: 0; }
.modal .actions { display: flex; gap: 8px; justify-content: space-between; margin-top: 4px; flex-wrap: wrap; }
.modal .actions .row { margin-left: auto; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.colors button.sel { border-color: var(--text); }
.cmd input { font-size: 17px; }
.cmd-list { display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; }
.cmd-item { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.cmd-item.sel, .cmd-item:hover { background: var(--accent-weak); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
kbd { background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font-size: 12px; font-family: inherit; }

.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; z-index: 80; }

/* Handy */
@media (max-width: 900px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat .v { font-size: 21px; }
  .nav { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); z-index: 30; }
  .nav .brand, .nav-foot { display: none; }
  .nav-btn { flex-direction: column; gap: 2px; font-size: 18px; padding: 6px 10px; }
  .nav-btn span { font-size: 11px; }
  .main { padding: 16px 14px 150px; }
  .timerbar { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .focus .clock { font-size: 56px; }
  .focus .ftitle { font-size: 23px; }
  .week { grid-template-columns: 1fr; }
  .daycol { min-height: 0; }
  .chart { height: 150px; gap: 5px; }
  .chart-labels { gap: 5px; }
  .hide-mobile { display: none; }
}
