:root {
  /* iOS system palette (light) */
  --tint: #AF52DE;                        /* systemPurple – Standardthema */
  --on-tint: #FFFFFF;
  --red: #FF3B30;
  --switch-on: #34C759;
  --bg: #F2F2F7;                          /* systemGroupedBackground */
  --card: #FFFFFF;                        /* secondarySystemGroupedBackground */
  --card-2: #F2F2F7;
  --label: #000000;
  --label-2: rgba(60,60,67,.6);           /* secondaryLabel */
  --label-3: rgba(60,60,67,.3);           /* tertiaryLabel */
  --sep: rgba(60,60,67,.29);              /* separator */
  --fill: rgba(120,120,128,.16);          /* secondarySystemFill */
  --fill-2: rgba(120,120,128,.12);
  --chev: #C7C7CC;
  --seg-sel: #FFFFFF;
  --scrim: rgba(0,0,0,.4);

  /* Liquid Glass (iOS 26/27): Material, Glanzlicht, abgedunkelte Kante */
  --glass-bg: rgba(255,255,255,.58);
  --glass-hl: rgba(255,255,255,.6);       /* specular highlight */
  --glass-edge: rgba(25,25,35,.14);       /* darkened edge */
  --glass-shadow: 0 10px 30px rgba(0,0,0,.14);
  --blur: saturate(180%) blur(24px);

  --radius-card: 18px;
  --radius-group: 22px;

  --shadow-card: 0 1px 2px rgba(0,0,0,.04);
  --shadow-float: 0 8px 24px rgba(0,0,0,.18);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  --appbar-h: 56px;
  --nav-h: 62px;
  --nav-gap: 12px;
  --count-h: 32px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

:root[data-mode="dark"] {
  --tint: #BF5AF2;
  --red: #FF453A;
  --switch-on: #30D158;
  --bg: #000000;
  --card: #1C1C1E;
  --card-2: #2C2C2E;
  --label: #FFFFFF;
  --label-2: rgba(235,235,245,.6);
  --label-3: rgba(235,235,245,.3);
  --sep: rgba(84,84,88,.65);
  --fill: rgba(120,120,128,.24);
  --fill-2: rgba(120,120,128,.18);
  --chev: #5A5A5E;
  --seg-sel: #636366;
  --glass-bg: rgba(28,28,32,.6);
  --glass-hl: rgba(255,255,255,.14);
  --glass-edge: rgba(0,0,0,.55);
  --glass-shadow: 0 10px 30px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --tint: #BF5AF2;
    --red: #FF453A;
    --switch-on: #30D158;
    --bg: #000000;
    --card: #1C1C1E;
    --card-2: #2C2C2E;
    --label: #FFFFFF;
    --label-2: rgba(235,235,245,.6);
    --label-3: rgba(235,235,245,.3);
    --sep: rgba(84,84,88,.65);
    --fill: rgba(120,120,128,.24);
    --fill-2: rgba(120,120,128,.18);
    --chev: #5A5A5E;
    --seg-sel: #636366;
    --glass-bg: rgba(28,28,32,.6);
    --glass-hl: rgba(255,255,255,.14);
    --glass-edge: rgba(0,0,0,.55);
    --glass-shadow: 0 10px 30px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html, body { min-height: 100%; }
body { font-family: var(--font); color: var(--label); background: var(--bg); -webkit-font-smoothing: antialiased; }

.app { max-width: 460px; margin: 0 auto; position: relative; background: var(--bg); min-height: 100dvh; }

/* Liquid-Glass-Material: Blur + Glanzlicht oben + abgedunkelte Kante (iOS 27) */
.navbar, .notes-count-bar, .sheet-panel, .snackbar, .pending-banner, .ctrl-btn, .search-wrap {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: inset 0 1px 1px var(--glass-hl), inset 0 0 0 0.5px rgba(255,255,255,.18), 0 0 0 0.5px var(--glass-edge), var(--glass-shadow);
}

/* ---------- Navigation bar (large title) ---------- */
.appbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 72%, transparent); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); padding-top: var(--safe-t); }
.appbar-inner { height: var(--appbar-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 2px; padding: 0 12px 0 16px; }
/* Unterseiten (mit Zurück-Button): zentrierter, kleinerer Titel */
.appbar-title { grid-column: 2; text-align: center; font-size: 20px; font-weight: 600; letter-spacing: .2px; color: var(--label); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Hauptseiten (ohne Zurück-Button): Large Title, linksbündig – wie native iOS-Apps */
.appbar-inner:has(.nav-back[hidden]) { grid-template-columns: auto 1fr auto; }
.appbar-inner:has(.nav-back[hidden]) .appbar-title { text-align: left; font-size: 28px; font-weight: 700; }
.nav-back[hidden] { display: none; }
.nav-back { grid-column: 1; justify-self: start; color: var(--tint); width: 38px; height: 38px; margin-left: -6px; border-radius: 50%; background: var(--fill-2); }
.appbar-trailing { grid-column: 3; justify-self: end; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--red); padding-right: 4px; }
.nav-rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: recblink 1.4s ease-in-out infinite; }
@keyframes recblink { 50% { opacity: .35; } }

/* ---------- Icon button ---------- */
.icon-btn { width: 40px; height: 40px; border: none; border-radius: 50%; background: transparent; color: var(--label-2); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; transition: background-color .15s ease, opacity .1s ease; }
.icon-btn:active { opacity: .5; }
.icon-btn:focus-visible { outline: 2px solid var(--tint); outline-offset: 1px; }
.icon-btn.tonal { background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); border-radius: 14px; }
.icon-btn.danger:active { color: var(--red); }

/* ---------- Stage / views ---------- */
.view { display: none; padding: 8px 16px calc(var(--nav-h) + var(--nav-gap) + var(--safe-b) + 28px); }
.view.is-active { display: block; }
.view[hidden] { display: none !important; }
#view-notes.is-active { padding-bottom: calc(var(--nav-h) + var(--nav-gap) + var(--count-h) + var(--safe-b) + 24px); }
#view-detail.is-active { padding-bottom: calc(var(--nav-h) + var(--nav-gap) + var(--safe-b) + 92px); }
#view-home.is-active { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100dvh - var(--safe-t) - var(--appbar-h) - var(--nav-h) - var(--nav-gap) - var(--safe-b)); padding-top: 0; padding-bottom: 0; }

/* ---------- Recorder (Voice-Memos-Stil) ---------- */
.recorder { display: flex; flex-direction: column; align-items: center; }
.rec-timer { font-size: 56px; font-weight: 200; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 1px; color: var(--label); margin-bottom: 30px; }
.fab-record { width: 74px; height: 74px; border: none; border-radius: 50%; background: var(--red); color: #FFFFFF; display: grid; place-items: center; cursor: pointer; box-shadow: inset 0 1px 1px rgba(255,255,255,.4), 0 0 0 4px var(--bg), 0 0 0 6.5px var(--sep), 0 10px 24px rgba(255,59,48,.35); transition: background-color .2s ease, transform .1s ease; }
.fab-record:active { transform: scale(0.94); }
.fab-record:focus-visible { outline: 3px solid var(--tint); outline-offset: 8px; }
.ic-stop { display: none; width: 26px; height: 26px; border-radius: 8px; background: currentColor; }
.fab-record[data-state="rec"] { background: var(--red); color: #FFFFFF; }
.fab-record[data-state="rec"] .ic-mic { display: none; }
.fab-record[data-state="rec"] .ic-stop { display: block; }
.fab-record[data-state="busy"] { background: var(--fill); color: var(--label-3); pointer-events: none; box-shadow: 0 0 0 4px var(--bg), 0 0 0 6.5px var(--sep); }
.home-status { display: flex; align-items: center; gap: 8px; margin-top: 28px; min-height: 22px; font-size: 15px; color: var(--label-2); text-align: center; }
.home-status[data-state="error"] { color: var(--red); }
.hs-spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--fill); border-top-color: var(--tint); animation: spin .7s linear infinite; }
.home-status[data-state="busy"] .hs-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Settings: inset grouped list ---------- */
.settings-list { list-style: none; background: var(--card); border-radius: var(--radius-group); overflow: hidden; margin-top: 16px; box-shadow: var(--shadow-card); }
.set-row { width: 100%; display: flex; align-items: center; gap: 12px; background: none; border: none; padding: 11px 16px; min-height: 48px; cursor: pointer; color: var(--label); position: relative; }
.set-row::after { content: ""; position: absolute; left: 57px; right: 0; bottom: 0; border-bottom: 0.5px solid var(--sep); }
.settings-list li:last-child .set-row::after { display: none; }
.set-row:active { background: var(--fill-2); }
.set-row:focus-visible { outline: 2px solid var(--tint); outline-offset: -2px; }
.set-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #FFFFFF; flex: 0 0 auto; box-shadow: inset 0 1px 1px rgba(255,255,255,.35), inset 0 -6px 10px rgba(0,0,0,.08); }
.set-ic svg { width: 19px; height: 19px; }
.settings-list li:nth-child(1) .set-ic { background: #007AFF; }
.settings-list li:nth-child(2) .set-ic { background: #FF9500; }
.settings-list li:nth-child(3) .set-ic { background: #34C759; }
.settings-list li:nth-child(4) .set-ic { background: #FF3B30; }
.settings-list li:nth-child(5) .set-ic { background: #8E8E93; }
.settings-list li:nth-child(6) .set-ic { background: #AF52DE; }
.set-name { flex: 1 1 auto; font-size: 17px; font-weight: 400; text-align: left; }
.set-chev { color: var(--chev); display: grid; place-items: center; }
.settings-panel[hidden] { display: none; }

/* ---------- Text fields (grouped rows) ---------- */
.md-field { position: relative; background: var(--card); border-radius: var(--radius-card); padding: 8px 16px 9px; margin-bottom: 12px; box-shadow: var(--shadow-card); }
.md-field:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--tint) 45%, transparent); }
.md-field-label { display: block; font: 400 13px var(--font); color: var(--label-2); margin-bottom: 2px; }
.md-field-row { display: flex; align-items: center; gap: 8px; }
.md-input { flex: 1 1 auto; width: 100%; border: none; background: transparent; outline: none; font: 17px var(--font); color: var(--label); }
.md-input::placeholder { color: var(--label-3); }
.md-select { padding-right: 44px; }
.md-select .md-input { appearance: none; }
.md-trailing { position: absolute; right: 14px; bottom: 12px; color: var(--chev); pointer-events: none; }

/* ---------- Switch rows (statt Checkbox) ---------- */
.check-row { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--radius-card); padding: 11px 16px; margin-bottom: 12px; cursor: pointer; box-shadow: var(--shadow-card); }
.check-input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-label { font-size: 17px; color: var(--label); order: 1; flex: 1 1 auto; }
.check-box { order: 2; width: 51px; height: 31px; border-radius: 31px; border: none; background: var(--fill); flex: 0 0 auto; position: relative; transition: background-color .2s ease; box-shadow: inset 0 1px 2px rgba(0,0,0,.06); }
.check-box::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #FFFFFF; box-shadow: inset 0 1px 1px rgba(255,255,255,.8), 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .2s ease; }
.check-input:checked + .check-box { background: var(--switch-on); }
.check-input:checked + .check-box::after { transform: translateX(20px); }
.check-input:focus-visible + .check-box { outline: 2px solid var(--tint); outline-offset: 2px; }

/* ---------- Buttons (Kapselformen) ---------- */
.filled-btn { width: 100%; margin-top: 12px; min-height: 52px; padding: 14px 20px; border: none; border-radius: 26px; background: var(--tint); color: var(--on-tint); font: 600 17px var(--font); cursor: pointer; box-shadow: inset 0 1px 1px rgba(255,255,255,.35), 0 6px 18px color-mix(in srgb, var(--tint) 35%, transparent); transition: opacity .1s ease, transform .1s ease; }
.filled-btn:active { opacity: .75; }
.filled-btn:disabled { opacity: .4; pointer-events: none; }
.filled-btn:focus-visible { outline: 3px solid var(--tint); outline-offset: 3px; }
.tonal-btn { width: 100%; min-height: 52px; padding: 14px 20px; border: none; border-radius: 26px; background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); font: 600 17px var(--font); cursor: pointer; transition: opacity .1s ease; }
.tonal-btn:active { opacity: .6; }
.tonal-btn.small { width: auto; min-height: 36px; padding: 7px 16px; font-size: 15px; border-radius: 18px; }
.outlined-btn { background: color-mix(in srgb, var(--tint) 14%, transparent); border: none; color: var(--tint); border-radius: 22px; min-height: 44px; padding: 11px 18px; font: 600 15px var(--font); cursor: pointer; transition: opacity .1s ease; }
.outlined-btn:active { opacity: .6; }
.update-btn { width: 100%; margin-top: 4px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--tint); font: 400 17px var(--font); cursor: pointer; padding: 8px 10px; border-radius: 14px; transition: opacity .1s ease; }
.link-btn:active { opacity: .4; }
.link-btn.small { padding: 6px 8px; font-size: 15px; }
.link-btn.danger { color: var(--red); }
.link-btn:focus-visible { outline: 2px solid var(--tint); outline-offset: 1px; }

.group-label { font: 400 13px var(--font); color: var(--label-2); text-transform: uppercase; letter-spacing: .05em; padding: 22px 16px 8px; }
.group-foot { font-size: 13px; color: var(--label-2); line-height: 1.45; padding: 8px 16px 0; }
.settings-status { font-size: 14px; color: var(--tint); min-height: 18px; padding: 12px 16px 0; font-weight: 500; }
.settings-status.err { color: var(--red); }

/* ---------- Categories management ---------- */
.cat-manage { list-style: none; background: var(--card); border-radius: var(--radius-group); overflow: hidden; box-shadow: var(--shadow-card); }
.cat-item { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; position: relative; }
.cat-item::after { content: ""; position: absolute; left: 60px; right: 0; bottom: 0; border-bottom: 0.5px solid var(--sep); }
.cat-item:last-child::after { display: none; }
.cat-item-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); flex: 0 0 auto; }
.cat-item-name { flex: 1 1 auto; font-size: 17px; color: var(--label); }
.cat-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.cat-empty { padding: 16px; font-size: 15px; color: var(--label-2); }
.cat-editor { padding: 14px 16px; background: var(--card-2); position: relative; }
.cat-editor::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; border-bottom: 0.5px solid var(--sep); }
.cat-editor:last-child::after { display: none; }
.cat-editor .md-field { margin-bottom: 12px; background: var(--card); box-shadow: none; border: 0.5px solid var(--sep); }
.cat-editor-actions { display: flex; justify-content: flex-end; gap: 6px; }

.cat-add { display: flex; gap: 10px; align-items: stretch; }
.cat-add-field { flex: 1 1 auto; margin-bottom: 0; }
.cat-icon-btn { width: 56px; height: auto; min-height: 56px; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 12px; margin-top: 14px; background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.icon-grid[hidden] { display: none; }
.icon-opt { aspect-ratio: 1; display: grid; place-items: center; border: none; border-radius: 12px; background: transparent; color: var(--label-2); cursor: pointer; }
.icon-opt:active { background: var(--fill-2); }
.icon-opt.is-sel { background: color-mix(in srgb, var(--tint) 16%, transparent); color: var(--tint); }

/* ---------- Grouped notes ---------- */
.notes-groups { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.group-head { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; padding: 6px 4px; color: var(--label); border-radius: 14px; }
.group-head:active { opacity: .55; }
.group-head:focus-visible { outline: 2px solid var(--tint); outline-offset: 1px; }
.group-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); flex: 0 0 auto; }
.group.is-muted .group-icon { background: var(--fill); color: var(--label-2); }
.group-name { font-size: 20px; font-weight: 700; letter-spacing: .1px; }
.group-count { font-size: 14px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.group-chev { margin-left: auto; color: var(--chev); display: grid; place-items: center; transition: transform .2s ease; }
.group.is-collapsed .group-chev { transform: rotate(-90deg); }
.group-list { list-style: none; display: flex; flex-direction: column; gap: 10px; padding-top: 2px; }
.group.is-collapsed .group-list { display: none; }

/* ---------- Note cell + swipe ---------- */
.note-cell { position: relative; border-radius: var(--radius-card); overflow: hidden; }
.note-swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; opacity: 0; transition: opacity .12s ease; }
.note-swipe-bg.del { background: var(--red); color: #fff; justify-content: flex-end; padding: 0 22px; }
.note-swipe-bg.cat { background: var(--tint); color: var(--on-tint); justify-content: flex-start; padding: 0 22px; }
.note-cell.dir-left .note-swipe-bg.del { opacity: 1; }
.note-cell.dir-right .note-swipe-bg.cat { opacity: 1; }
.note-fg { position: relative; touch-action: pan-y; will-change: transform; }
.note-card { width: 100%; text-align: left; background: var(--card); border: none; border-radius: var(--radius-card); padding: 13px 16px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; box-shadow: var(--shadow-card); }
.note-card:active { background: var(--card-2); }
.note-card:focus-visible { outline: 3px solid var(--tint); outline-offset: -3px; }
.note-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.note-card-title { font-size: 17px; font-weight: 600; color: var(--label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-dur { flex: 0 0 auto; font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.note-card-snippet { font-size: 15px; color: var(--label-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-card-date { font-size: 12px; letter-spacing: .2px; color: var(--label-3); }

/* ---------- Empty ---------- */
.empty { display: none; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 64px 30px; }
.empty.is-shown { display: flex; }
.empty-mark { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--fill); color: var(--label-2); margin-bottom: 8px; }
.empty-title { font-size: 17px; font-weight: 600; }
.empty-text { font-size: 15px; color: var(--label-2); max-width: 260px; }

/* ---------- Notes count: schwebende Glas-Kapsel ---------- */
.notes-count-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--nav-gap) + var(--safe-b) + 10px); height: var(--count-h); display: flex; align-items: center; justify-content: center; padding: 0 18px; border-radius: calc(var(--count-h) / 2); color: var(--label-2); font-size: 13px; font-weight: 500; z-index: 9; white-space: nowrap; }
.notes-count-bar[hidden] { display: none; }

/* ---------- Detail ---------- */
.detail-title { font-size: 24px; font-weight: 700; line-height: 1.25; padding: 8px 2px 2px; letter-spacing: .1px; }
.detail-headline { font-size: 15px; color: var(--label-2); padding: 0 2px 8px; line-height: 1.4; }
.detail-meta { font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; padding: 0 2px 14px; }
.detail-chiprow { padding: 0 0 14px; }
.detail-edit-field { margin-bottom: 14px; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 0 14px; }
.content-label { font: 400 13px var(--font); color: var(--label-2); letter-spacing: .05em; text-transform: uppercase; padding: 2px 2px 8px; }
.detail-card { background: var(--card); border-radius: var(--radius-group); padding: 16px 18px; box-shadow: var(--shadow-card); }
.detail-text { font-size: 17px; line-height: 1.55; color: var(--label); white-space: pre-wrap; word-break: break-word; }
textarea.md-input { min-height: 200px; resize: vertical; line-height: 1.5; font-family: var(--font); }
.detail-action-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--nav-gap) + var(--safe-b) + 10px); width: 100%; max-width: 460px; z-index: 9; background: transparent; padding: 0 16px; display: flex; pointer-events: none; }
.detail-action-bar[hidden] { display: none; }
.sum-btn { pointer-events: auto; flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; border: none; border-radius: 26px; background: color-mix(in srgb, var(--tint) 82%, transparent); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); color: var(--on-tint); font: 600 17px var(--font); cursor: pointer; box-shadow: inset 0 1px 1px rgba(255,255,255,.4), 0 0 0 0.5px var(--glass-edge), 0 10px 26px color-mix(in srgb, var(--tint) 40%, transparent); transition: opacity .1s ease; }
.sum-btn:active { opacity: .75; }
.sum-btn:disabled { opacity: .45; pointer-events: none; }
.sum-ic { display: inline-flex; }
.detail-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 16px 0 0; }
.detail-foot-spacer { flex: 1 1 auto; }
.detail-toggle { margin-top: 14px; }

.cat-chip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 15px 0 12px; border-radius: 17px; border: none; background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); font: 500 15px var(--font); cursor: pointer; transition: opacity .1s ease; }
.cat-chip svg { width: 17px; height: 17px; color: var(--tint); }
.cat-chip:active { opacity: .6; }
.cat-chip.is-empty { color: var(--label-2); background: var(--fill-2); border: 1px dashed var(--sep); }
.cat-chip.is-empty svg { color: var(--label-2); }
.cat-chip:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }

/* ---------- Schwebende Glas-Tab-Bar (Liquid Glass) ---------- */
.navbar { position: fixed; bottom: calc(var(--safe-b) + var(--nav-gap)); left: 50%; transform: translateX(-50%); width: min(calc(100% - 32px), 400px); z-index: 10; display: flex; align-items: stretch; height: var(--nav-h); border-radius: calc(var(--nav-h) / 2); padding: 0 6px; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0; background: none; border: none; cursor: pointer; color: var(--label-2); transition: opacity .1s ease; }
.tab:active { opacity: .55; }
.tab-ind { display: grid; place-items: center; width: 54px; height: 30px; border-radius: 15px; transition: background-color .2s ease; }
.tab.is-active { color: var(--tint); }
.tab.is-active .tab-ind { background: color-mix(in srgb, var(--tint) 15%, transparent); box-shadow: inset 0 1px 1px rgba(255,255,255,.25); }
.tab-label { font: 500 10px var(--font); letter-spacing: .1px; }
.tab:focus-visible { outline: 2px solid var(--tint); outline-offset: -4px; border-radius: 16px; }

/* ---------- Modal bottom sheet (Glas) ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .2s ease; }
.sheet.is-open .sheet-backdrop { opacity: 1; }
.sheet-panel { position: absolute; left: 50%; bottom: 0; transform: translate(-50%, 105%); width: 100%; max-width: 460px; border-radius: 34px 34px 0 0; padding: 0 16px calc(16px + var(--safe-b)); transition: transform .3s cubic-bezier(.32,.72,0,1); }
.sheet.is-open .sheet-panel { transform: translate(-50%, 0); }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 10px auto 10px; }
.sheet-title { text-align: center; font: 600 13px var(--font); color: var(--label-2); margin-bottom: 8px; }
.cat-choices { list-style: none; }
.cat-choice { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: none; padding: 11px 10px; border-radius: 14px; cursor: pointer; font: 400 17px var(--font); color: var(--label); position: relative; }
.cat-choice::after { content: ""; position: absolute; left: 54px; right: 0; bottom: 0; border-bottom: 0.5px solid var(--sep); }
.cat-choices li:last-child .cat-choice::after { display: none; }
.cat-choice:active { background: var(--fill-2); }
.cat-choice .cat-item-icon { width: 32px; height: 32px; }
.cat-choice.is-sel { color: var(--tint); font-weight: 600; }
.cat-choice .check { margin-left: auto; color: var(--tint); }
.sheet-skip { margin-top: 12px; }

/* ---------- Toast / Snackbar (Glas-Pille) ---------- */
.snackbar { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--nav-gap) + var(--safe-b) + 14px); transform: translateX(-50%) translateY(8px); color: var(--label); font-size: 15px; padding: 10px 10px 10px 18px; border-radius: 22px; opacity: 0; transition: opacity .2s ease, transform .2s ease; z-index: 70; max-width: 88%; min-width: 260px; display: flex; align-items: center; gap: 8px; }
.snackbar.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }
.snackbar[hidden] { display: none; }
.snackbar-msg { flex: 1 1 auto; }
.snackbar-action { background: none; border: none; color: var(--tint); font: 600 15px var(--font); padding: 8px 12px; border-radius: 14px; cursor: pointer; flex: 0 0 auto; }

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

/* ---------- Farbthemen (Personalisierung) ---------- */
:root[data-theme="blue"] { --tint: #007AFF; }
:root[data-theme="green"] { --tint: #34C759; }
:root[data-theme="rose"] { --tint: #FF2D55; }
:root[data-mode="dark"][data-theme="blue"] { --tint: #0A84FF; }
:root[data-mode="dark"][data-theme="green"] { --tint: #30D158; }
:root[data-mode="dark"][data-theme="rose"] { --tint: #FF375F; }
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"])[data-theme="blue"] { --tint: #0A84FF; }
  :root:not([data-mode="light"])[data-theme="green"] { --tint: #30D158; }
  :root:not([data-mode="light"])[data-theme="rose"] { --tint: #FF375F; }
}

/* ---------- Theme picker ---------- */
.mode-row { display: flex; gap: 2px; margin: 8px 0 4px; background: var(--fill); border-radius: 19px; padding: 3px; }
.mode-opt { flex: 1 1 0; min-height: 32px; border: none; border-radius: 16px; background: transparent; color: var(--label); font: 500 13px var(--font); cursor: pointer; transition: background-color .15s ease; }
.mode-opt.is-sel { background: var(--seg-sel); box-shadow: inset 0 1px 1px rgba(255,255,255,.5), 0 1px 4px rgba(0,0,0,.12), 0 3px 8px rgba(0,0,0,.06); font-weight: 600; }
.theme-grid { display: flex; gap: 10px; margin-top: 8px; }
.theme-opt { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 6px; border: 2px solid transparent; border-radius: var(--radius-card); background: var(--card); color: var(--label); font: 500 13px var(--font); cursor: pointer; box-shadow: var(--shadow-card); }
.theme-opt:active { background: var(--card-2); }
.theme-opt.is-sel { border-color: var(--tint); color: var(--tint); font-weight: 600; }
.theme-swatch { width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto; box-shadow: inset 0 1px 2px rgba(255,255,255,.5), inset 0 0 0 1px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.15); }
.theme-check { display: none; }

/* ---------- Pending (offline) banner ---------- */
.pending-banner { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; padding: 10px 18px; border-radius: 20px; color: var(--tint); font-size: 14px; font-weight: 500; border: none; cursor: pointer; max-width: 90%; text-align: center; transition: opacity .1s ease; }
.pending-banner:active { opacity: .6; }
.pending-banner[hidden] { display: none; }

/* ---------- Recording controls: pause + level meter ---------- */
.rec-controls { display: flex; justify-content: center; align-items: center; gap: 32px; }
.ctrl-btn { width: 60px; height: 60px; border-radius: 50%; border: none; color: var(--label); display: grid; place-items: center; cursor: pointer; transition: transform .1s ease, opacity .1s ease; }
.ctrl-btn[hidden] { display: none; }
.ctrl-btn:active { transform: scale(.94); opacity: .7; }
.cancel-btn { margin-top: 20px; background: none; border: none; color: var(--red); font: 400 16px var(--font); cursor: pointer; padding: 8px 14px; border-radius: 14px; transition: opacity .1s ease; }
.cancel-btn[hidden] { display: none; }
.cancel-btn:active { opacity: .4; }
.level-meter { display: flex; align-items: center; justify-content: center; gap: 3px; height: 40px; margin-bottom: 18px; }
.level-meter[hidden] { display: none; }
.level-meter span { width: 3px; height: 12%; background: var(--red); border-radius: 2px; transition: height .08s linear; }

/* ---------- Notes search (Glas-Kapsel + KI-Button) ---------- */
.search-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 18px; }
.search-row:has(> .search-wrap[hidden]) { display: none; }
.search-wrap { position: relative; flex: 1 1 auto; display: flex; align-items: center; gap: 9px; border-radius: 22px; padding: 0 8px 0 15px; height: 44px; }
.search-wrap[hidden] { display: none; }
.search-wrap:focus-within { outline: 2px solid color-mix(in srgb, var(--tint) 55%, transparent); outline-offset: -1px; }
.search-ic { color: var(--label-2); flex: 0 0 auto; width: 19px; height: 19px; }
.search-input { flex: 1 1 auto; width: 100%; border: none; background: transparent; outline: none; font: 17px var(--font); color: var(--label); }
.search-input::placeholder { color: var(--label-3); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear { border: none; background: var(--fill); color: var(--label-2); font-size: 17px; line-height: 1; cursor: pointer; width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; transition: opacity .1s ease; }
.search-clear:active { opacity: .6; }
.search-clear[hidden] { display: none; }

/* ---------- Suchtreffer, Pin ---------- */
mark { background: color-mix(in srgb, var(--tint) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.pin-ic { color: var(--tint); margin-right: 5px; vertical-align: -1px; }

/* ---------- KI-Chips (Übersetzen, Sprachen) ---------- */
.ai-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border: none; border-radius: 16px; background: var(--fill); color: var(--label); font: 500 14px var(--font); cursor: pointer; transition: opacity .1s ease; }
.ai-chip:active { opacity: .6; }
.lang-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 14px; }
.lang-row[hidden] { display: none; }
.lang-row .ai-chip { background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); }

/* ---------- Karaoke ---------- */
.seg { border-radius: 5px; transition: background-color .18s ease, color .18s ease; }
.seg-active { background: color-mix(in srgb, var(--tint) 20%, transparent); color: var(--label); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 20%, transparent); }

/* ---------- Notizen fragen (KI-Button neben der Suche) ---------- */
.ask-btn { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; border: none; border-radius: 50%; background: var(--tint); color: var(--on-tint); cursor: pointer; box-shadow: inset 0 1px 1px rgba(255,255,255,.35), 0 5px 14px color-mix(in srgb, var(--tint) 35%, transparent); transition: opacity .1s ease, transform .1s ease; }
.ask-btn:active { opacity: .8; transform: scale(.94); }
.ask-btn[hidden] { display: none; }
.ask-btn:focus-visible { outline: 2px solid var(--tint); outline-offset: 3px; }
.ask-panel { text-align: center; }
.ask-panel .ob-text { margin-bottom: 4px; }
.ask-answer { margin-top: 16px; text-align: left; background: var(--card-2); box-shadow: none; }
.ask-answer[hidden] { display: none; }

/* ---------- Papierkorb ---------- */
.trash-info { flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.trash-info .cat-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-date { font-size: 12px; color: var(--label-2); }
.trash-clear { margin-top: 14px; color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }

/* ---------- Audio-Import ---------- */
.import-btn { margin-top: 14px; color: var(--label-2); }

/* ---------- Onboarding ---------- */
.onboard { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: var(--scrim); opacity: 0; transition: opacity .25s ease; }
.onboard[hidden] { display: none; }
.onboard.is-open { opacity: 1; }
.onboard-panel { width: min(440px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; background: var(--card); border-radius: 34px; padding: 36px 28px 22px; box-shadow: var(--shadow-float); transform: translateY(14px) scale(.98); transition: transform .3s cubic-bezier(.32,.72,0,1); }
.onboard.is-open .onboard-panel { transform: none; }
.ob-slide { display: none; text-align: center; }
.ob-slide.is-active { display: block; }
.ob-icon { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 24px; display: grid; place-items: center; background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); box-shadow: inset 0 1px 1px rgba(255,255,255,.35); }
.ob-title { font-size: 24px; font-weight: 700; letter-spacing: .2px; margin-bottom: 10px; }
.ob-text { font-size: 15px; line-height: 1.55; color: var(--label-2); }
.ob-text + .ob-text { margin-top: 10px; }
.ob-text a { color: var(--tint); text-decoration: none; font-weight: 500; }
.ob-field { margin: 18px 0 0; background: var(--card-2); box-shadow: none; text-align: left; }
.ob-foot { font-size: 13px; color: var(--label-3); line-height: 1.45; margin-top: 12px; }
.ob-cats { list-style: none; margin-top: 16px; text-align: left; background: var(--card-2); border-radius: var(--radius-card); overflow: hidden; }
.ob-cat { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 12px; position: relative; }
.ob-cat::after { content: ""; position: absolute; left: 54px; right: 0; bottom: 0; border-bottom: 0.5px solid var(--sep); }
.ob-cat:last-child::after { display: none; }
.ob-cat .cat-item-icon { width: 30px; height: 30px; border-radius: 9px; }
.ob-cat-name { flex: 1 1 auto; font-size: 16px; color: var(--label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-cat-del { width: 32px; height: 32px; border: none; background: transparent; color: var(--label-2); font-size: 22px; line-height: 1; border-radius: 50%; cursor: pointer; flex: 0 0 auto; transition: opacity .1s ease; }
.ob-cat-del:active { opacity: .5; }
.ob-cat-empty { padding: 14px 16px; font-size: 14px; color: var(--label-2); }
.ob-cat-add { margin-top: 12px; }
.ob-cat-add .ob-field { margin: 0; }
.ob-icon-grid { margin-top: 10px; background: var(--card-2); box-shadow: none; }
.ob-cat-add-btn { width: 100%; margin-top: 10px; }
@media (hover: hover) {
  .ob-cat-del:hover { background: var(--fill); color: var(--red); }
}

.ob-dots { display: flex; justify-content: center; gap: 7px; margin: 24px 0 12px; }
.ob-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fill); transition: background-color .2s ease; }
.ob-dot.is-active { background: var(--tint); }
.ob-skip { display: block; margin: 6px auto 0; }

/* ---------- Hover (Maus/Trackpad: iPad-Pointer & Desktop) ---------- */
@media (hover: hover) {
  .set-row:hover, .cat-choice:hover, .icon-opt:hover, .group-head:hover, .search-clear:hover { background: var(--fill-2); }
  .note-card:hover { background: var(--card-2); }
  .icon-btn:hover, .aud-mute:hover { background: var(--fill-2); }
  .icon-btn.tonal:hover { background: color-mix(in srgb, var(--tint) 22%, transparent); }
  .filled-btn:hover, .sum-btn:hover, .aud-btn:hover, .ask-btn:hover { filter: brightness(1.07); }
  .tonal-btn:hover, .outlined-btn:hover, .audio-toggle:hover, .cat-chip:hover, .pending-banner:hover { background: color-mix(in srgb, var(--tint) 22%, transparent); }
  .cat-chip.is-empty:hover { background: var(--fill); }
  .link-btn:hover, .cancel-btn:hover, .snackbar-action:hover { opacity: .7; }
  .tab:hover { color: var(--label); }
  .tab.is-active:hover { color: var(--tint); }
  .mode-opt:not(.is-sel):hover { background: var(--fill-2); }
  .theme-opt:hover { background: var(--card-2); }
  .fab-record:hover { filter: brightness(1.06); }
  .ctrl-btn:hover { filter: brightness(1.05); }
}

/* ---------- Tablet & Desktop: Seiten-Rail + breiter Inhalt ---------- */
@media (min-width: 700px) {
  :root { --rail-w: 96px; --content-w: 720px; }

  .app { max-width: none; padding-left: var(--rail-w); }
  .appbar-inner, .view { max-width: var(--content-w); margin: 0 auto; }
  .appbar-inner { padding: 0 16px; }
  .appbar { margin-left: calc(0px - var(--rail-w)); padding-left: var(--rail-w); }

  /* Tab-Bar wird zur vertikalen Glas-Rail am linken Rand */
  .navbar { left: 16px; right: auto; top: 50%; bottom: auto; transform: translateY(-50%); width: 68px; height: auto; flex-direction: column; padding: 10px 6px; gap: 4px; border-radius: 34px; }
  .tab { flex: 0 0 auto; padding: 8px 0; }

  /* Untere Fix-Elemente: kein Balken mehr unten, an Inhaltsmitte ausrichten */
  .view { padding-bottom: 48px; }
  #view-notes.is-active { padding-bottom: 84px; }
  #view-detail.is-active { padding-bottom: 110px; }
  #view-home.is-active { min-height: calc(100dvh - var(--safe-t) - var(--appbar-h)); }
  .notes-count-bar { left: calc(50% + var(--rail-w) / 2); bottom: calc(var(--safe-b) + 20px); }
  .detail-action-bar { left: calc(50% + var(--rail-w) / 2); bottom: calc(var(--safe-b) + 20px); max-width: 420px; }
  .snackbar { left: calc(50% + var(--rail-w) / 2); bottom: calc(var(--safe-b) + 24px); }

  /* Notizen mehrspaltig */
  .group-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
  .note-card { height: 100%; }

  /* Sheet wird zum zentrierten Dialog */
  .sheet-panel { bottom: auto; top: 50%; width: 420px; border-radius: 28px; padding: 0 16px 16px; transform: translate(-50%, -46%); opacity: 0; transition: transform .25s cubic-bezier(.32,.72,0,1), opacity .2s ease; }
  .sheet.is-open .sheet-panel { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-handle { visibility: hidden; }

  .rec-timer { font-size: 64px; }
}

@media (min-width: 1100px) {
  :root { --content-w: 960px; }
}

/* ---------- Detail audio player ---------- */
.detail-audio { margin-top: 16px; }
.audio-toggle { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 19px; border: none; background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); font: 500 15px var(--font); cursor: pointer; transition: opacity .1s ease; }
.audio-toggle:active { opacity: .6; }
.audio-toggle .audio-chev { color: currentColor; transition: transform .2s ease; }
.audio-toggle.open .audio-chev { transform: rotate(180deg); }
.audio-player { display: none; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 16px; background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.audio-player.open { display: flex; }
.aud-btn { width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--tint); color: var(--on-tint); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; box-shadow: inset 0 1px 1px rgba(255,255,255,.35); }
.aud-btn:active { transform: scale(.95); }
.aud-mute { width: 40px; height: 40px; border-radius: 50%; border: none; background: transparent; color: var(--label-2); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.aud-mute:active { background: var(--fill-2); }
.aud-seek { flex: 1 1 auto; accent-color: var(--tint); height: 4px; cursor: pointer; }
