/* ==========================================================================
   Memen2Me
   Papierfarbenes Raster, Schieferschrift, Messing als einziger Akzent.
   Die Farbe gehört den Bereichen – das Interface hält sich zurück.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,800&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper:      #EEF1F5;
  --surface:    #FFFFFF;
  --surface-2:  #F7F9FB;
  --ink:        #141D26;
  --ink-2:      #4E5F70;
  --ink-3:      #8595A5;
  --line:       #D7DFE7;
  --line-soft:  #E7ECF1;
  --brass:      #A8792B;
  --brass-lift: #C89A45;
  --brass-soft: #F6EEDD;
  --ferien:     #DCE9F2;
  --warn-bg:    #FDF3E3;
  --warn-line:  #E0B871;
  --warn-ink:   #8A5B12;
  --danger:     #B23A2F;
  --ok:         #2E7D5B;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;

  --shadow-1: 0 1px 2px rgba(20,29,38,.06), 0 1px 1px rgba(20,29,38,.04);
  --shadow-2: 0 8px 28px rgba(20,29,38,.12), 0 2px 6px rgba(20,29,38,.06);
  --shadow-3: 0 24px 60px rgba(20,29,38,.22);

  --header-h: 60px;
  --sidebar-w: 268px;

  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-data: 'IBM Plex Mono', ui-monospace, monospace;

  --ease: cubic-bezier(.22,.61,.36,1);
}

[data-theme="dark"] {
  --paper:      #10161D;
  --surface:    #18212B;
  --surface-2:  #1E2833;
  --ink:        #E7EDF3;
  --ink-2:      #A8B7C5;
  --ink-3:      #6B7C8C;
  --line:       #2B3945;
  --line-soft:  #232F3A;
  --brass:      #D6A54E;
  --brass-lift: #E7BC71;
  --brass-soft: #2A2418;
  --ferien:     #1C2C39;
  --warn-bg:    #2E2617;
  --warn-line:  #6B5426;
  --warn-ink:   #E0B871;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 8px 28px rgba(0,0,0,.5);
  --shadow-3: 0 24px 60px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500; font-size: 13px;
  cursor: pointer;
  transition: background .14s var(--ease), border-color .14s var(--ease), transform .08s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary {
  background: var(--ink); border-color: var(--ink); color: var(--surface);
}
.btn-primary:hover { background: #22303E; border-color: #22303E; }
[data-theme="dark"] .btn-primary { background: var(--brass); border-color: var(--brass); color: #10161D; }
.btn-brass { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn-brass:hover { background: var(--brass-lift); border-color: var(--brass-lift); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-soft); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.btn-icon { padding: 8px; }
.btn-sm { padding: 5px 9px; font-size: 12px; }

.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px;
}
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 4px;
  font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* --------------------------------------------------------------- Felder */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }
.field .hint { font-size: 12px; color: var(--ink-3); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 18%, transparent);
}
textarea { resize: vertical; min-height: 72px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brass); }

/* --------------------------------------------------------------- Gerüst */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.brand {
  height: var(--header-h); display: flex; align-items: center; gap: 10px;
  padding: 0 18px; border-bottom: 1px solid var(--line-soft); flex: none;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 5px; flex: none;
  background: var(--ink); position: relative;
}
[data-theme="dark"] .brand-mark { background: var(--brass); }
.brand-mark::after {
  content: ''; position: absolute; inset: 6px 6px auto 6px; height: 3px;
  background: var(--brass); border-radius: 1px;
}
[data-theme="dark"] .brand-mark::after { background: #10161D; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: -.02em; }

.sidebar-scroll { overflow-y: auto; padding: 16px 14px 90px; flex: 1; min-height: 0; }
.side-group { margin-bottom: 22px; }
.side-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3); font-weight: 600; margin: 0 4px 8px;
  display: flex; align-items: center; justify-content: space-between;
}

.cal-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm); border: 0; background: transparent;
  cursor: pointer; text-align: left; color: var(--ink); font-size: 13px;
}
.cal-item:hover { background: var(--surface-2); }
.cal-item[aria-current="true"] { background: var(--brass-soft); font-weight: 600; }
.cal-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brass); flex: none; }

/* Bereichs-Legende – Farbe an, Farbe aus */
.legend-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 6px 8px; border-radius: var(--r-sm); border: 0; background: transparent;
  cursor: pointer; text-align: left; font-size: 13px; color: var(--ink);
}
.legend-item:hover { background: var(--surface-2); }
.legend-swatch {
  width: 13px; height: 13px; border-radius: 3px; flex: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.legend-item[data-off="true"] { color: var(--ink-3); }
.legend-item[data-off="true"] .legend-swatch { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--line); }
.legend-count { margin-left: auto; font-family: var(--font-data); font-size: 11px; color: var(--ink-3); }

/* --------------------------------------------------------------- Kopf */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--header-h); flex: none;
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.period {
  font-family: var(--font-display); font-size: 19px; font-weight: 600;
  letter-spacing: -.02em; white-space: nowrap;
}
.period .yr { color: var(--ink-3); font-weight: 400; }
.nav-group { display: flex; align-items: center; gap: 2px; }
.spacer { flex: 1; }

.search-wrap { position: relative; width: 240px; }
.search-wrap input { padding-left: 32px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search-results {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); max-height: 60vh; overflow-y: auto; padding: 5px;
}
.search-hit {
  display: flex; gap: 9px; align-items: baseline; padding: 8px 9px;
  border-radius: var(--r-sm); cursor: pointer;
}
.search-hit:hover, .search-hit[data-active="true"] { background: var(--surface-2); }
.search-hit .d { font-family: var(--font-data); font-size: 11px; color: var(--ink-3); flex: none; width: 84px; }

/* --------------------------------------------------------------- Bühne */
.stage { flex: 1; overflow: auto; padding: 18px; min-height: 0; }
.sheet-paper {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden;
}

/* ---- Blattkopf: welcher Zeitraum liegt hier gerade vor ---- */
.sheet-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; padding: 16px 18px 13px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--surface-2), var(--surface));
}
.sheet-head-text { min-width: 0; }
.sheet-titel {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 600; line-height: 1.1;
  letter-spacing: -.015em; display: flex; align-items: baseline; gap: 9px;
  flex-wrap: wrap;
}
.sheet-jahr {
  font-family: var(--font-data);
  font-size: 15px; font-weight: 400; color: var(--ink-3);
  letter-spacing: .02em;
}
.sheet-jahr-gross {
  font-family: var(--font-data);
  font-size: 26px; font-weight: 600; letter-spacing: .01em;
}
.sheet-kw {
  font-family: var(--font-data);
  font-size: 20px; font-weight: 600; letter-spacing: .01em;
  color: var(--brass);
}
.sheet-zusatz {
  font-size: 12.5px; color: var(--ink-2); margin-top: 3px;
}
.sheet-head-rechts { flex: none; }
.sheet-zaehler {
  font-family: var(--font-data); font-size: 11.5px;
  color: var(--ink-3); white-space: nowrap;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-soft); background: var(--surface);
}

@media (max-width: 700px) {
  .sheet-head { padding: 13px 14px 11px; gap: 10px; }
  .sheet-titel { font-size: 18px; gap: 7px; }
  .sheet-jahr-gross { font-size: 22px; }
  .sheet-kw { font-size: 17px; }
  .sheet-zusatz { font-size: 11.5px; }
  .sheet-zaehler { padding: 3px 8px; font-size: 11px; }
}

/* ---- Monat ---- */
.month-head, .month-grid { display: grid; grid-template-columns: 34px repeat(7, 1fr); }
.month-head { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.month-head div {
  padding: 9px 8px; font-size: 11px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-2);
}
.month-head .kw-h { font-family: var(--font-data); color: var(--ink-3); text-align: center; padding-inline: 0; }

.month-grid { }
.kw-cell {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2); display: flex; align-items: flex-start; justify-content: center;
  padding-top: 8px; font-family: var(--font-data); font-size: 11px; color: var(--ink-3);
}
.day {
  position: relative; min-height: 116px; padding: 6px 7px 7px 7px;
  border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  overflow: hidden; cursor: pointer;
  transition: background .12s var(--ease);
}
.day:nth-child(8n) { border-right: 0; }
.day:hover { background: var(--surface-2); }
.day[data-out="true"] { background: color-mix(in srgb, var(--paper) 60%, var(--surface)); }
.day[data-out="true"] .day-num { color: var(--ink-3); }
.day[data-ferien="true"]::before {
  content: ''; position: absolute; inset: 0; background: var(--ferien); opacity: .55; pointer-events: none;
}
.day > * { position: relative; }

.day-top { display: flex; align-items: center; gap: 5px; margin-bottom: 5px; }
.day-num {
  font-family: var(--font-display); font-size: 14px; font-weight: 600;
  min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
}
.day[data-today="true"] .day-num { background: var(--brass); color: #fff; }
.day-flag {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0;
  color: var(--brass);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.day-flag[data-kind="ferien"] { color: var(--ink-3); text-transform: none; font-weight: 500; }

.chips { display: flex; flex-direction: column; gap: 3px; }
.chip {
  display: flex; align-items: baseline; gap: 5px;
  font-size: 11.5px; line-height: 1.3; padding: 2.5px 6px;
  border-radius: 4px; border-left: 3px solid var(--c, var(--brass));
  background: color-mix(in srgb, var(--c, var(--brass)) 13%, var(--surface));
  color: var(--ink);
  overflow: hidden; white-space: nowrap;
}
.chip .t { font-family: var(--font-data); font-size: 10.5px; color: var(--ink-2); flex: none; }
.chip .n { overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.chip[data-cancelled="true"] { opacity: .55; }
.chip[data-cancelled="true"] .n { text-decoration: line-through; }
.chip[data-span] {
  background: var(--c, var(--brass)); color: #fff; border-left-color: transparent;
  font-weight: 600;
}
.chip[data-span] .t { color: rgba(255,255,255,.8); }
.chip-more { font-size: 11px; color: var(--ink-3); padding-left: 6px; font-weight: 500; }

/* ---- Woche ---- */
.week-grid { display: grid; grid-template-columns: 1fr; }
.week-row {
  display: grid; grid-template-columns: 104px 1fr;
  border-bottom: 1px solid var(--line-soft); min-height: 78px;
}
.week-row:last-child { border-bottom: 0; }
.week-row[data-today="true"] { background: color-mix(in srgb, var(--brass) 6%, var(--surface)); }
.week-row[data-ferien="true"] .week-date { background: var(--ferien); }
.week-date {
  padding: 12px 12px 12px 14px; border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.week-date .wd { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.week-date .dn { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.1; }
.week-row[data-today="true"] .dn { color: var(--brass); }
.week-date .fl {
  font-size: 10.5px; color: var(--brass); font-weight: 600;
  overflow-wrap: anywhere; line-height: 1.25; padding-right: 4px;
}
.week-events { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.wevent {
  display: grid; grid-template-columns: 88px 1fr auto; gap: 12px; align-items: baseline;
  padding: 8px 11px; border-radius: var(--r-sm); cursor: pointer;
  border-left: 4px solid var(--c, var(--brass));
  background: color-mix(in srgb, var(--c, var(--brass)) 10%, var(--surface));
  transition: transform .1s var(--ease), box-shadow .1s var(--ease);
}
.wevent:hover { transform: translateX(2px); box-shadow: var(--shadow-1); }
.wevent .t { font-family: var(--font-data); font-size: 12px; color: var(--ink-2); }
.wevent .n { font-weight: 600; font-size: 14px; }
.wevent .m { font-size: 12px; color: var(--ink-3); }
.wevent[data-cancelled="true"] .n { text-decoration: line-through; color: var(--ink-3); }
.badge-off {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  padding: 1px 5px; border-radius: 3px; margin-left: 7px;
}
.week-empty { color: var(--ink-3); font-size: 13px; padding: 8px 11px; }

/* ---- Jahr ---- */
.year-wrap { overflow-x: auto; padding: 4px; }
.year-grid { display: grid; grid-template-columns: repeat(12, minmax(94px, 1fr)); gap: 1px; background: var(--line-soft); min-width: 1140px; }
.year-col { background: var(--surface); }
.year-col h4 {
  font-size: 12px; text-align: center; padding: 8px 0; background: var(--surface-2);
  border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .07em;
}
.ycell {
  display: grid; grid-template-columns: 15px 20px 1fr; align-items: center; gap: 4px;
  height: 20px; padding: 0 5px 0 0; font-size: 11px; cursor: pointer;
  border-bottom: 1px solid var(--line-soft); position: relative;
}
.ycell:hover { background: var(--surface-2); }
.ycell[data-empty="true"] { visibility: hidden; }
.ycell[data-we="true"] { background: color-mix(in srgb, var(--paper) 70%, var(--surface)); }
.ycell[data-ferien="true"] { background: var(--ferien); }
.ycell[data-holiday="true"] { background: var(--brass-soft); }
.ycell[data-today="true"] { box-shadow: inset 0 0 0 1.5px var(--brass); }
.ycell .n { font-family: var(--font-data); font-size: 10px; color: var(--ink-3); text-align: right; }
.ycell .w { font-size: 9px; color: var(--ink-3); text-transform: uppercase; }
.ycell .ticks { display: flex; gap: 2px; height: 8px; align-items: center; }
.ycell .ticks i { width: 6px; height: 6px; border-radius: 2px; display: block; }
.ycell .ticks .rest { font-family: var(--font-data); font-size: 9px; color: var(--ink-3); }

/* ---- Liste / Agenda ---- */
.agenda { display: flex; flex-direction: column; }
.agenda-day { border-bottom: 1px solid var(--line-soft); padding: 12px 16px; }
.agenda-day:last-child { border-bottom: 0; }
.agenda-head {
  display: flex; align-items: baseline; gap: 9px; margin-bottom: 8px;
  position: sticky; top: 0; background: var(--surface); padding: 2px 0; z-index: 2;
}
.agenda-head .dn { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.agenda-head .wd { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; }
.agenda-head[data-today="true"] .dn { color: var(--brass); }
.agenda-head .fl { font-size: 11px; color: var(--brass); margin-left: auto; }

/* --------------------------------------------------------------- Modal */
.scrim {
  position: fixed; inset: 0; background: rgba(15,22,30,.42);
  backdrop-filter: blur(2px); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .16s var(--ease);
}
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  width: min(560px, 100%); max-height: min(86dvh, 900px);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop .2s var(--ease);
}
.modal.wide { width: min(880px, 100%); }
.modal-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft); flex: none;
}
.modal-head h3 { font-size: 16px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; gap: 9px; justify-content: flex-end; padding: 14px 18px;
  border-top: 1px solid var(--line-soft); background: var(--surface-2); flex: none;
}
.modal-foot .left { margin-right: auto; }

@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985) } }
@keyframes sheet-up { from { transform: translateY(100%) } }

/* --------------------------------------------------------------- Toast */
.toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-2);
  animation: pop .18s var(--ease); display: flex; align-items: center; gap: 9px;
  pointer-events: auto; max-width: 92vw;
}
.toast[data-kind="error"] { background: var(--danger); }
.toast[data-kind="ok"] { background: var(--ok); }

/* --------------------------------------------------------- Ladeanzeigen */
#topProgress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--brass), var(--brass-lift));
  z-index: 500; transition: width .28s var(--ease), opacity .3s var(--ease);
  box-shadow: 0 0 8px color-mix(in srgb, var(--brass) 60%, transparent);
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.skeleton {
  background: linear-gradient(100deg, var(--line-soft) 30%, var(--surface-2) 50%, var(--line-soft) 70%);
  background-size: 240% 100%; animation: shimmer 1.3s infinite linear;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -240% 0 } }
.sk-grid { display: grid; grid-template-columns: 34px repeat(7,1fr); }
.sk-grid .skeleton { height: 116px; margin: 1px; }

.progress-ring { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; background: var(--brass); width: 0; transition: width .25s var(--ease); }

/* ------------------------------------------------------------- Diverses */
.empty {
  padding: 56px 24px; text-align: center; color: var(--ink-2);
}
.empty h3 { font-size: 17px; margin-bottom: 6px; }
.empty p { margin: 0 0 16px; color: var(--ink-3); }

.card {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  padding: 14px; margin-bottom: 10px;
}
.card-row { display: flex; align-items: center; gap: 12px; }
.mono { font-family: var(--font-data); font-size: 12px; }
.tokenbox {
  display: flex; gap: 6px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 7px 10px; font-family: var(--font-data); font-size: 12px;
  overflow-x: auto; white-space: nowrap;
}
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink-2);
}
.pick {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px;
  border: 1px solid var(--line-soft); border-radius: 999px; cursor: pointer; font-size: 13px;
  background: transparent; color: var(--ink-3);
  opacity: .62; transition: all .14s var(--ease);
}
.pick:hover { opacity: .85; border-color: var(--line); }
.pick[aria-pressed="true"] {
  opacity: 1; color: var(--ink);
  border-color: var(--c, var(--brass));
  background: color-mix(in srgb, var(--c, var(--brass)) 22%, var(--surface));
  font-weight: 600;
}
.pick .sw {
  width: 11px; height: 11px; border-radius: 3px;
  background: var(--c, var(--brass)); opacity: .5;
}
.pick[aria-pressed="true"] .sw {
  opacity: 1;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--brass)) 30%, transparent);
}
.picks { display: flex; flex-wrap: wrap; gap: 7px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); }
table.tbl tr:last-child td { border-bottom: 0; }

/* --------------------------------------------------------------- Auth */
.gate {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--brass) 10%, transparent), transparent 60%),
    var(--paper);
}
.gate-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 30px 28px;
}
.gate-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 4px; }
.gate-card .claim { color: var(--ink-3); margin: 0 0 22px; font-size: 13px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.gate-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--ink-2); }

/* --------------------------------------------------------------- Fehler */
.errpage { min-height: 100dvh; display: grid; place-items: center; padding: 24px; text-align: center; }
.errpage .code { font-family: var(--font-data); font-size: 13px; color: var(--brass); letter-spacing: .12em; }
.errpage h1 { font-size: 28px; margin: 8px 0 10px; letter-spacing: -.03em; }
.errpage p { color: var(--ink-2); max-width: 42ch; margin: 0 auto 20px; }

/* --------------------------------------------------------------- Mobil */
.mobile-only { display: none; }
.fab {
  position: fixed; right: 16px; bottom: calc(66px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 50%; border: 0;
  background: var(--brass); color: #fff; box-shadow: var(--shadow-2);
  display: none; align-items: center; justify-content: center; z-index: 90; cursor: pointer;
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--line);
  display: none; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; padding: 9px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; color: var(--ink-3); cursor: pointer; font-weight: 500;
}
.tabbar button[aria-selected="true"] { color: var(--brass); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 84vw; max-width: 320px; z-index: 150;
    transform: translateX(-100%); transition: transform .24s var(--ease);
    box-shadow: var(--shadow-3);
  }
  .sidebar[data-open="true"] { transform: none; }
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none !important; }
  .tabbar { display: flex; }
  .fab { display: flex; }
  .stage { padding: 10px 10px calc(78px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 12px; gap: 8px; }
  .period { font-size: 16px; }
  .search-wrap { position: fixed; left: 10px; right: 10px; top: 8px; width: auto; z-index: 160; display: none; }
  .search-wrap[data-open="true"] { display: block; }

  /* Monatsraster mobil: kompakt, Termine als Punkte, Details im Sheet.
     Die KW-Spalte bleibt – nur sehr schmal. Wer in Kalenderwochen plant,
     braucht sie auf dem Handy genauso wie am Rechner. */
  .month-head, .month-grid { grid-template-columns: 22px repeat(7, 1fr); }
  .month-head .kw-h { font-size: 9px; letter-spacing: .02em; }
  .kw-cell { font-size: 10px; padding: 0; }
  .day { min-height: 62px; padding: 4px 3px 4px 5px; }

  .chips { gap: 2px; }
  .chip { font-size: 0; padding: 0; height: 4px; border-radius: 2px; border-left: 0;
          background: var(--c, var(--brass)); }
  .chip .t, .chip .n { display: none; }
  .chip-more { font-size: 9px; padding: 0 2px; }
  .day-flag { display: none; }
  .week-row { grid-template-columns: 76px 1fr; }
  .week-date { padding: 10px; }
  .week-date .dn { font-size: 20px; }
  .wevent { grid-template-columns: 62px 1fr; }
  .wevent .m { grid-column: 2; }
  .year-grid { grid-template-columns: repeat(3, minmax(94px,1fr)); min-width: 0; }

  /* Bottom-Sheet statt Dialog */
  .scrim { align-items: flex-end; padding: 0; }
  .modal {
    width: 100%; max-height: 92dvh; border-radius: var(--r-lg) var(--r-lg) 0 0;
    animation: sheet-up .26s var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-head::before {
    content: ''; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 2px; background: var(--line);
  }
  .modal-head { position: relative; padding-top: 20px; }
}

@media print {
  .sidebar, .topbar, .tabbar, .fab { display: none !important; }
  .stage { padding: 0; overflow: visible; }
  /* Der Blattkopf bleibt: ohne Topbar ist er die einzige Zeitangabe auf dem Papier. */
  .sheet-head { background: none; border-bottom: 1px solid #999; }
  .sheet-zaehler { border: 0; padding: 0; }
}

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

/* ══════════════════════════════════════════════════════════════════════
   Ergänzungen: Instanzverwaltung, Avatare, Startseite, Terminansicht
   Basisregeln zuerst, alle Bildschirmanpassungen gesammelt am Ende.
   ══════════════════════════════════════════════════════════════════════ */

/* Gedämpfter Text – wird überall für Nebeninformationen benutzt */
.muted { color: var(--ink-3); }
.klein { font-size: 12px; }
p.muted { line-height: 1.5; }

/* ------------------------------------------------------ Listen & Zeilen */
.liste { display: flex; flex-direction: column; gap: 2px; }
.zeile {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 12px; border-radius: var(--r);
  border: 1px solid var(--line-soft);
}
.zeile + .zeile { margin-top: -1px; }
.zeile:hover { background: var(--surface-2); }
.zeile-text { min-width: 0; text-align: left; flex: 1; }
.zeile-text strong { display: block; overflow-wrap: anywhere; }
.zeile-klick {
  width: 100%; background: none; font: inherit; color: inherit;
  cursor: pointer; text-align: left;
}
.zeile-klick:hover { border-color: var(--line); }
.aktionen {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin: 8px 0 14px;
}
.aktionen select { max-width: 150px; }

/* ------------------------------------------------------- Kennzahlen */
.kennzahlen {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-bottom: 14px;
}
.kennzahl {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.kennzahl strong { font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kennzahl span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kennzahl.achtung { border-color: var(--brass); background: var(--brass-soft); }
.kennzahl.achtung strong { color: var(--brass); }

/* ------------------------------------------------------------ Pillen */
.pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--ink-2);
}
.pill-brass { background: var(--brass-soft); border-color: var(--brass); color: var(--brass); }
.pill-warn  { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }

/* ----------------------------------------------------------- Avatare */
.avatar {
  border-radius: 50%; flex: none;
  background: var(--surface-2); object-fit: cover; display: block;
}

/* --------------------------------------------------- Farbige Tags */
.tag-farbe {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; line-height: 1; padding: 5px 10px 5px 8px;
  border-radius: 999px; white-space: nowrap;
  color: color-mix(in srgb, var(--c, var(--ink-3)) 72%, var(--ink));
  background: color-mix(in srgb, var(--c, var(--ink-3)) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c, var(--ink-3)) 34%, transparent);
}
.tag-punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.tag-icon { display: block; color: currentColor; flex: none; }
.tag-neutral { color: var(--ink-2); background: var(--surface-2); border-color: var(--line-soft); }
.tag-warn { color: var(--warn-ink); background: var(--warn-bg); border-color: var(--warn-line); }

/* ------------------------------------------------- Termin-Ansicht */
.ansicht { display: flex; flex-direction: column; gap: 2px; }
.ansicht-kopf {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 0 0 16px 14px; margin-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
  border-left: 4px solid var(--c, var(--ink-3));
  border-radius: 2px;
}
.ansicht-titel {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 600; line-height: 1.25;
  overflow-wrap: anywhere;
}
.ansicht-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.ansicht-zeile {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 7px 0; font-size: 14px;
}
.ansicht-zeile > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.ansicht-icon { color: var(--ink-3); flex: none; display: block; margin-top: 1px; }
.ansicht-notiz {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 10px; padding: 12px;
  background: var(--surface-2); border-radius: var(--r);
  font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere;
}

/* --------------------------------- Weitere Bereiche im Formular */
.ziele { display: flex; flex-wrap: wrap; gap: 7px; }

/* Ausgangszustand: sichtbar, aber merklich zurückgenommen. Der Unterschied
   zwischen an und aus muss auf hellem wie dunklem Grund sofort ins Auge
   fallen – ein zarter Farbstich reicht dafür nicht. */
.ziel {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 13px; line-height: 1;
  padding: 9px 14px 9px 11px; border-radius: 999px;
  border: 1px solid var(--line-soft); background: transparent;
  color: var(--ink-3); cursor: pointer; user-select: none;
  opacity: .62;
  transition: opacity .12s, border-color .12s, background .12s, color .12s;
}
.ziel:hover { opacity: .85; border-color: var(--line); }
.ziel:active { transform: scale(.97); }
.ziel input { margin: 0; }
.ziel:has(input:checked) {
  opacity: 1; border-color: var(--brass);
  background: var(--brass-soft); color: var(--brass);
}

.ziel-farbe .tag-punkt {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--c); flex: none; opacity: .5;
}
.ziel-farbe[aria-pressed="true"] {
  opacity: 1;
  color: var(--ink);
  background: color-mix(in srgb, var(--c) 22%, var(--surface));
  border-color: var(--c);
  font-weight: 600;
}
.ziel-farbe[aria-pressed="true"] .tag-punkt {
  opacity: 1;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent);
}

/* -------------------------------------------------------- Startseite */
.start { padding: 22px 24px 28px; }
.start-kopf {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 22px;
}
.start-kopf h2 { font-size: 22px; overflow-wrap: anywhere; }
.start-titel {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); margin: 22px 0 10px;
}
.start-titel:first-of-type { margin-top: 0; }
.start-kacheln {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.start-kachel {
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 13px 14px;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .12s, transform .12s;
}
.start-kachel:hover { border-color: var(--brass); transform: translateY(-1px); }
.start-kachel-kopf { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.start-kachel-kopf strong { font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.start-swatches { display: flex; gap: 4px; }
.start-swatch { width: 16px; height: 5px; border-radius: 3px; }
.start-termine { display: flex; flex-direction: column; }
.start-tag {
  display: flex; align-items: baseline; gap: 8px;
  margin: 16px 0 6px; font-size: 13px; color: var(--ink-2);
}
.start-tag:first-child { margin-top: 0; }
.start-wd {
  font-family: var(--font-data); font-size: 11px;
  color: var(--ink-3); text-transform: uppercase;
}
.start-termin {
  display: flex; align-items: baseline; gap: 12px;
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: none; border: 0; border-left: 3px solid var(--c);
  padding: 8px 10px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.start-termin:hover { background: var(--surface-2); }
.start-termin[data-cancelled="true"] .start-name { text-decoration: line-through; opacity: .6; }
.start-zeit {
  font-family: var(--font-data); font-size: 12px; color: var(--ink-3);
  min-width: 62px; flex: none;
}
.start-name { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.start-herkunft { flex: none; }

/* --------------------------------------------------------- Kleinkram */
.fab[hidden] { display: none; }
.modal-foot .btn[hidden] { display: none; }

/* ══════════════════════════════════════════════════════════════════════
   Kleine Bildschirme
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .start { padding: 16px 14px 24px; }
  .start-kacheln { grid-template-columns: 1fr; }
  .start-herkunft { display: none; }
  .start-kopf h2 { font-size: 19px; }
  .start-zeit { min-width: 54px; font-size: 11.5px; }
  .start-termin { gap: 8px; padding: 9px 8px; }

  .kennzahlen { grid-template-columns: repeat(2, 1fr); }
  .kennzahl strong { font-size: 18px; }

  /* Zeilen brechen um, Aktionen rutschen darunter und werden gut treffbar */
  .zeile { flex-wrap: wrap; gap: 8px; padding: 12px; }
  .zeile-text { flex: 1 1 100%; }
  .zeile > .btn, .zeile > .aktionen { flex: 1 1 auto; }
  .zeile .aktionen { margin: 0; width: 100%; }
  .zeile .aktionen select { max-width: none; flex: 1; }

  .aktionen { gap: 8px; }
  .aktionen .btn { flex: 1 1 auto; min-height: 40px; }

  .ansicht-kopf { padding-left: 12px; }
  .ansicht-titel { font-size: 17px; }
  .ansicht-zeile { padding: 8px 0; }

  .ziel { padding: 9px 13px; }          /* größere Trefferfläche */
  .tag-farbe { padding: 6px 11px 6px 9px; }
}

/* ---- Kopf der Freigabeansicht ---- */
/* Ohne flex-Angabe: auf dem Rechner verhält sich der Kopf wie zuvor,
   die Breitenvorgabe kommt erst in der Mobilregel weiter unten. */
.share-kopf { min-width: 0; overflow: hidden; }
.share-titel { font-weight: 700; font-size: 14px; line-height: 1.25; }
.share-unter { font-size: 11.5px; color: var(--ink-3); line-height: 1.3; }

/* Auf dem Handy bekommt der Name eine eigene Zeile. Zwischen Blätterpfeilen
   und Export blieben ihm sonst gut 170 Pixel – zu wenig für einen Namen, den
   jemand "Terminübersicht Altonas bunter Haufen" genannt hat. */
@media (max-width: 900px) {
  .topbar-share {
    flex-wrap: wrap; height: auto; padding-block: 8px; row-gap: 6px;
  }
  /* Zeichen und Name bilden zusammen die erste Zeile, die Bedienung folgt
     darunter – sonst steht das Zeichen allein bei den Knöpfen. */
  .topbar-share .brand-mark { order: -2; margin-right: 8px; }
  /* Breit genug, dass daneben nur noch das Zeichen passt – alles Weitere
     rutscht damit zuverlässig in die zweite Zeile. */
  .topbar-share .share-kopf {
    flex: 1 1 calc(100% - 46px); order: -1; min-width: 0;
  }
  .topbar-share .spacer { display: none; }
  .share-titel { font-size: 15px; }
  /* Versetzt gestartet – zwei gleichzeitig wandernde Zeilen sind unruhig. */
  .share-unter .lauf-spur { animation-delay: 1.2s; }
}

/* ---- Laufschrift für Titel, die nicht in ihre Zeile passen ---- */
.lauf { overflow: hidden; display: block; min-width: 0; }
.lauf-spur { display: inline-block; white-space: nowrap; will-change: transform; }
/* Passt der Text: stehen lassen und, falls nötig, abschneiden. */
.lauf[data-laeuft="false"] .lauf-spur {
  display: block; overflow: hidden; text-overflow: ellipsis;
}
.lauf[data-laeuft="true"] .lauf-spur {
  animation: lauf var(--dauer, 9s) linear infinite;
}
/* Steht an beiden Enden still, damit man Anfang und Ende lesen kann. */
@keyframes lauf {
  0%, 18%   { transform: translateX(0); }
  82%, 100% { transform: translateX(var(--weg, 0)); }
}
/* Beim Berühren anhalten – wer liest, will nicht verfolgen. */
.lauf:hover .lauf-spur, .lauf:active .lauf-spur { animation-play-state: paused; }

/* Wer Bewegung abgestellt hat, bekommt sie auch hier nicht. Ohne diese Regel
   würde die allgemeine Verkürzung auf 0,01 ms die Endlosschleife flackern
   lassen – schlimmer als der stehende, abgeschnittene Text. */
@media (prefers-reduced-motion: reduce) {
  .lauf .lauf-spur {
    animation: none !important;
    display: block; overflow: hidden; text-overflow: ellipsis;
  }
}

@media (max-width: 420px) {
  .kennzahlen { grid-template-columns: 1fr 1fr; gap: 6px; }
  .sheet-head { padding: 11px 12px 9px; }
  .sheet-titel { font-size: 17px; }
  .share-titel { font-size: 13px; }
  .start-kachel { padding: 12px; }
  .ziele, .ansicht-tags { gap: 5px; }
}
