:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --text: #e0e0e0;
  --text-dim: #8899aa;
  --accent: #e94560;
  --accent2: #00d2ff;
  --cat-arbeit: #3b82f6;
  --cat-privat: #22c55e;
  --cat-sport: #f97316;
  --cat-essen: #ef4444;
  --cat-familie: #a855f7;
  --cat-gimboid: #eab308;
  --cat-medikinet: #ec4899;
  --med-taken: #22c55e;
  --med-skipped: #ef4444;
  --med-missed: #6b7280;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
.header {
  background: var(--bg2);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--bg3);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 1.4rem; letter-spacing: 1px; }
.header h1 span { color: var(--accent); }
.header-date { color: var(--text-dim); font-size: 0.9rem; }
.main-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  padding: 16px 24px;
  min-height: calc(100vh - 60px);
}
.timeline-container {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.timeline-header h2 { font-size: 1rem; color: var(--text-dim); }
.next-up {
  background: var(--bg3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--accent2);
  font-weight: 600;
}
.timeline-wrapper {
  position: relative;
  overflow-x: auto;
  padding-bottom: 8px;
}
.timeline-track {
  position: relative;
  min-width: 1200px;
  height: 340px;
  margin-top: 10px;
}
.timeline-axis {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bg3);
}
.timeline-hours {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  height: 16px;
}
.hour-mark {
  position: absolute;
  top: 0;
  font-size: 0.65rem;
  color: var(--text-dim);
  transform: translateX(-50%);
}
.hour-mark::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  width: 1px;
  height: 6px;
  background: var(--bg3);
}
.time-block {
  position: absolute;
  top: 10px;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: grab;
  user-select: none;
  min-width: 60px;
  transition: transform 0.15s, box-shadow 0.15s;
  font-size: 0.78rem;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  z-index: 2;
}
.time-block:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0,0,0,0.5);
  z-index: 10;
}
.time-block .block-title { font-weight: 600; margin-bottom: 2px; }
.time-block .block-time { font-size: 0.7rem; opacity: 0.8; }
.time-block .block-cat { font-size: 0.65rem; opacity: 0.6; margin-top: 2px; }
.time-block.cat-arbeit { background: var(--cat-arbeit); }
.time-block.cat-privat { background: var(--cat-privat); }
.time-block.cat-sport { background: var(--cat-sport); }
.time-block.cat-essen { background: var(--cat-essen); }
.time-block.cat-familie { background: var(--cat-familie); }
.time-block.cat-gimboid { background: var(--cat-gimboid); }
.time-block.cat-medikinet { background: var(--cat-medikinet); }
.now-marker {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  z-index: 20;
  pointer-events: none;
}
.now-marker::before {
  content: 'JETZT';
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}
.timeline-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--bg3);
}
.cat-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 90px);
  padding-right: 4px;
}
.right-panel::-webkit-scrollbar { width: 4px; }
.right-panel::-webkit-scrollbar-track { background: transparent; }
.right-panel::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 2px; }
.panel-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel-card h3 {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* MEDIKINET TRACKER */
.medkit-section { border: 2px solid var(--cat-medikinet); }
.medkit-stats {
  display: flex;
  justify-content: space-around;
  background: var(--bg3);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}
.medkit-stat { text-align: center; }
.medkit-stat .val { font-size: 1.5rem; font-weight: 700; color: var(--accent2); }
.medkit-stat .lbl { font-size: 0.7rem; color: var(--text-dim); }
.medkit-big-btn {
  width: 100%;
  padding: 18px;
  border: 3px solid var(--cat-medikinet);
  border-radius: 14px;
  background: linear-gradient(135deg, var(--cat-medikinet), #db2777);
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.medkit-big-btn:hover { transform: scale(1.02); box-shadow: 0 0 25px rgba(236,72,153,0.4); }
.medkit-big-btn .icon { font-size: 2rem; }
.medkit-big-btn .detail { font-size: 0.85rem; opacity: 0.9; }
.medkit-big-btn .time { font-size: 1.2rem; font-weight: 800; }
.medkit-big-btn.taken { background: linear-gradient(135deg, var(--med-taken), #16a34a); border-color: var(--med-taken); }
.medkit-pending-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 10px 0 6px;
}
.medkit-pending-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 0.82rem;
}
.medkit-pending-item.pending {
  background: rgba(239,68,68,0.12);
  border-left: 3px solid var(--med-skipped);
}
.medkit-pending-item.expired {
  background: rgba(239,68,68,0.2);
  border-left: 3px solid var(--med-skipped);
  padding: 10px 10px;
}
.medkit-pending-item.taken {
  background: rgba(34,197,94,0.12);
  border-left: 3px solid var(--med-taken);
}
.medkit-pending-item.missed {
  background: rgba(107,114,128,0.12);
  border-left: 3px solid var(--med-missed);
}
/* Action buttons for expired doses */
.medkit-expired-btn {
  min-width: 70px;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  transition: opacity 0.2s, transform 0.1s;
  min-height: 32px;
}
.medkit-expired-btn:active { transform: scale(0.96); }
.medkit-btn-take { background: var(--med-taken); color: white; }
.medkit-btn-skip { background: var(--med-missed); color: white; }
.medkit-pending-item .pend-time { font-weight: 600; min-width: 44px; }
.medkit-pending-item .pend-info { flex: 1; }
.medkit-pending-item .pend-info .pend-name { font-weight: 600; }
.medkit-pending-item .pend-info .pend-dose { font-size: 0.7rem; color: var(--text-dim); }
.medkit-pending-item .pend-status { font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.medkit-pending-item.pending .pend-status { background: var(--med-skipped); color: white; }
.medkit-pending-item.taken .pend-status { background: var(--med-taken); color: white; }
.medkit-streak {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0,210,255,0.12);
  border: 1px solid var(--accent2);
  border-radius: 8px;
  padding: 8px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--accent2);
  font-weight: 600;
}
.medkit-history {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--bg3);
}
.medkit-history-label { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 6px; }
.history-timeline { position: relative; padding-left: 20px; }
.history-timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--bg3);
}
.history-entry {
  position: relative;
  padding: 4px 0 4px 10px;
  font-size: 0.72rem;
}
.history-entry::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid;
}
.history-entry.s-taken::before { background: var(--med-taken); border-color: var(--med-taken); }
.history-entry.s-skipped::before { background: var(--med-skipped); border-color: var(--med-skipped); }
.history-entry.s-missed::before { background: var(--med-missed); border-color: var(--med-missed); }
.history-entry.s-noanswer::before { background: var(--bg3); border-color: var(--med-missed); border-style: dashed; }
.history-entry .h-date { color: var(--text-dim); font-size: 0.68rem; }
.history-entry .h-action { font-weight: 600; }
.history-entry .h-action.s-taken { color: var(--med-taken); }
.history-entry .h-action.s-skipped { color: var(--med-skipped); }
.history-entry .h-action.s-noanswer { color: var(--med-missed); }
.history-entry .h-action.s-pending { color: var(--accent2); }
.history-entry .h-note { color: var(--text-dim); font-style: italic; font-size: 0.68rem; }
.todo-input-row { display: flex; gap: 6px; margin-bottom: 10px; }
.todo-input-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}
.todo-input-row input:focus { border-color: var(--accent); }
.todo-input-row button, .btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
}
.todo-input-row button:hover { background: #d63a52; }
.priority-select {
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: 6px;
  padding: 8px;
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
  width: 80px;
}
.todo-list { max-height: 200px; overflow-y: auto; }
.todo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 0.82rem;
}
.todo-item:hover { background: var(--bg); }
.todo-item input[type="checkbox"] { accent-color: var(--accent2); width: 16px; height: 16px; cursor: pointer; }
.todo-item .todo-text { flex: 1; }
.todo-item .todo-text.done { text-decoration: line-through; opacity: 0.5; }
.todo-item .todo-priority { font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.priority-hoch { background: rgba(239,68,68,0.3); color: #fca5a5; }
.priority-mittel { background: rgba(234,179,8,0.3); color: #fde68a; }
.priority-niedrig { background: rgba(34,197,94,0.3); color: #86efac; }
.timer-display { text-align: center; margin: 10px 0; }
.timer-time { font-size: 2.5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent2); letter-spacing: 2px; }
.timer-progress { width: 100%; height: 4px; background: var(--bg); border-radius: 2px; margin: 12px 0; overflow: hidden; }
.timer-progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 2px; transition: width 1s linear; }
.timer-controls { display: flex; gap: 8px; justify-content: center; }
.timer-controls button {
  background: var(--bg3);
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
}
.timer-controls button:hover { background: var(--bg); }
.timer-controls button.active { background: var(--accent); }
.timer-settings { display: flex; align-items: center; gap: 6px; margin-top: 8px; justify-content: center; }
.timer-settings label { font-size: 0.75rem; color: var(--text-dim); }
.timer-settings input { width: 50px; background: var(--bg); border: 1px solid var(--bg3); border-radius: 4px; padding: 4px 6px; color: var(--text); font-size: 0.75rem; text-align: center; outline: none; }
/* ====== FLAME ENERGY / FOCUS ====== */
.flame-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.flame-controls-v {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.flame-controls-h {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}
.slider-label-v {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  margin: 6px 0;
}
.slider-label-h {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.slider-val-v {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  margin: 6px 0;
}
.slider-val-h {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
}
/* Vertical range slider */
#energyRange {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  background: transparent;
  writing-mode: vertical-lr;
  direction: rtl;
  transform: rotate(180deg);
}
#energyRange::-webkit-slider-runnable-track {
  width: 4px;
  height: 100px;
  background: linear-gradient(to top, var(--bg3), var(--accent));
  border-radius: 2px;
}
#energyRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  margin-left: -7px;
}
#energyRange::-moz-range-track {
  width: 4px;
  height: 100px;
  background: linear-gradient(to top, var(--bg3), var(--accent));
  border-radius: 2px;
}
#energyRange::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
/* Horizontal range slider */
#focusRange {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  max-width: 180px;
  height: 4px;
  background: linear-gradient(to right, var(--bg3), var(--accent));
  border-radius: 2px;
}
#focusRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
#focusRange::-moz-range-track {
  width: 100%;
  max-width: 180px;
  height: 4px;
  background: linear-gradient(to right, var(--bg3), var(--accent));
  border-radius: 2px;
}
#focusRange::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
#flameCanvas {
  display: block;
  image-rendering: auto;
}
/* Mobile – bis 900px */
@media (max-width: 900px) {
  .main-layout { grid-template-columns: 1fr; padding: 8px; }
  .timeline-track { min-width: 900px; height: 280px; }
  .panel-card { padding: 12px; }
  .medkit-big-btn { padding: 14px; font-size: 0.95rem; border-width: 2px; }
  .medkit-big-btn .icon { font-size: 1.5rem; }
  .medkit-big-btn .time { font-size: 1rem; }
  .medkit-big-btn .detail { font-size: 0.75rem; }
  .timer-time { font-size: 2rem; }
  .mood-btn { width: 32px; height: 32px; }
  .mood-btn[data-level="1"],
  .mood-btn[data-level="5"] { width: 36px; height: 36px; }
  /* Touch-friendly: min 44px tap targets */
  .mood-btn { min-width: 44px; min-height: 44px; }
  .todo-input-row { flex-wrap: wrap; }
  .todo-input-row input { width: 100%; min-width: 100%; margin-bottom: 4px; }
  .todo-input-row button { width: 100%; }
  .right-panel { -webkit-overflow-scrolling: touch; }
}
/* Kleinstgeräte */
@media (max-width: 480px) {
  .header { padding: 8px 12px; }
  .header h1 { font-size: 1.1rem; }
  .header-date { font-size: 0.75rem; }
  .panel-card { padding: 10px; }
  .panel-card h3 { font-size: 0.82rem; }
  .timeline-container { padding: 12px; }
  .medkit-stats { padding: 8px; }
  .medkit-stat .val { font-size: 1.2rem; }
  .medkit-stat .lbl { font-size: 0.6rem; }
  .medkit-pending-item { padding: 6px 8px; font-size: 0.75rem; }
  .timer-time { font-size: 1.7rem; }
  .timeline-track { min-width: 700px; height: 260px; }
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
