/* ---------------------------------------------------------------------------
   x.wenkmedia — Notizen
   Bild: ein Werkstattbuch. Links eine Randspalte mit Uhrzeiten in Schreibmaschine,
   rechts der Eintrag. Keine externen Schriften, kein CDN.
   Theme: html.is-light / html.is-dark, gesetzt vom Inline-Skript im Kopf.
   ------------------------------------------------------------------------- */

:root {
  --bg:       #f1f3f2;
  --surface:  #ffffff;
  --sunk:     #e7eae9;
  --shim:     #dde2e1;
  --ink:      #151b20;
  --muted:    #5f6c74;
  --line:     #d9dfe0;
  --accent:   #0d6f60;
  --accent-ink: #ffffff;
  --signal:   #b8511a;
  --danger:   #9c2f2f;
  --shadow:   0 1px 2px rgba(20,30,35,.05);
  --radius:   14px;
  --rail:     58px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

html.is-dark {
  --bg:      #101518;
  --surface: #182025;
  --sunk:    #131a1e;
  --shim:    #202a30;
  --ink:     #e4ebee;
  --muted:   #8b989f;
  --line:    #242e34;
  --accent:  #2fae99;
  --accent-ink: #06231f;
  --signal:  #d4813f;
  --danger:  #d9736c;
  --shadow:  0 1px 2px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
html:lang(zh) body { line-height: 1.65; }

body { animation: pagein .3s ease both; }
@keyframes pagein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
mark { background: color-mix(in srgb, var(--signal) 28%, transparent); color: inherit; border-radius: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Ladebalken ganz oben bei Navigation */
.pageload {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 90;
  opacity: 0;
  transition: width .25s ease, opacity .3s ease;
}
.pageload.run { opacity: 1; width: 72%; transition: width 8s cubic-bezier(.1,.8,.3,1); }
.pageload.done { opacity: 0; width: 100%; transition: width .2s ease, opacity .4s ease .1s; }

/* ------------------------------------------------------------------ Kopf */

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 8px;
  padding-top: max(10px, env(safe-area-inset-top));
}

.find { display: flex; gap: 6px; align-items: center; }
.find input[type="search"] {
  flex: 1; min-width: 0;
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
}
.find button, .find .clear {
  font: 500 13px/1 var(--sans);
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.chips {
  display: flex; gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 12px 2px;
  margin: 0 -12px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  font: 500 13px/1 var(--sans);
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip span { font: 500 11px/1 var(--mono); opacity: .65; }
.tagchip { font-family: var(--mono); font-size: 12px; }

.toolbar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.switches { display: flex; align-items: center; gap: 8px; }
.toolbar .ghost { margin-left: auto; opacity: .65; }

.langsw {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}
.langsw .lang {
  font: 500 12px/1 var(--sans);
  padding: 7px 10px;
  color: var(--muted);
  text-decoration: none;
  border-right: 1px solid var(--line);
  transition: background .15s ease, color .15s ease;
}
.langsw .lang:last-child { border-right: 0; }
.langsw .lang.on { background: var(--accent); color: var(--accent-ink); }

.themesw {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 12px/1 var(--sans);
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
}
.themesw .tico { font-size: 13px; transition: transform .4s ease; }
.themesw:hover .tico { transform: rotate(20deg); }

.result { margin: 8px 2px 0; font: 500 13px/1.3 var(--mono); color: var(--muted); }

.top.slim { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.top.slim .back { font: 500 14px/1 var(--sans); text-decoration: none; }
.top.slim .when { font: 400 12px/1.4 var(--mono); color: var(--muted); }
.top.slim .switches { margin-left: auto; }

/* -------------------------------------------------------------- Zeitleiste */

.stream { max-width: 780px; margin: 0 auto; padding: 8px 12px 140px; position: relative; }
.stream::before {
  content: "";
  position: absolute;
  left: calc(12px + var(--rail) - 13px);
  top: 0; bottom: 140px;
  width: 1px;
  background: var(--line);
}

.daymark { position: relative; margin: 22px 0 12px; text-align: center; }
.daymark span {
  position: relative;
  background: var(--bg);
  padding: 0 10px;
  font: 500 11px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  align-items: start;
  margin: 0 0 10px;
  scroll-margin-top: 104px;
}

.reveal { opacity: 0; transform: translateY(10px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .45s ease, transform .45s cubic-bezier(.2,.7,.3,1); }
.no-js .reveal, html:not(.js) .reveal { opacity: 1; transform: none; }

.stamp {
  padding-top: 12px;
  font: 400 12px/1 var(--mono);
  color: var(--muted);
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
}
.stamp .pin { color: var(--signal); font-size: 10px; }

.bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow);
  padding: 10px 12px 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.card.pinned .bubble { border-color: color-mix(in srgb, var(--signal) 45%, var(--line)); }
.card.done .bubble { background: var(--sunk); box-shadow: none; }
.card.done .text, .card.done .ctitle { color: var(--muted); }

.ctitle { margin: 0 0 4px; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.text { margin: 0; }
.text a.tag, .ctitle a.tag { font-family: var(--mono); font-size: .92em; text-decoration: none; }

.cardbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 8px; padding-top: 6px;
  border-top: 1px dashed var(--line);
}
.cardbar .clip, .cardbar .edited { font: 400 11px/1 var(--mono); color: var(--muted); }

.chipbtn {
  font: 500 12px/1 var(--sans);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  transition: color .15s ease, border-color .15s ease;
}
.chipbtn:hover { color: var(--ink); border-color: var(--muted); }
.chipbtn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chipbtn.danger { color: var(--danger); }
.chipbtn.on { border-color: var(--accent); color: var(--accent); }
.chipbtn[disabled] { opacity: .5; cursor: default; }
.inline { display: inline; margin: 0; }

.pinnedbar { margin: 6px 0 18px; }
.railtitle {
  font: 500 11px/1 var(--mono);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}
.pinrow {
  display: flex; gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--signal);
  border-radius: 8px;
  margin-bottom: 6px;
  text-decoration: none;
  color: var(--ink);
}
.pinwhen { font: 400 12px/1.4 var(--mono); color: var(--muted); }
.pintext { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

.more { text-align: center; margin: 14px 0; }
.more a { font: 500 13px/1 var(--sans); color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 15px; }

/* ---------------------------------------------------------------- Anhaenge */

.gallery { display: grid; gap: 4px; margin: 8px 0 4px; }
.gallery.n1 { grid-template-columns: 1fr; }
.gallery.n2, .gallery.n3, .gallery.n4 { grid-template-columns: 1fr 1fr; }

.shot {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--sunk);
  aspect-ratio: 4 / 3;
  cursor: zoom-in;
}
.gallery.n1 .shot { aspect-ratio: var(--ar, 4/3); max-height: 62vh; }
.shot img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity .5s ease, transform .6s cubic-bezier(.2,.7,.3,1);
}
.shot img.loaded { opacity: 1; transform: none; }

/* Schimmer, solange das Bild laedt */
.skel::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg, var(--sunk) 30%, var(--shim) 50%, var(--sunk) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skel.ready::before { animation: none; opacity: 0; transition: opacity .4s ease; }
@keyframes shimmer { from { background-position: 140% 0; } to { background-position: -40% 0; } }

.files { list-style: none; margin: 8px 0 2px; padding: 0; display: grid; gap: 4px; }
.files a {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px;
  background: var(--sunk);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
}
.ext {
  font: 600 10px/1 var(--mono);
  letter-spacing: .06em;
  padding: 5px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
}
.fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.fsize { font: 400 11px/1 var(--mono); color: var(--muted); }

/* --------------------------------------------------------------- Composer */

.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.composer .row { display: flex; align-items: flex-end; gap: 8px; max-width: 780px; margin: 0 auto; }

.iconbtn {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 19px;
  cursor: pointer;
  transition: transform .12s ease;
}
.iconbtn:active { background: var(--sunk); transform: scale(.94); }

.composer textarea {
  flex: 1; min-width: 0;
  font: inherit;
  resize: none;
  max-height: 40vh;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
}

.send {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  cursor: pointer;
  transition: transform .12s ease;
}
.send:active { transform: scale(.94); }
.send[disabled] { opacity: .55; }

.picked {
  display: flex; gap: 6px;
  overflow-x: auto;
  max-width: 780px;
  margin: 0 auto 8px;
  scrollbar-width: none;
}
.picked::-webkit-scrollbar { display: none; }
.picked figure {
  position: relative;
  margin: 0;
  flex: 0 0 auto;
  width: 66px; height: 66px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--sunk);
  border: 1px solid var(--line);
  animation: pop .25s cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes pop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }
.picked img { width: 100%; height: 100%; object-fit: cover; }
.picked .doc {
  display: grid; place-items: center;
  height: 100%;
  font: 600 10px/1.3 var(--mono);
  text-align: center;
  color: var(--muted);
  padding: 4px;
  overflow: hidden;
}
.picked figure .drop {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  border: 0; border-radius: 50%;
  background: rgba(10,14,16,.72);
  color: #fff;
  font: 600 11px/1 var(--sans);
  cursor: pointer;
}
.picked figure.busy::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: shimmer 1s linear infinite;
}

/* Fortschritt in Prozent */
.progress {
  display: flex; align-items: center; gap: 10px;
  max-width: 780px;
  margin: 0 auto 8px;
}
.pbar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--sunk);
  overflow: hidden;
}
.pbar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width .18s ease;
}
.ptext { font: 500 12px/1 var(--mono); color: var(--muted); min-width: 96px; text-align: right; }

/* ------------------------------------------------------------- Bearbeiten */

.sheet { max-width: 780px; margin: 0 auto; padding: 18px 14px 60px; }
.sheet.narrow { max-width: 380px; padding-top: 16vh; }
.sheet.wide { max-width: 820px; }

.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.sheet h1 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 16px; }
.sheet h2 { font-size: 15px; margin: 22px 0 8px; }
.loginswitches { margin-top: 26px; display: flex; justify-content: center; }

.stack { display: grid; gap: 10px; }
.stack input, .titlefield, .bodyfield {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.stack button {
  font: 500 15px/1 var(--sans);
  padding: 11px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.editform { display: grid; gap: 8px; }
.titlefield { font-weight: 650; }
.bodyfield { min-height: 160px; resize: vertical; line-height: 1.55; }
.editbar { display: flex; gap: 8px; align-items: center; }

.attgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.att {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.att .shot { border-radius: 0; aspect-ratio: 4 / 3; }
.filebox { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--sunk); }
.att figcaption { display: grid; gap: 2px; padding: 6px 8px; }
.att .fname { font-size: 12px; }
.attbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 8px; }

.statusbar { display: flex; flex-wrap: wrap; gap: 8px; }
.taglist { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }

.checks { list-style: none; padding: 0; margin: 0 0 8px; font-size: 14px; display: grid; gap: 4px; }
.checks li.ok, .ok { color: var(--accent); }
.checks li.warn, .warn { color: var(--signal); }
.meta { font: 400 12px/1.4 var(--mono); color: var(--muted); }
.code, pre.code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: 400 12px/1.5 var(--mono);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* -------------------------------------------------------------- Meldungen */

.flash {
  position: fixed;
  left: 50%;
  top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 60;
  max-width: 92vw;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0,0,0,.22);
  animation: flashin .3s ease both, flashout 4.6s forwards;
}
@keyframes flashin { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes flashout { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* --------------------------------------------------- Lightbox mit Zoom */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8,11,13,.95);
  display: grid;
  place-items: center;
  overflow: hidden;
  animation: lbin .22s ease both;
  touch-action: none;
}
@keyframes lbin { from { opacity: 0; } to { opacity: 1; } }

.lbstage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  cursor: grab;
}
.lbstage.grabbing { cursor: grabbing; }
.lbstage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.lbstage img.anim { transition: transform .22s cubic-bezier(.2,.7,.3,1); }

.lbtop {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  z-index: 2;
}
.lbcount { font: 500 12px/1 var(--mono); color: rgba(255,255,255,.72); }
.lbzoomlevel { font: 500 12px/1 var(--mono); color: rgba(255,255,255,.5); margin-left: auto; }
.lbclose {
  font-size: 24px; line-height: 1;
  color: #fff; background: none; border: 0; cursor: pointer;
  padding: 4px 8px;
}

.lbnav {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; gap: 8px;
  z-index: 2;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 12px;
}
.lbnav button, .lbnav a {
  font: 500 13px/1 var(--sans);
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.lbnav button:disabled { opacity: .35; cursor: default; }
.lbhint {
  position: absolute;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 46px);
  font: 400 11px/1 var(--mono);
  color: rgba(255,255,255,.45);
  animation: fadeaway 4s forwards;
}
@keyframes fadeaway { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}

@media (min-width: 620px) {
  :root { --rail: 66px; }
  .gallery.n3 { grid-template-columns: repeat(3, 1fr); }
  .gallery.n4 { grid-template-columns: repeat(4, 1fr); }
}

/* ---------------------------------------------------------------------------
   Kalender — Zeile je Tag, Spalten frei konfigurierbar
   ------------------------------------------------------------------------- */

:root {
  --r-weekend:  #fdf6bd;
  --r-holiday:  #c8ecc4;
  --r-vacation: #c6e6f6;
  --r-travel:   #f3ddc4;
  --r-ink:      #1a2024;
}
html.is-dark {
  --r-weekend:  #3b3717;
  --r-holiday:  #16351a;
  --r-vacation: #12303d;
  --r-travel:   #3a2c17;
  --r-ink:      #e4ebee;
}

body.cal { padding-bottom: 40px; }

.calhead .monthnav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.calhead .monthname { font: 600 15px/1 var(--sans); min-width: 130px; text-align: center; }

.callegend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 12px;
  font: 400 12px/1 var(--mono);
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 12;
}
.callegend .lg { padding: 4px 8px; border-radius: 6px; color: var(--r-ink); }
.callegend .lg.row-weekend  { background: var(--r-weekend); }
.callegend .lg.row-holiday  { background: var(--r-holiday); }
.callegend .lg.row-vacation { background: var(--r-vacation); }
.callegend .lg.row-travel   { background: var(--r-travel); }
.callegend .totals { margin-left: auto; }
.callegend:not(:has(.lg)) { justify-content: flex-end; }
.callegend:not(:has(.lg)) .totals { margin-left: 0; }
.callegend .totals b { color: var(--ink); font-weight: 600; }
.callegend .savehint { min-width: 78px; text-align: right; opacity: 0; transition: opacity .2s ease; }
.callegend .savehint.on { opacity: 1; }

.calwrap {
  overflow: auto;
  max-height: calc(100vh - 150px);
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

table.cal {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  white-space: nowrap;
  table-layout: fixed;
}
col.g-week { width: 34px; }
col.g-wd   { width: 34px; }
col.g-date { width: 104px; }
col.g-type { width: 116px; }
table.cal th, table.cal td {
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
  background: var(--surface);
}
table.cal thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--sunk);
  font: 500 11px/1 var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 6px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Kopf verschieben, Kante ziehen, Doppelklick benennt um */
table.cal thead th[data-key] { cursor: grab; user-select: none; padding-right: 12px; }
table.cal thead th[data-key].dragging { opacity: .45; }
table.cal thead th[data-key].dropbefore { box-shadow: inset 3px 0 0 var(--accent); }
table.cal thead th[data-key].dropafter  { box-shadow: inset -3px 0 0 var(--accent); }
table.cal thead th .thlabel { display: block; overflow: hidden; text-overflow: ellipsis; }
table.cal thead th .thlabel[contenteditable="true"] {
  cursor: text;
  outline: 2px solid var(--accent);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  padding: 2px 4px;
  margin: -2px -4px;
}
table.cal thead th .grip {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 9px;
  cursor: col-resize;
  z-index: 2;
}
table.cal thead th .grip::after {
  content: "";
  position: absolute;
  top: 25%; bottom: 25%; right: 3px;
  width: 2px;
  background: var(--line);
  border-radius: 2px;
}
table.cal thead th[data-key]:hover .grip::after { background: var(--accent); }
table.cal thead th { position: sticky; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }

/* Monatstrenner in der Endlosansicht */
table.cal tr.monthsep td {
  position: sticky;
  top: 30px;
  z-index: 4;
  background: var(--sunk);
  font: 600 12px/1 var(--sans);
  letter-spacing: .04em;
  color: var(--ink);
  padding: 7px 10px;
  border-top: 2px solid var(--line);
}
table.cal tr.loadmore td {
  text-align: center;
  padding: 14px;
  font: 400 12px/1 var(--mono);
  color: var(--muted);
  background: var(--bg);
}

/* Farbtupfer vor der Auswahl, damit sichtbar ist, was die Zeile faerbt */
td.c-type { position: relative; }
td.c-type .swatch {
  position: absolute;
  left: 6px; top: 50%;
  width: 9px; height: 9px;
  margin-top: -4px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,.18);
  background: var(--surface);
  pointer-events: none;
}
tr.row-weekend  td.c-type .swatch { background: var(--r-weekend); }
tr.row-holiday  td.c-type .swatch { background: var(--r-holiday); }
tr.row-vacation td.c-type .swatch { background: var(--r-vacation); }
tr.row-travel   td.c-type .swatch { background: var(--r-travel); }
td.c-type .typesel { padding-left: 20px; }

/* linke Spalten stehen beim Scrollen */
table.cal .c-week { position: sticky; left: 0;    z-index: 5; width: 34px; text-align: center; }
table.cal .c-wd   { position: sticky; left: 34px; z-index: 5; width: 34px; text-align: center; }
table.cal .c-date { position: sticky; left: 68px; z-index: 5; width: 86px; }
table.cal thead .c-week, table.cal thead .c-wd, table.cal thead .c-date { z-index: 7; }
table.cal .c-week, table.cal .c-wd, table.cal .c-date {
  font: 400 12px/1 var(--mono);
  padding: 5px 6px;
  color: var(--muted);
  border-right-color: var(--line);
}
table.cal .c-date { color: var(--ink); line-height: 1.25; }
table.cal .c-date .holname {
  display: block;
  font: 400 9px/1.2 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
tr.row-holiday .c-date .holname { color: inherit; opacity: .75; }
table.cal .c-type { width: 108px; }

table.cal tr.weekstart td { border-top: 2px solid var(--line); }
table.cal tr.today .c-date { color: var(--accent); font-weight: 700; }
table.cal tr.today td { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--accent) 5%, transparent); }

/* Farben der Tagesarten */
table.cal tr.row-weekend  td { background: var(--r-weekend); color: var(--r-ink); }
table.cal tr.row-holiday  td { background: var(--r-holiday); color: var(--r-ink); }
table.cal tr.row-vacation td { background: var(--r-vacation); color: var(--r-ink); }
table.cal tr.row-travel   td { background: var(--r-travel); color: var(--r-ink); }

table.cal input.cell {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 5px 6px;
  min-width: 60px;
}
table.cal input.cell:focus {
  outline: 0;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: 3px;
  position: relative;
  z-index: 4;
}
table.cal input.cell.ghost { color: var(--muted); }
table.cal input.cell.ct-time,
table.cal input.cell.ct-duration { font-family: var(--mono); text-align: center; }
table.cal input.cell.saved { animation: cellsaved .8s ease; }
@keyframes cellsaved { from { background: color-mix(in srgb, var(--accent) 26%, transparent); } to { background: transparent; } }

table.cal td.calc {
  font: 500 12px/1 var(--mono);
  text-align: center;
  padding: 6px;
  color: var(--ink);
  background-image: linear-gradient(color-mix(in srgb, var(--accent) 7%, transparent), color-mix(in srgb, var(--accent) 7%, transparent));
}
table.cal td.calc.neg { color: var(--danger); }
table.cal td.c-check { text-align: center; padding: 4px; }

.typesel {
  width: 100%;
  border: 0;
  background: transparent;
  font: 400 12px/1 var(--sans);
  color: var(--muted);
  padding: 5px 4px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.typesel:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Spaltenverwaltung */
.colmgr { max-width: 100%; margin: 14px auto 40px; padding: 0 14px; }
.colmgr > summary {
  cursor: pointer;
  font: 500 13px/1 var(--sans);
  color: var(--muted);
  padding: 8px 0;
}
.colgrid { border-collapse: collapse; width: 100%; font-size: 13px; margin-top: 8px; }
.colgrid th {
  font: 500 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  text-align: left;
  padding: 6px 6px;
  border-bottom: 1px solid var(--line);
}
.colgrid td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.colgrid td.mid { text-align: center; }
.colgrid input[type="text"], .colgrid input[type="number"], .colgrid select {
  width: 100%;
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.colgrid tr.newcol td { background: var(--sunk); }
.colactions { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }

@media (max-width: 620px) {
  .calwrap { max-height: calc(100vh - 190px); }
  table.cal .c-date { font-size: 11px; }
  .callegend .totals { margin-left: 0; width: 100%; }
}

/* Endlosansicht */
body.mode-stream .calwrap { max-height: calc(100vh - 128px); }
.datejump {
  font: 400 12px/1 var(--mono);
  padding: 6px 8px;
  color: var(--ink);
}

/* --------------------------------------------------- Termine und Zähler */

/* Feiertag und Termin dürfen umbrechen, die Spalte bleibt aber schmal */
table.cal .c-date .holname,
table.cal .c-date .evname {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  overflow: hidden;
  font: 400 9px/1.25 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  word-break: break-word;
}
table.cal .c-date .holname { color: var(--muted); }
table.cal .c-date .evname  { color: var(--accent); margin-top: 1px; }
tr.row-holiday .c-date .holname { color: inherit; opacity: .8; }
tr.row-holiday .c-date .evname,
tr.row-weekend .c-date .evname,
tr.row-vacation .c-date .evname,
tr.row-travel .c-date .evname { color: inherit; opacity: .85; font-weight: 600; }
table.cal td.c-date { white-space: normal; vertical-align: top; padding-top: 5px; }

.chipbtn.tiny { font-size: 10px; padding: 5px 7px; opacity: .7; }

.evfield {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 320px;
  overflow: hidden;
}
.evfield .evico { color: var(--accent); font-size: 11px; }
.evfield .evwhen { font: 500 10px/1 var(--mono); color: var(--muted); }
.evfield .evtext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evfield.today { border-color: var(--accent); color: var(--ink); }
.evfield.today .evwhen { color: var(--accent); }

.counters { display: inline-flex; gap: 8px; align-items: center; }
.counters .cnt {
  font: 400 12px/1 var(--mono);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--surface);
}
.counters .cnt b { color: var(--accent); font-weight: 600; letter-spacing: .04em; }
.counters .cnt i {
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
  opacity: .8;
  margin-left: 3px;
}
.counters .cnt i::before { content: "/"; margin-right: 2px; opacity: .6; }

/* Terminverwaltung */
.evfind { max-width: 520px; margin-bottom: 10px; }
.monthchips { margin: 0 0 14px; }
.evform {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px;
  background: var(--sunk);
  border-radius: 10px;
  margin-bottom: 14px;
}
.evform input, .evform select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.evform .evdate { width: 92px; font-family: var(--mono); text-align: center; }
.evform .evtitle { flex: 1; min-width: 180px; }
.evform .evyear { width: 84px; font-family: var(--mono); }

table.evlist { width: 100%; border-collapse: collapse; }
table.evlist td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.evlist .evd { width: 74px; font: 400 12px/1 var(--mono); color: var(--muted); white-space: nowrap; }
table.evlist .evt { font-size: 14px; }
table.evlist .eva { text-align: right; white-space: nowrap; }
.evage {
  font: 500 10px/1 var(--mono);
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 4px;
  margin-left: 6px;
}
.evkind { font: 400 10px/1 var(--mono); color: var(--muted); margin-left: 6px; text-transform: uppercase; }

@media (max-width: 620px) {
  .evfield { max-width: 150px; }
  table.evlist .eva .chipbtn { padding: 5px 7px; }
}
