/* Kalender, Kontakte, Einladungen - nutzt die Farb-Variablen aus app.css (hell/dunkel). */

/* ---------- Umschalter und Bereiche ---------- */
.mod-switch { display: flex; gap: 2px; margin: 0 4px 12px; padding: 3px; background: var(--surface-3); border-radius: 12px; }
.mod-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 6px; border: 0;
  border-radius: 9px; background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 500; min-width: 0;
}
.mod-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mod-btn .icon { width: 17px; height: 17px; }
.mod-btn:hover { color: var(--text); }
.mod-btn.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.mod-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 1200px) { .mod-btn span { display: none; } }
@media (max-width: 899px) { .mod-btn span { display: inline; } }

.module-pane, .pim-side { display: none; }
.module-pane { flex: 1; min-width: 0; min-height: 0; flex-direction: column; background: var(--surface); border-radius: var(--radius); position: relative; overflow: hidden; }
.pim-side { flex: 1; min-height: 0; flex-direction: column; }
.app[data-module="calendar"] .module-pane[data-for="calendar"], .app[data-module="contacts"] .module-pane[data-for="contacts"],
.app[data-module="calendar"] .pim-side[data-for="calendar"], .app[data-module="contacts"] .pim-side[data-for="contacts"] { display: flex; }
.app[data-module="calendar"] .list-pane, .app[data-module="contacts"] .list-pane,
.app[data-module="calendar"] .reader-pane, .app[data-module="contacts"] .reader-pane,
.app[data-module="calendar"] .sidebar > .compose-btn, .app[data-module="contacts"] .sidebar > .compose-btn,
.app[data-module="calendar"] .sidebar > .folders-head, .app[data-module="contacts"] .sidebar > .folders-head,
.app[data-module="calendar"] .sidebar > .folders, .app[data-module="contacts"] .sidebar > .folders,
.app[data-module="calendar"] .sidebar > .quota, .app[data-module="contacts"] .sidebar > .quota,
.app[data-module="calendar"] > .fab, .app[data-module="contacts"] > .fab { display: none !important; }
.app[data-module="calendar"] .topbar .search, .app[data-module="contacts"] .topbar .search { visibility: hidden; }
@media (min-width: 900px) {
  .app[data-pane="bottom"] .module-pane { grid-column: 2; grid-row: 1 / span 2; }
  .pim-fab { display: none !important; }
}
.pim-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.pim-sub { padding: 10px 16px 2px; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.pim-empty { padding: 8px 16px; }
.pim-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pim-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border); min-height: 52px; flex-wrap: wrap; }
.pim-title { margin: 0 4px; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pim-status { white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.seg-btn { border: 0; background: var(--surface); padding: 0 12px; height: 30px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { background: var(--surface-2); }
.seg-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.danger-btn { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.primary.danger-btn:hover { background: var(--danger); filter: brightness(.95); }
.danger-text { color: var(--danger); }
.settings-form input[type=time], .settings-form input[type=url], .settings-form input[type=tel], .settings-form input[type=search] {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); padding: 8px 10px; font-size: 14px;
}
.settings-form input.narrow { width: 80px; }
.settings-form label > span:first-child { color: var(--text-2); }

/* ---------- Kalender: Seitenleiste ---------- */
.cal-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px 0 14px; border-radius: 0 17px 17px 0; margin-right: 4px; cursor: pointer; font-size: 14px; position: relative; }
.cal-item:hover { background: var(--surface-3); }
.cal-item input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--c, var(--accent)); flex: none; cursor: pointer; }
.cal-item .folder-more { display: none; }
.cal-item:hover .folder-more, .cal-item:focus-within .folder-more { display: inline-flex; }
.cal-lock, .cal-def { color: var(--text-3); }
.cal-def { width: 13px; height: 13px; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; display: inline-block; }

/* ---------- Kalender: Termine ---------- */
.cal-main { position: relative; }
.cal-body-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cal-ev {
  --c: var(--accent);
  background: var(--accent-soft); background: color-mix(in srgb, var(--c) 18%, var(--surface));
  border: 0; border-left: 3px solid var(--c); color: var(--text); border-radius: 4px; text-align: left; cursor: pointer; overflow: hidden;
}
.cal-ev:hover { background: color-mix(in srgb, var(--c) 28%, var(--surface)); }
.cal-ev:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-ev.tentative { background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--c) 12%, transparent) 6px 12px); }
.cal-ev.declined, .cal-ev.cancelled { opacity: .55; }
.cal-ev.declined .cal-ev-title, .cal-ev.cancelled .cal-ev-title, .cal-ev.declined .cal-chip-title, .cal-ev.cancelled .cal-chip-title,
.cal-ev.cancelled .cal-ag-title { text-decoration: line-through; }
.cal-chip { display: flex; align-items: center; gap: 4px; width: 100%; padding: 1px 6px; font-size: 12px; line-height: 18px; min-height: 20px; white-space: nowrap; }
.cal-chip.allday { background: var(--c); background: color-mix(in srgb, var(--c) 75%, var(--surface)); color: #fff; border-left-color: transparent; }
:root[data-theme="dark"] .cal-chip.allday { color: #0f1220; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cal-chip.allday { color: #0f1220; } }
.cal-chip-time { color: var(--text-2); font-variant-numeric: tabular-nums; flex: none; }
.cal-chip-title { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Tag/Woche */
.cal-grid { --days: 7; --hour: 48px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cal-head, .cal-allday { display: grid; grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); border-bottom: 1px solid var(--border); padding-right: var(--sbw, 0); }
.cal-gutter { display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; font-size: 11px; }
.cal-dayhead { border: 0; background: none; cursor: pointer; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; color: var(--text-2); border-left: 1px solid var(--border); }
.cal-dayhead:hover { background: var(--surface-2); }
.cal-wd { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.cal-dn { font-size: 20px; line-height: 28px; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.cal-dayhead.today .cal-dn { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.cal-dayhead.today .cal-wd { color: var(--accent); font-weight: 600; }
.cal-allday { max-height: 96px; overflow-y: auto; }
.cal-allcell { border-left: 1px solid var(--border); padding: 2px; min-height: 26px; display: flex; flex-direction: column; gap: 2px; cursor: copy; }
.cal-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.cal-inner { display: grid; grid-template-columns: 56px minmax(0, 1fr); position: relative; }
.cal-hours { position: relative; }
.cal-hour { height: var(--hour); position: relative; font-size: 11px; color: var(--text-3); text-align: right; padding-right: 6px; }
.cal-hour:not(:empty) { transform: translateY(-7px); }
.cal-cols { display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr)); }
.cal-col {
  position: relative; height: calc(var(--hour) * 24); border-left: 1px solid var(--border); cursor: copy;
  background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px), linear-gradient(to bottom, transparent calc(var(--hour) / 2), color-mix(in srgb, var(--border) 45%, transparent) calc(var(--hour) / 2), color-mix(in srgb, var(--border) 45%, transparent) calc(var(--hour) / 2 + 1px), transparent calc(var(--hour) / 2 + 1px));
  background-size: 100% var(--hour);
}
.cal-col.today { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.cal-timed { position: absolute; padding: 2px 5px; font-size: 12px; line-height: 1.3; box-shadow: 0 0 0 1px var(--surface); user-select: none; z-index: 1; }
.cal-timed.short .cal-ev-time, .cal-timed.short .cal-ev-loc { display: none; }
.cal-timed.short .cal-ev-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-timed.dragging { opacity: .85; z-index: 5; box-shadow: var(--shadow); cursor: grabbing; }
.cal-ev-title { font-weight: 600; overflow-wrap: anywhere; }
.cal-ev-time, .cal-ev-loc { color: var(--text-2); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* Monat */
.cal-month { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: auto repeat(6, minmax(0, 1fr)); overflow: auto; }
.cal-mhead { text-align: center; font-size: 11.5px; text-transform: uppercase; color: var(--text-2); padding: 6px 0; border-bottom: 1px solid var(--border); }
.cal-mcell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 2px 3px; min-height: 92px; display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: copy; overflow: hidden; }
.cal-mcell:nth-child(7n + 7) { border-right: 0; }
.cal-mcell.other { background: var(--surface-2); }
.cal-mcell.other .cal-mday { color: var(--text-3); }
.cal-mday { align-self: flex-start; border: 0; background: none; cursor: pointer; font-size: 12.5px; width: 24px; height: 24px; border-radius: 50%; color: var(--text); flex: none; }
.cal-mday:hover { background: var(--surface-3); }
.cal-mcell.today .cal-mday { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.cal-month .cal-chip:not(.allday) { background: transparent; border-left: 0; padding-left: 2px; }
.cal-month .cal-chip:not(.allday)::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.cal-month .cal-chip:not(.allday):hover { background: var(--surface-2); }
.cal-more { align-self: flex-start; font-size: 12px; padding: 0 4px; }

/* Liste */
.cal-agenda { flex: 1; overflow-y: auto; padding: 4px 16px 24px; }
.cal-ag-day { font-size: 13.5px; margin: 16px 0 6px; color: var(--text-2); font-weight: 600; }
.cal-ag-day.today { color: var(--accent); }
.cal-ag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cal-ag-item { display: grid; grid-template-columns: 12px 120px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; font-size: 14px; }
.cal-ag-time { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 13px; }
.cal-ag-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ag-cal { white-space: nowrap; }

/* Details und Dialog */
.ev-detail { display: flex; flex-direction: column; gap: 10px; }
.ev-calbar { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.ev-calbar .tag { display: inline-flex; align-items: center; }
.ev-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.ev-row > .icon { margin-top: 2px; color: var(--text-3); }
.ev-row > div { min-width: 0; overflow-wrap: anywhere; }
.ev-att { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.ev-att li, .invite-attendees li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ps { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; display: inline-block; }
.ps-accepted { background: #2b8a3e; }
.ps-tentative { background: var(--flag); }
.ps-declined { background: var(--danger); }
.ps-delegated { background: var(--accent); }
.ev-desc { margin-top: 4px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: 13.5px; max-height: 300px; overflow: auto; }
.ev-rsvp { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--border); }
.ev-rsvp > span { margin-right: auto; }
.ev-actions { gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.ev-modal { max-width: 720px; }
.ev-form { gap: 12px; }
.ev-form .ev-title { font-size: 18px; padding: 10px 12px; }
.ev-when { display: flex; flex-direction: column; gap: 8px; }
.ev-times { display: grid; grid-template-columns: auto minmax(0, 150px) minmax(0, 110px) 1fr; gap: 6px 8px; align-items: center; }
.ev-times .ev-time-label { font-size: 13px; color: var(--text-2); }
.ev-times select { grid-column: 4; grid-row: 1 / span 2; align-self: center; max-width: 220px; }
.ev-repeat { display: flex; flex-direction: column; gap: 8px; }
.repeat-box { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.repeat-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.repeat-line input, .repeat-line select { background: var(--surface) !important; }
.wd-row { display: flex; gap: 4px; flex-wrap: wrap; }
.wd-box { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 4px !important; padding: 4px 8px; border: 1px solid var(--border); border-radius: 14px; cursor: pointer; background: var(--surface); }
.wd-box input { margin: 0; }
.ev-attendees { display: flex; flex-direction: column; gap: 6px; }
.ev-attendees .field { border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; background: var(--surface-2); }
.ev-attendees .field-label { min-width: 0; }

/* ---------- Einladung im Lesebereich ---------- */
.reader-extras:empty { display: none; }
.invite-card { margin: 8px 24px; padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.invite-head { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; flex-wrap: wrap; }
.invite-head .tag { text-transform: none; letter-spacing: 0; }
.invite-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.invite-title.cancelled { text-decoration: line-through; color: var(--text-2); }
.invite-row { display: flex; align-items: flex-start; gap: 8px; color: var(--text); overflow-wrap: anywhere; }
.invite-row .icon { margin-top: 2px; color: var(--text-3); }
.invite-attendees summary { cursor: pointer; color: var(--text-2); }
.invite-attendees ul { list-style: none; margin: 6px 0 0; padding: 0 0 0 22px; display: flex; flex-direction: column; gap: 3px; }
.invite-note { margin: 2px 0; color: var(--text-2); }
.invite-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.invite-actions select { height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 0 8px; max-width: 200px; }
.invite-status { margin-left: 4px; }

/* ---------- Kontakte ---------- */
.ab-main { flex-direction: row; }
.ab-listcol { width: 360px; flex: none; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.ab-searchbar { display: flex; align-items: center; gap: 6px; margin: 8px 10px; padding: 0 10px; height: 36px; border-radius: 18px; background: var(--surface-3); color: var(--text-2); }
.ab-search { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; height: 100%; font-size: 14px; }
.ab-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.ab-list { list-style: none; margin: 0; padding: 0 0 16px; }
.ab-letter { padding: 8px 16px 2px; font-size: 12px; font-weight: 700; color: var(--accent); }
.ab-item { display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 14px; cursor: pointer; border-left: 3px solid transparent; }
.ab-item:hover { background: var(--surface-2); }
.ab-item.selected { background: var(--selected); border-left-color: var(--accent); }
.ab-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ab-item .avatar { width: 34px; height: 34px; font-size: 13px; }
.ab-item-main { flex: 1; min-width: 0; }
.ab-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-sub { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.photo { background: var(--surface-3); overflow: hidden; }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xl { width: 72px; height: 72px; font-size: 26px; }
.ab-detail { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; }
.ab-detail-head { display: flex; align-items: center; gap: 16px; padding: 24px 24px 12px; }
.ab-head-text { min-width: 0; }
.ab-head-text h2 { margin: 0 0 2px; font-size: 21px; font-weight: 500; overflow-wrap: anywhere; }
.ab-back { display: none; }
.ab-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 24px 12px; border-bottom: 1px solid var(--border); }
.ab-rows { padding: 12px 24px 24px; display: flex; flex-direction: column; gap: 14px; }
.ab-row { display: flex; gap: 12px; align-items: flex-start; }
.ab-row > .icon { margin-top: 3px; color: var(--text-3); }
.ab-row-main { min-width: 0; overflow-wrap: anywhere; }
.ab-row-label { font-size: 12px; color: var(--text-3); }
.ab-adr, .ab-note { white-space: pre-wrap; }
.ab-form { gap: 12px; }
.ab-photo-row { display: flex; align-items: center; gap: 14px; }
.ab-photo-prev { width: 64px; height: 64px; border-radius: 50%; background: var(--surface-3); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; color: var(--text-3); }
.ab-photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.ab-group { display: flex; flex-direction: column; gap: 6px; }
.ab-group-label { font-size: 13px; color: var(--text-2); }
.ab-multi { display: flex; flex-direction: column; gap: 6px; }
.ab-multi-row { display: flex; align-items: center; gap: 6px; }
.ab-multi-row input { flex: 1; min-width: 0; }
.ab-multi-row select { width: 140px; flex: none; }
.ab-adr-edit { display: flex; flex-direction: column; gap: 8px; }
.ab-zipcity { display: grid; grid-template-columns: 110px 1fr; gap: 12px; }
.ab-group + .row2, .ab-form .link-btn { align-self: flex-start; }

/* ---------- schmal ---------- */
@media (max-width: 899px) {
  .module-pane { border-radius: 0; }
  .pim-head { padding: 6px 6px 6px 8px; gap: 4px; }
  .pim-title { font-size: 15px; flex: 1 1 100%; order: 10; margin: 2px 6px; }
  .seg-btn { padding: 0 9px; }
  .cal-head, .cal-allday { grid-template-columns: 40px repeat(var(--days), minmax(0, 1fr)); }
  .cal-inner { grid-template-columns: 40px minmax(0, 1fr); }
  .cal-hour { font-size: 10px; padding-right: 3px; }
  .cal-timed { padding: 1px 3px; font-size: 11px; }
  .cal-ev-time, .cal-ev-loc { display: none; }
  .cal-mcell { min-height: 64px; }
  .cal-month .cal-chip-time { display: none; }
  .cal-ag-item { grid-template-columns: 12px 92px minmax(0, 1fr); }
  .cal-ag-cal { display: none; }
  .invite-card { margin: 8px 16px; }
  .ev-times { grid-template-columns: auto minmax(0, 1fr) minmax(0, 100px); }
  .ev-times select { grid-column: 1 / span 3; grid-row: auto; max-width: none; }
  .ab-listcol { width: 100%; border-right: 0; }
  .ab-detail { display: none; }
  .ab-main[data-pane="detail"] .ab-listcol { display: none; }
  .ab-main[data-pane="detail"] .ab-detail { display: flex; }
  .ab-back { display: inline-flex; }
  .ab-detail-head { padding: 12px 16px; }
  .ab-actions, .ab-rows { padding-left: 16px; padding-right: 16px; }
  .ab-multi-row select { width: 110px; }
}
