:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1f2a24;
  --muted: #6d746e;
  --line: #e4ded2;
  --accent: #3f8f6b;
  --accent-soft: #e2efe7;
  --warn: #b5482f;
  --warn-soft: #f8e6df;
  --prio: #c9871f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 36, .06), 0 6px 24px rgba(31, 42, 36, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a17;
    --panel: #1c2420;
    --ink: #e8ece6;
    --muted: #93a097;
    --line: #2c3631;
    --accent: #5cb98e;
    --accent-soft: #23362c;
    --warn: #e8826a;
    --warn-soft: #3a2420;
    --prio: #e3a84a;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--accent); }
code { font: 13px ui-monospace, Consolas, monospace; background: var(--accent-soft); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.copy { cursor: copy; }
.muted { color: var(--muted); }
.small, small { font-size: 13px; }
.warn { color: var(--warn); font-size: 13px; margin: 4px 0; }
.ok { color: var(--accent); }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* Knöpfe & Felder */
button, .btn {
  font: inherit; border: 0; border-radius: 10px; padding: 8px 14px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
button.ghost:hover { background: var(--accent-soft); filter: none; }
button.small { padding: 3px 10px; font-size: 13px; }
button.danger, .danger { color: var(--warn) !important; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 38px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check, .small-check { flex-direction: row; align-items: center; gap: 6px; }
textarea { resize: vertical; }

/* Kopf */
.top {
  display: flex; align-items: center; gap: 16px; padding: 22px 28px 14px;
  max-width: 1400px; margin: 0 auto;
}
.hello { flex: 1; min-width: 0; }
.hello h1 { font-size: 28px; }
.hello p { margin: 2px 0 0; color: var(--muted); }
.icon-btn { background: transparent; color: var(--muted); padding: 8px; border-radius: 50%; }
.icon-btn:hover { background: var(--panel); color: var(--ink); }

.music {
  display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 16px 5px 5px; box-shadow: var(--shadow); max-width: 280px;
}
.music .play { width: 40px; height: 40px; border-radius: 50%; padding: 0; display: grid; place-items: center; background: #1db954; flex: none; }
.music.off .play { background: var(--muted); }
.music .play.busy { animation: pulse 1s infinite; }
.music.playing .play { box-shadow: 0 0 0 4px rgba(29, 185, 84, .25); }
.music-text { display: flex; flex-direction: column; min-width: 0; }
.music-text .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
#playlist-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
@keyframes pulse { 50% { opacity: .5; } }

/* Raster */
.grid {
  display: grid; grid-template-columns: 1.1fr 1.1fr 1fr; gap: 18px;
  padding: 6px 28px 28px; max-width: 1400px; margin: 0 auto; align-items: start;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { font-size: 18px; }
.tabs { display: none; }
.empty { text-align: center; padding: 24px 0; }

/* Termine */
.day { margin-bottom: 14px; }
.day h3, .group h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 0 0 6px; font-weight: 700;
}
.day.is-today h3 { color: var(--accent); }
.event {
  display: grid; grid-template-columns: 10px 92px 1fr auto; gap: 10px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.event:last-child { border-bottom: 0; }
.event .dot { width: 9px; height: 9px; border-radius: 50%; align-self: center; }
.event .when { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.event .what small { display: block; color: var(--muted); }
.event .cal { font-size: 11px; color: var(--muted); }
.event.past { opacity: .45; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Aufgaben */
.add { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.add > input { flex: 1; }
.add > button { flex: none; }
.add-more {
  width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px;
  padding: 10px; background: var(--bg); border-radius: 10px; align-items: end;
}
.add-more .interval { flex-direction: row; align-items: center; }
.add-more .interval input { width: 64px; }
.group { margin-bottom: 14px; }
.group.overdue h3 { color: var(--warn); }
.group.today h3 { color: var(--accent); }
.count { background: var(--line); color: var(--ink); border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
.task {
  display: flex; gap: 10px; align-items: flex-start; padding: 7px 4px; border-radius: 8px;
  transition: opacity .3s, transform .3s;
}
.task:hover { background: var(--accent-soft); }
.task.ticking { opacity: 0; transform: translateX(16px); }
.check-btn {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); background: transparent;
  padding: 0; flex: none; margin-top: 1px;
}
.task.prio .check-btn { border-color: var(--prio); }
.check-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.is-done .check-btn { background: var(--accent); border-color: var(--accent); }
.is-done .title { text-decoration: line-through; color: var(--muted); }
.task-body { flex: 1; cursor: pointer; min-width: 0; }
.task-body .title { display: block; overflow-wrap: anywhere; }
.task.prio .title { font-weight: 600; }
.task-body .meta { display: block; font-size: 12px; color: var(--muted); }
.group.overdue .meta { color: var(--warn); }
.more { margin: 4px 0 0 30px; }

/* Notizen */
.note-add { flex-direction: column; }
.note-add .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note {
  position: relative; padding: 10px 34px 10px 12px; border-radius: 10px; background: var(--bg);
  margin-bottom: 8px; cursor: pointer; border-left: 3px solid transparent;
}
.note.imp { border-left-color: var(--prio); }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9.5em; overflow: hidden; }
.note time { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.star { position: absolute; right: 6px; top: 6px; background: transparent; color: var(--prio); padding: 2px 6px; font-size: 17px; }

/* Dialoge */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink);
  padding: 22px; width: min(520px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog.wide { width: min(760px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10, 14, 12, .45); backdrop-filter: blur(2px); }
dialog form, .settings { display: flex; flex-direction: column; gap: 12px; }
dialog h3 { font-size: 19px; }
dialog h4 { font-size: 14px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.source { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 6px 0; }
.source-form { margin-top: 8px; padding: 14px; background: var(--bg); border-radius: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.logout { text-align: right; margin-top: 8px; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; opacity: 0;
  transition: .25s; pointer-events: none; font-size: 14px; max-width: calc(100vw - 32px); text-align: center; z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Login */
body.login { display: grid; place-items: center; padding: 16px; }
body.login .card {
  background: var(--panel); padding: 28px; border-radius: var(--radius); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); box-shadow: var(--shadow);
}
.err { color: var(--warn); margin: 0; }

/* Mittelgroß */
@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr 1fr; }
  #notizen { grid-column: 1 / -1; }
}
/* Handy */
@media (max-width: 720px) {
  .top { padding: 16px 16px 10px; flex-wrap: wrap; gap: 10px; }
  .hello { flex-basis: calc(100% - 60px); }
  .hello h1 { font-size: 22px; }
  .music { order: 3; max-width: none; flex: 1; }
  .tabs {
    display: flex; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 6px 16px; gap: 6px;
  }
  .tabs button { flex: 1; background: transparent; color: var(--muted); border: 1px solid var(--line); }
  .tabs button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .grid { display: block; padding: 8px 16px 90px; }
  .panel { display: none; padding: 14px; }
  .panel.active { display: block; }
  .event { grid-template-columns: 10px 78px 1fr; }
  .event .cal { display: none; }
  dialog { padding: 16px; }
}
