/* Engel Notes – Stylesheet
   Farbwelt angelehnt an yusebits.de: Tinte #0C0A24, Indigo #232A45, Signalrot #F23C34, Papier #F5F6FB
   Powered by YUSE Bits UG */

@font-face { font-family: "Archivo"; src: url("fonts/archivo-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("fonts/archivo-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Archivo", "IBM Plex Sans", system-ui, sans-serif;

  --bg: #F5F6FB;
  --bg-2: #EDEFF7;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --line: #E1E5F1;
  --line-strong: #C9CEE3;
  --text: #141530;
  --muted: #5B6180;
  --hover: rgba(20, 21, 48, .06);
  --press: rgba(20, 21, 48, .11);
  --accent: #F23C34;
  --accent-deep: #D4271F;
  --accent-soft: rgba(242, 60, 52, .12);
  --on-accent: #FFFFFF;
  --unread: #1D63F0;
  --badge: #1D63F0;
  --muted-on-color: #3A3F5E;
  --unread-soft: rgba(29, 99, 240, .14);
  --unread-glow: rgba(29, 99, 240, .45);
  --scrim: rgba(12, 10, 36, .42);
  --shadow-1: 0 1px 2px rgba(20, 21, 48, .06), 0 1px 3px rgba(20, 21, 48, .08);
  --shadow-2: 0 6px 24px rgba(20, 21, 48, .12), 0 2px 6px rgba(20, 21, 48, .08);
  --shadow-3: 0 24px 64px rgba(12, 10, 36, .28);
  --chip: rgba(20, 21, 48, .07);
  --bubble-me: #232A45;
  --bubble-me-text: #FFFFFF;
  --bubble-other: #FFFFFF;

  --c-default: var(--surface);
  --c-rot: #FAAFA8; --c-orange: #F9C9A8; --c-gelb: #FFF1A8; --c-gruen: #DDF2CE;
  --c-mint: #BFE6DB; --c-blau: #D4E6F1; --c-dunkelblau: #B4CCE6; --c-lila: #DCC9E8;
  --c-rosa: #F7DDE4; --c-braun: #E9E1D2; --c-grau: #E8E9EF;

  --r-card: 14px;
  --r-pill: 999px;
  --top-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0C0A24;
  --bg-2: #131032;
  --surface: #141233;
  --surface-raised: #1B1942;
  --line: rgba(255, 255, 255, .10);
  --line-strong: rgba(255, 255, 255, .20);
  --text: #EDEFF7;
  --muted: #A7ADC8;
  --hover: rgba(255, 255, 255, .07);
  --press: rgba(255, 255, 255, .12);
  --accent-soft: rgba(242, 60, 52, .18);
  --unread: #5B93FF;
  --badge: #2E66D6;
  --muted-on-color: #D0D4E6;
  --unread-soft: rgba(91, 147, 255, .18);
  --unread-glow: rgba(91, 147, 255, .55);
  --scrim: rgba(3, 2, 12, .62);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, .45);
  --shadow-3: 0 24px 64px rgba(0, 0, 0, .6);
  --chip: rgba(255, 255, 255, .10);
  --bubble-me: #F23C34;
  --bubble-me-text: #FFFFFF;
  --bubble-other: #1F1D4A;

  --c-rot: #6E2230; --c-orange: #6B3418; --c-gelb: #6A4D0B; --c-gruen: #264A37;
  --c-mint: #134F4A; --c-blau: #1F4A5E; --c-dunkelblau: #263A5A; --c-lila: #45305A;
  --c-rosa: #5E3246; --c-braun: #463E33; --c-grau: #2A2A40;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%;
  font: 400 15px/1.5 var(--font);
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}
[hidden] { display: none !important; }
body.lock { overflow: hidden; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
.noscript { padding: 2rem; text-align: center; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2.5px solid var(--unread); outline-offset: 2px; }
svg.ic { width: 24px; height: 24px; fill: currentColor; flex: none; display: block; }
svg.ic.sm { width: 20px; height: 20px; }
svg.ic.xs { width: 16px; height: 16px; }

/* ---------- Schaltflächen ---------- */
.iconbtn {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  display: inline-grid; place-items: center; position: relative; flex: none;
  transition: background-color .15s ease, color .15s ease;
}
.iconbtn:hover { background: var(--hover); color: var(--text); }
.iconbtn:active { background: var(--press); }
.iconbtn[aria-pressed="true"] { color: var(--text); background: var(--hover); }
.iconbtn .dot {
  position: absolute; top: 5px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--badge); color: #fff;
  font: 600 11px/18px var(--font); text-align: center; box-shadow: 0 0 0 2px var(--bg);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  font-weight: 600; font-size: 14.5px; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent-deep); border-color: var(--accent-deep); color: var(--on-accent); }
.btn.primary:hover { background: #BE1F18; }
.btn.danger { color: var(--accent-deep); border-color: color-mix(in srgb, var(--accent-deep) 45%, transparent); }
:root[data-theme="dark"] .btn.danger { color: #FF7A73; }
.btn.ghost { border-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }

/* ---------- Kopfleiste ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  padding-top: env(safe-area-inset-top, 0px);
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-row { display: flex; align-items: center; gap: 4px; height: var(--top-h); padding: 0 8px 0 4px; max-width: 1600px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 4px 8px 4px 2px; border-radius: 10px; min-width: 0; }
.brand img { height: 40px; width: auto; display: block; }
.brand .brand-word {
  font: 700 21px/1 var(--font-display); letter-spacing: -.01em;
  padding-left: 11px; border-left: 1.5px solid var(--line-strong); white-space: nowrap;
}
.brand .brand-word b { color: var(--accent); font-weight: 700; }
.logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: block !important; }
.spacer { flex: 1; }
.search {
  flex: 1 1 560px; max-width: 720px; margin: 0 16px;
  display: flex; align-items: center; gap: 4px; height: 48px; padding: 0 4px 0 6px;
  background: var(--bg-2); border-radius: 12px; border: 1px solid transparent;
  transition: background-color .15s, box-shadow .15s, border-color .15s;
}
.search:focus-within { background: var(--surface); box-shadow: var(--shadow-2); border-color: var(--line); outline: 2.5px solid var(--unread); outline-offset: 2px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; height: 100%; font-size: 16px; }
.search input::placeholder { color: var(--muted); }
.search .iconbtn { width: 40px; height: 40px; }
.search-row { display: none; padding: 0 12px 10px; }
.avatar {
  --hue: 220;
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: hsl(var(--hue) 62% 44%); color: #fff;
  font: 600 14px/1 var(--font-display); letter-spacing: .02em; user-select: none;
}
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10.5px; }
.avatarbtn { border: 0; background: transparent; padding: 4px; border-radius: 50%; display: grid; place-items: center; }
.avatarbtn:hover { background: var(--hover); }

@media (max-width: 759px) {
  .topbar-row { height: 58px; }
  .topbar-row .search { display: none; }
  .search-row { display: block; }
  .search-row .search { margin: 0; max-width: none; height: 46px; border-radius: 23px; }
  .brand img { height: 30px; }
  .brand .brand-word { font-size: 19px; padding-left: 9px; }
  .hide-mobile { display: none !important; }
}
@media (max-width: 380px) {
  .brand .brand-word { display: none; }
}
@media (min-width: 760px) { .hide-desktop { display: none !important; } }

/* ---------- Seitenmenü ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 61;
  width: min(320px, 86vw); background: var(--surface-raised); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  transform: translateX(-104%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  border-radius: 0 20px 20px 0; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 20px; }
.drawer-head img { height: 36px; width: auto; }
.drawer-scroll { flex: 1; overflow-y: auto; padding: 4px 0 12px; overscroll-behavior: contain; }
.nav-item {
  display: flex; align-items: center; gap: 18px; width: calc(100% - 12px); min-height: 48px;
  padding: 0 16px 0 22px; margin: 1px 0; border: 0; background: transparent; text-align: left;
  border-radius: 0 var(--r-pill) var(--r-pill) 0; color: var(--text); font-weight: 500; font-size: 15px;
  text-decoration: none;
}
.nav-item svg { color: var(--muted); }
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
:root[data-theme="dark"] .nav-item[aria-current="page"] { color: #FF8A84; }
.nav-item[aria-current="page"] svg { color: currentColor; }
.nav-item .count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--badge); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.nav-item .label-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 0; }
.nav-title { padding: 10px 22px 6px; color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; justify-content: space-between; }
.nav-title button { border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; padding: 6px 8px; border-radius: 8px; }
.nav-title button:hover { background: var(--hover); color: var(--text); }
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 4px 16px 6px 22px; padding: 4px; background: var(--bg-2); border-radius: 14px; }
.theme-switch button { border: 0; background: transparent; border-radius: 10px; min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.powered {
  display: flex; align-items: center; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px; text-decoration: none;
}
.powered img { height: 22px; width: auto; }
.powered:hover { color: var(--text); }

/* ---------- Inhalt ---------- */
main { max-width: 1600px; margin: 0 auto; padding: 8px 16px calc(120px + env(safe-area-inset-bottom, 0px)); }
.page-head { display: flex; align-items: center; gap: 12px; padding: 18px 4px 6px; min-height: 56px; }
.page-head h1 { margin: 0; font: 700 24px/1.2 var(--font-display); letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: 14px; }
.section-title { margin: 22px 6px 10px; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.notes-wrap.list { max-width: 680px; margin: 0 auto; }
.masonry { display: flex; gap: 14px; align-items: flex-start; }
.masonry .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 759px) {
  main { padding-left: 10px; padding-right: 10px; }
  .masonry, .masonry .col { gap: 10px; }
}

/* ---------- Notizkarte ---------- */
.card {
  position: relative; background: var(--nc, var(--surface)); border-radius: var(--r-card);
  border: 1px solid var(--line); padding: 14px 16px 10px; cursor: pointer;
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s;
  outline-offset: 3px; min-height: 58px;
}
.card[data-color]:not([data-color="default"]) { border-color: transparent; }
.card:hover { box-shadow: var(--shadow-2); }
.card h3, .card .body, .ed-title { -webkit-hyphens: auto; hyphens: auto; }
.card h3 { margin: 0 26px 6px 0; font: 600 16px/1.35 var(--font-display); letter-spacing: -.005em; }
.card .body { white-space: pre-wrap; font-size: 14.5px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 12; -webkit-box-orient: vertical; overflow: hidden; }
.card.list-view .body { -webkit-line-clamp: 6; }
.card .body.big { font-size: 20px; line-height: 1.35; }
.card .empty-hint { color: var(--muted); font-style: italic; font-size: 14px; }
.card .items { list-style: none; margin: 0; padding: 0; font-size: 14.5px; }
.card .items li { display: flex; gap: 8px; align-items: flex-start; padding: 2px 0; }
.card .items li svg { margin-top: 1px; color: var(--muted); }
.card .items li.done span { text-decoration: line-through; color: var(--muted); }
.card .items .more { color: var(--muted); font-size: 13px; padding-top: 4px; }
.card .pinmark { position: absolute; top: 10px; right: 10px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border-radius: 13px; background: var(--chip); font-size: 12.5px; font-weight: 500; max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: transparent; width: 24px; height: 24px; margin-right: -8px; border-radius: 50%; display: grid; place-items: center; color: inherit; opacity: .7; }
.chip button:hover { background: var(--hover); opacity: 1; }
.card-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; min-height: 22px; color: var(--muted); font-size: 12.5px; }
.card-foot .meta { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot .talk { flex: none; display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-weight: 500; }
.newpill { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 11px; background: var(--badge); color: #fff; font-weight: 600; font-size: 12px; margin-left: auto; }
.newpill + .talk { margin-left: 0; }

/* Blaues Aufleuchten: ungelesene Nachrichten im Notiz-Chat */
.card.unread { border-color: var(--unread) !important; box-shadow: 0 0 0 2px var(--unread), 0 0 22px var(--unread-glow); animation: glow 2.4s ease-in-out infinite; }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 2px var(--unread), 0 0 10px var(--unread-glow); }
  50% { box-shadow: 0 0 0 2px var(--unread), 0 0 28px var(--unread-glow); }
}

[data-color="rot"] { --nc: var(--c-rot); } [data-color="orange"] { --nc: var(--c-orange); }
[data-color="gelb"] { --nc: var(--c-gelb); } [data-color="gruen"] { --nc: var(--c-gruen); }
[data-color="mint"] { --nc: var(--c-mint); } [data-color="blau"] { --nc: var(--c-blau); }
[data-color="dunkelblau"] { --nc: var(--c-dunkelblau); } [data-color="lila"] { --nc: var(--c-lila); }
[data-color="rosa"] { --nc: var(--c-rosa); } [data-color="braun"] { --nc: var(--c-braun); }
[data-color="grau"] { --nc: var(--c-grau); }
/* Gedämpfte Schrift auf farbigen Notizen: >= 5,3:1 auf allen Notizfarben (gemessen) */
[data-color]:not([data-color="default"]) { --muted: var(--muted-on-color); }

.empty { text-align: center; padding: 72px 20px; color: var(--muted); }
.empty svg { width: 96px; height: 96px; opacity: .22; margin: 0 auto 14px; fill: currentColor; display: block; }
.empty p { margin: 0 auto; max-width: 360px; font-size: 16px; }

/* ---------- Neue Notiz ---------- */
.fab-wrap { position: fixed; right: calc(20px + env(safe-area-inset-right, 0px)); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.fab {
  height: 60px; min-width: 60px; padding: 0 22px 0 18px; border: 0; border-radius: 18px;
  background: var(--accent-deep); color: #fff; display: flex; align-items: center; gap: 10px;
  font: 600 16px/1 var(--font-display); letter-spacing: .005em;
  box-shadow: 0 8px 24px rgba(242, 60, 52, .35), 0 2px 6px rgba(12, 10, 36, .2);
  transition: transform .15s ease, box-shadow .15s ease;
}
.fab svg { width: 28px; height: 28px; }
.fab:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(242, 60, 52, .42), 0 2px 6px rgba(12, 10, 36, .2); }
.fab:active { transform: scale(.97); }
.fab-mini {
  height: 48px; padding: 0 18px 0 14px; border-radius: 16px; border: 0;
  background: var(--surface-raised); color: var(--text); display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14.5px; box-shadow: var(--shadow-2);
}
.fab-mini:hover { background: var(--bg-2); }
@media (max-width: 759px) {
  .fab .fab-label { display: none; }
  .fab { padding: 0; width: 60px; justify-content: center; }
  .fab-mini .fab-label { display: none; }
  .fab-mini { width: 48px; padding: 0; justify-content: center; }
}

/* ---------- Editor ---------- */
.overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: var(--scrim); animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; } }
.editor {
  --nc: var(--surface-raised);
  width: min(640px, 100%); max-height: min(88vh, 900px);
  background: var(--nc); color: var(--text); border-radius: 18px; box-shadow: var(--shadow-3);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
  overflow: hidden; animation: pop .2s cubic-bezier(.2, .9, .3, 1.1);
}
.editor[data-color="default"] { --nc: var(--surface-raised); }
@keyframes pop { from { transform: scale(.96); opacity: .4; } }
.editor.with-chat { width: min(1080px, 100%); grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); }
.ed-main { display: flex; flex-direction: column; min-height: 0; }
.ed-head { display: flex; align-items: center; gap: 2px; padding: 8px 8px 0; }
.ed-head .iconbtn, .ed-tools .iconbtn { color: var(--text); opacity: .78; }
.ed-head .iconbtn:hover, .ed-tools .iconbtn:hover { opacity: 1; }
.ed-scroll { flex: 1; overflow-y: auto; padding: 4px 22px 10px; min-height: 160px; overscroll-behavior: contain; }
.ed-title, .ed-body { width: 100%; border: 0; outline: 0; background: transparent; resize: none; display: block; padding: 0; }
.ed-title { font: 600 22px/1.3 var(--font-display); letter-spacing: -.01em; margin: 6px 0 12px; }
.ed-body { font-size: 16px; line-height: 1.6; min-height: 120px; }
.ed-title::placeholder, .ed-body::placeholder { color: var(--muted); opacity: .85; }
.ed-items { list-style: none; margin: 0; padding: 0; }
.ed-item { display: flex; align-items: flex-start; gap: 4px; padding: 1px 0; border-radius: 8px; }
.ed-item .iconbtn { width: 38px; height: 38px; }
.ed-item textarea { flex: 1; border: 0; outline: 0; background: transparent; resize: none; padding: 8px 0; font-size: 16px; line-height: 1.45; min-height: 38px; }
.ed-item.done textarea { text-decoration: line-through; color: var(--muted); }
.ed-item .rm { opacity: 0; }
.ed-item:hover .rm, .ed-item:focus-within .rm { opacity: .7; }
.ed-add { display: flex; align-items: center; gap: 12px; padding: 8px 8px; border: 0; background: transparent; color: var(--muted); font-size: 15.5px; width: 100%; text-align: left; border-radius: 8px; }
.ed-add:hover { background: var(--hover); }
.ed-done-title { margin: 14px 0 4px; color: var(--muted); font-size: 13.5px; padding-top: 10px; border-top: 1px solid var(--line); }
.ed-chips { padding: 6px 22px 0; }
.ed-meta { padding: 8px 22px 4px; color: var(--muted); font-size: 12.5px; text-align: right; }
.ed-tools { display: flex; align-items: center; gap: 2px; padding: 4px 8px calc(8px + env(safe-area-inset-bottom, 0px)); position: relative; }
.ed-tools .chat-toggle { width: auto; padding: 0 14px 0 10px; border-radius: var(--r-pill); gap: 6px; display: inline-flex; font-weight: 600; font-size: 14px; }
.ed-tools .chat-toggle.has-new { background: var(--badge); color: #fff; opacity: 1; }
.ed-close { margin-left: auto; }
.ed-trashed { margin: 8px 22px 0; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 14px; }

/* Popups (Farbe, Kategorien, Weitere) */
.pop {
  position: fixed; z-index: 90; background: var(--surface-raised); color: var(--text);
  border-radius: 14px; box-shadow: var(--shadow-3); border: 1px solid var(--line);
  padding: 8px; min-width: 220px; max-width: min(360px, calc(100vw - 16px)); max-height: 60vh; overflow: auto;
  animation: fade .12s ease;
}
.swatches { display: grid; grid-template-columns: repeat(6, 40px); gap: 6px; padding: 4px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid transparent; background: var(--nc); display: grid; place-items: center; color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.swatch[data-color="default"] { background: var(--surface); }
.swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: none; }
.swatch:hover { box-shadow: inset 0 0 0 1px var(--text); }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; background: transparent; border-radius: 10px; text-align: left; font-size: 14.5px; }
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--accent-deep); }
:root[data-theme="dark"] .menu-item.danger { color: #FF8A84; }
.menu-item svg { color: var(--muted); }
.menu-item.danger svg { color: currentColor; }
.menu-title { padding: 6px 12px 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.pop input[type="text"], .pop input[type="search"] { width: 100%; height: 40px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); padding: 0 12px; outline: none; font-size: 15px; }
.pop input:focus { border-color: var(--unread); }
.checkrow { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 10px; border: 0; background: transparent; border-radius: 10px; text-align: left; font-size: 14.5px; }
.checkrow:hover { background: var(--hover); }

/* ---------- Chat unter der Notiz ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); border-left: 1px solid var(--line); }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line); min-height: 60px; }
.chat-head h2 { margin: 0; font: 600 16px/1.2 var(--font-display); flex: 1; min-width: 0; }
.chat-head h2 small { display: block; font: 400 12.5px/1.3 var(--font); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list { flex: 1; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 30px 12px; font-size: 14.5px; max-width: 280px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; margin-top: 8px; }
.msg.cont { margin-top: 2px; }
.msg.cont .avatar { visibility: hidden; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.bubble { padding: 8px 12px 6px; border-radius: 16px 16px 16px 5px; background: var(--bubble-other); box-shadow: var(--shadow-1); min-width: 0; }
.msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); border-radius: 16px 16px 5px 16px; }
.bubble .who { font-size: 12.5px; font-weight: 600; margin-bottom: 2px; color: hsl(var(--hue) 55% 42%); }
:root[data-theme="dark"] .bubble .who { color: hsl(var(--hue) 75% 72%); }
.bubble .txt { white-space: pre-wrap; font-size: 15px; line-height: 1.45; }
.bubble .txt a { color: inherit; text-decoration: underline; }
.bubble .time { font-size: 11px; opacity: .7; text-align: right; margin-top: 2px; }
.day-sep { align-self: center; margin: 14px 0 4px; font-size: 12px; color: var(--muted); background: var(--bg-2); padding: 3px 12px; border-radius: 10px; }
.new-sep { align-self: stretch; display: flex; align-items: center; gap: 10px; margin: 12px 0 2px; color: var(--unread); font-size: 12px; font-weight: 600; }
.new-sep::before, .new-sep::after { content: ""; flex: 1; height: 1px; background: var(--unread); opacity: .5; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface-raised); }
.composer textarea { flex: 1; min-height: 44px; max-height: 160px; resize: none; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--surface); padding: 10px 16px; outline: none; font-size: 16px; line-height: 1.4; }
.composer textarea:focus { border-color: var(--unread); }
.composer .send { background: var(--accent-deep); color: #fff; }
.composer .send:hover { background: #BE1F18; color: #fff; }
.composer .send:disabled { background: var(--bg-2); color: var(--muted); }
.attach-preview { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; background: var(--surface-raised); border-top: 1px solid var(--line); }
.attach-preview + .composer { border-top: 0; }

/* Angehängte Notiz in Nachrichten */
.note-ref { display: flex; align-items: stretch; gap: 0; margin: 4px 0 2px; border-radius: 12px; overflow: hidden; background: var(--nc, var(--surface)); color: var(--text); border: 1px solid var(--line); text-align: left; width: 100%; min-width: 200px; max-width: 320px; padding: 0; }
.note-ref .bar { width: 5px; background: var(--accent); flex: none; }
.note-ref .inner { padding: 8px 12px; min-width: 0; }
.note-ref .t { font: 600 14px/1.3 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-ref .x { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-ref:hover { box-shadow: var(--shadow-2); }
.note-ref.gone { opacity: .7; cursor: default; }

@media (max-width: 899px) {
  .editor.with-chat { grid-template-columns: minmax(0, 1fr); }
  .editor.with-chat .ed-main { display: none; }
  .chat { border-left: 0; }
}
@media (max-width: 759px) {
  .overlay { padding: 0; background: var(--bg); }
  .editor, .editor.with-chat { width: 100%; height: 100%; max-height: none; border-radius: 0; box-shadow: none; animation: slideup .22s cubic-bezier(.2, .9, .3, 1); }
  @keyframes slideup { from { transform: translateY(24px); opacity: .5; } }
  .ed-head { padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
  .chat-head { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .ed-scroll { padding-left: 18px; padding-right: 18px; }
  .ed-chips, .ed-meta { padding-left: 18px; padding-right: 18px; }
}

/* ---------- Nachrichten (privat) ---------- */
.conv-list { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 2px; }
.conv {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; border: 0; border-radius: 14px;
  background: transparent; text-align: left; color: inherit; text-decoration: none;
}
.conv:hover { background: var(--hover); }
.conv .c-main { flex: 1; min-width: 0; }
.conv .c-top { display: flex; align-items: baseline; gap: 8px; }
.conv .c-name { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .c-role { font-size: 11.5px; font-weight: 600; color: var(--accent-deep); background: var(--accent-soft); padding: 1px 8px; border-radius: 8px; }
:root[data-theme="dark"] .conv .c-role { color: #FF8A84; }
.conv .c-time { margin-left: auto; font-size: 12.5px; color: var(--muted); flex: none; }
.conv .c-last { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.conv.has-new .c-last { color: var(--text); font-weight: 500; }
.conv.has-new .c-time { color: var(--unread); font-weight: 600; }
.conv .c-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--badge); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; flex: none; }
.dm-view { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: center; background: var(--scrim); }
.dm-panel { width: min(760px, 100%); height: 100%; display: flex; flex-direction: column; background: var(--bg); box-shadow: var(--shadow-3); }
.dm-panel .chat-list { padding-left: 16px; padding-right: 16px; }
@media (max-width: 759px) { .dm-view { background: var(--bg); } .dm-panel { box-shadow: none; } }

/* ---------- Dialoge ---------- */
dialog {
  border: 0; padding: 0; border-radius: 20px; background: var(--surface-raised); color: var(--text);
  box-shadow: var(--shadow-3); width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: var(--scrim); }
.dlg { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.dlg h2 { margin: 0; font: 700 20px/1.25 var(--font-display); }
.dlg p { margin: 0; color: var(--muted); }
.dlg .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 13.5px; font-weight: 600; }
.field input, .field select {
  height: 46px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface);
  padding: 0 14px; outline: none; font-size: 16px; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--unread); box-shadow: 0 0 0 3px var(--unread-soft); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.form-error { color: var(--accent-deep); font-size: 14px; font-weight: 500; min-height: 1em; }
:root[data-theme="dark"] .form-error { color: #FF8A84; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg-2); border-radius: 12px; }
.seg label { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 9px; cursor: pointer; font-size: 14.5px; font-weight: 500; color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--text); }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg label:has(input:focus-visible) { outline: 2.5px solid var(--unread); }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-weight: 500; }
.switchrow input { width: 22px; height: 22px; accent-color: var(--accent-deep); }

/* Nutzerliste */
.user-list { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.user-row .u-main { flex: 1; min-width: 0; }
.user-row .u-name { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.user-row .u-sub { font-size: 13.5px; color: var(--muted); }
.tag { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 8px; background: var(--chip); }
.tag.chef { background: var(--accent-soft); color: var(--accent-deep); }
:root[data-theme="dark"] .tag.chef { color: #FF8A84; }
.user-row.inactive { opacity: .6; }

/* Kategorien verwalten */
.label-rows { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; }
.label-row { display: flex; align-items: center; gap: 6px; }
.label-row input { flex: 1; height: 42px; border: 1px solid transparent; border-radius: 10px; background: transparent; padding: 0 10px; outline: none; font-size: 15px; }
.label-row input:hover { border-color: var(--line); }
.label-row input:focus { border-color: var(--unread); background: var(--surface); }
.label-row input[readonly] { cursor: default; border-color: transparent; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 110% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface-raised); border-radius: 24px; padding: 32px 28px 24px; box-shadow: var(--shadow-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; }
.auth-card .logo { height: 58px; width: auto; align-self: flex-start; }
.auth-card h1 { margin: 6px 0 0; font: 700 28px/1.15 var(--font-display); letter-spacing: -.015em; }
.auth-card h1 b { color: var(--accent); }
.auth-card .lead { margin: -8px 0 4px; color: var(--muted); font-size: 15px; }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; min-height: 44px; border-radius: 10px; color: var(--muted); font-size: 12.5px; }
.auth-foot img { height: 18px; width: auto; }
.auth-wrap { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* ---------- Hinweise ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; background: #232A45; color: #fff; padding: 12px 10px 12px 18px; border-radius: 12px; box-shadow: var(--shadow-3); font-size: 14.5px; animation: toast .22s cubic-bezier(.2, .9, .3, 1.1); }
.toast.err { background: #A81E17; }
.toast button { border: 0; background: transparent; color: #FFB4AF; font-weight: 700; padding: 6px 10px; border-radius: 8px; }
.toast button:hover { background: rgba(255, 255, 255, .1); }
@keyframes toast { from { transform: translateY(12px); opacity: 0; } }
.offline { position: fixed; top: calc(8px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 101; background: #A81E17; color: #fff; padding: 6px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-2); }

.loading { min-height: 100vh; display: grid; place-items: center; }
.loading img { height: 56px; opacity: .9; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .card.unread { box-shadow: 0 0 0 3px var(--unread), 0 0 18px var(--unread-glow); }
}
