:root {
  --bg: #f8fafc;
  --text: #0f172a;
  --muted: #475569;
  --card: #ffffff;
  --line: #dbe2ea;
  --tina: #dc2626;
  --klaus: #0284c7;
  --angebote: #16a34a;
  --kinder: #d97706;
  --axis-width: 3.4rem;
  --col-width: 9rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.45rem;
  padding: 0.65rem;
  background: #0f172a;
}

.icon-btn,
button,
.file-btn {
  border: 1px solid #334155;
  border-radius: 0.65rem;
  padding: 0.46rem 0.64rem;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.88rem;
  cursor: pointer;
  box-shadow: 0 1px 0 #ffffff0f inset;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
}

.icon-btn svg,
.calendar-btn svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.date-field {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid #334155;
  border-radius: 0.65rem;
  padding: 0.3rem;
  background: #1e293b;
}

.date-display {
  border: 0;
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  padding: 0.2rem 0.3rem;
  min-height: 2rem;
}

.calendar-btn {
  border-color: #334155;
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.36rem 0.45rem;
  display: grid;
  place-items: center;
}

.native-date-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.app {
  padding: 0.5rem;
  height: calc(100dvh - 4.4rem);
}

.planner-wrap {
  height: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}

.planner {
  width: max-content;
  min-width: 100%;
}

.planner-grid {
  display: grid;
  grid-template-columns: var(--axis-width) repeat(4, var(--col-width));
  grid-template-rows: auto auto;
}

.axis-head {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 9;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.col-head {
  display: grid;
  grid-template-columns: 1fr auto;
  position: sticky;
  top: 0;
  z-index: 8;
  align-items: center;
  gap: 0.25rem;
  padding: 0.45rem;
  color: #fff;
  border-right: 1px solid #ffffff66;
}

.col-head h3 {
  margin: 0;
  font-size: 0.88rem;
}

.col-head button {
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
  background: #ffffffde;
}

.col-head.collapsed {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 0.15rem 0.1rem;
  gap: 0.15rem;
}

.col-head.collapsed h3 {
  font-size: 0.62rem;
  line-height: 1;
}

.col-head .collapse-btn {
  min-width: 1.25rem;
}

.col-head.collapsed .collapse-btn {
  margin-bottom: 0.05rem;
}

.time-axis {
  position: relative;
  position: sticky;
  left: 0;
  z-index: 7;
  border-right: 1px solid var(--line);
  background: #f8fafc;
}

.time-label {
  position: absolute;
  left: 0.25rem;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.72rem;
}

.timeline-col {
  position: relative;
  border-right: 1px solid var(--line);
  background-image: repeating-linear-gradient(
    to bottom,
    #ffffff 0,
    #ffffff 59px,
    #cbd5e1 60px
  );
}

.timeline-col.drop-target {
  background-color: #e0f2fe;
}

.now-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dotted #dc2626;
  pointer-events: none;
  z-index: 40;
}

.entry-block {
  position: absolute;
  left: 0.2rem;
  right: 0.2rem;
  border: 0;
  border-left: 6px solid currentColor;
  border-radius: 0.4rem;
  background: #ffffffeb;
  padding: 0.2rem 0.25rem;
  text-align: left;
  overflow: hidden;
  touch-action: none;
}

.entry-title {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 700;
}

.entry-meta {
  margin: 0.1rem 0 0;
  font-size: 0.67rem;
  color: var(--muted);
}

.entry-block.dragging {
  opacity: 0.35;
}

#undoBtn:disabled,
#redoBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.entry-block.drag-ghost {
  opacity: 0.92;
  box-shadow: 0 8px 18px #0f172a33;
  border: 2px dashed currentColor;
  border-left-width: 2px;
  background: #ffffffea;
  z-index: 25;
}

.timeline-col.collapsed .entry-block {
  left: 0.12rem;
  right: 0.12rem;
  border-left-width: 0;
  border-radius: 999px;
  padding: 0;
  min-height: 14px;
  background: currentColor;
  opacity: 0.92;
  box-shadow: inset 0 0 0 1px #00000026;
}

.timeline-col.collapsed .entry-title,
.timeline-col.collapsed .entry-meta {
  display: none;
}

.settings-dialog,
.entry-dialog,
.move-copy-dialog {
  width: min(95vw, 420px);
  border: 0;
  border-radius: 0.8rem;
  padding: 0;
}

.settings-dialog::backdrop,
.entry-dialog::backdrop,
.move-copy-dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
}

.settings-form,
#entryForm {
  display: grid;
  gap: 0.45rem;
  padding: 1rem;
}

.settings-form h2,
#entryForm h2 {
  margin: 0;
  font-size: 1.1rem;
}

.move-copy-form {
  display: grid;
  gap: 0.7rem;
  padding: 1rem;
}

.move-copy-form h3,
.move-copy-form p {
  margin: 0;
}

.move-copy-form menu {
  grid-template-columns: 1fr 1fr 1fr;
}

details {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.4rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

.file-btn {
  display: inline-block;
  margin-top: 0.5rem;
}

.file-btn input {
  display: none;
}

.settings-actions {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

#entryForm label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.92rem;
}

#entryForm .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

#entryForm input,
#entryForm select,
#entryForm textarea {
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.42rem;
  font: inherit;
}

.notes-toggle {
  margin-top: 0.05rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.35rem 0.45rem;
}

.notes-toggle summary {
  font-weight: 600;
  cursor: pointer;
}

.notes-toggle label {
  margin-top: 0.35rem;
}

menu {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
}

body.dragging-active {
  user-select: none;
}

.settings-wrap {
  position: relative;
}

.settings-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  display: grid;
  gap: 0.3rem;
  min-width: 9.4rem;
  padding: 0.4rem;
  border: 1px solid #334155;
  border-radius: 0.6rem;
  background: #0f172a;
  box-shadow: 0 8px 18px #00000040;
  z-index: 80;
}

.settings-menu[hidden] {
  display: none !important;
}

.settings-menu button {
  border-color: #334155;
  background: #111827;
  color: #e2e8f0;
  text-align: left;
}

.planner-wrap,
.planner,
.planner-grid,
.time-axis,
.timeline-col,
.entry-block,
.col-head h3,
.time-label,
.entry-title,
.entry-meta {
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  overscroll-behavior: none;
}

#entryForm menu {
  grid-template-columns: 1fr 1fr 1fr;
}

.primary {
  background: #0f172a;
  color: #fff;
}

.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: #9f1239;
}

@media (min-width: 740px) {
  :root {
    --col-width: 12.4rem;
  }

  .app {
    max-width: 1020px;
    margin: 0 auto;
  }
}
