:root {
  --bg: #fbfaf7;
  --fg: #1d1d1b;
  --muted: #6f6b64; /* ≥ 4,5:1 auf Hintergrund und Karten */
  --danger: #b44a33;
  --faint: #c9c5bd;
  --line: #ebe8e1;
  --card: #ffffff;
  --accent: #1d1d1b;
  --sheet: #fbfaf7;
  --shadow: 0 -8px 40px rgba(0, 0, 0, .08);
  --fs: 1.1176rem;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Inter", "Segoe UI", Roboto, sans-serif;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --fg: #e9e7e2;
    --muted: #969390;
    --danger: #e0745c;
    --faint: #4a4844;
    --line: #262523;
    --card: #1a1a19;
    --accent: #e9e7e2;
    --sheet: #161615;
    --shadow: 0 -8px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121212;
  --fg: #e9e7e2;
  --muted: #969390;
  --danger: #e0745c;
  --faint: #4a4844;
  --line: #262523;
  --card: #1a1a19;
  --accent: #e9e7e2;
  --sheet: #161615;
  --shadow: 0 -8px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

:root[data-font="serif"] { --font: "New York", "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif; }
:root[data-font="mono"] { --font: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Grösserer Text: in der iOS-App folgt die Grundgrösse der Textgrösse aus den iOS-Einstellungen
   (Standard 17px); alle Schriftgrössen sind in rem und wachsen mit. */
html { font-size: 17px; }
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
}

body {
  font-size: .9412rem; /* früherer Standard 16px */
  line-height: normal;
  font-weight: 400;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }

/* ---------- Editor ---------- */

#editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 18px + 2.2353rem) max(24px, env(safe-area-inset-right)) 96px max(24px, env(safe-area-inset-left)); /* wächst mit der Textgrösse (unter dem Hinweis) */
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  will-change: transform;
}

#editor { overscroll-behavior: none; position: relative; }

/* Logo ganz leise im Hintergrund */
body::before {
  content: "";
  position: fixed;
  left: 50%;
  top: 46%;
  width: min(52vw, 240px);
  aspect-ratio: 524 / 419;
  transform: translate(-50%, -50%);
  background: var(--fg);
  -webkit-mask: url("icons/mark.png") center / contain no-repeat;
  mask: url("icons/mark.png") center / contain no-repeat;
  opacity: .06;
  pointer-events: none;
  z-index: 0;
}
#editor, .menu, .status, .banner { z-index: 1; }

/* #Kategorie-Vorschläge über der Tastatur */
.suggest {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 50px);
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 6;
  -webkit-overflow-scrolling: touch;
}
.suggest[hidden] { display: none; }
.suggest::-webkit-scrollbar { display: none; }
.suggest-chip {
  flex: none;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 0.8235rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
.suggest-chip.cat { color: var(--fg); border-color: var(--faint); }

#note {
  flex: none;
  width: 100%;
  min-height: 3em;
  overflow: hidden;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.6;
  caret-color: var(--fg);
  padding: 0;
}

#note::placeholder { color: var(--faint); }

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
}
.thumbs:empty { display: none; }

.note-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: 3px;
  word-break: break-all;
}
.note-link:active { text-decoration-color: var(--fg); }

.links { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; }
.links:empty { display: none; }
.links .note-link {
  text-decoration: none;
  font-size: 0.7941rem;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 12px;
  word-break: normal;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#editor .tap-area { flex: 1; min-height: 30vh; cursor: text; }

.thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb button {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 0.8235rem;
  line-height: 22px;
}

/* ---------- Status & banner ---------- */

.status {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 18px);
  left: 0; right: 0;
  text-align: center;
  font-size: 0.7059rem;
  letter-spacing: .04em;
  color: var(--muted);
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}
.status.show { opacity: 1; }

.banner {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 0.7647rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 14px;
  background: var(--bg);
  z-index: 5;
  width: max-content;
  max-width: calc(100% - 32px);
}
.banner[hidden] { display: none; }
.banner #banner-close { width: 24px; height: 24px; font-size: 0.9412rem; }

/* ---------- Bottom menu ---------- */

.menu {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  gap: clamp(14px, 6vw, 32px);
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  font-size: 0.7647rem;
  letter-spacing: .06em;
  transition: opacity .35s ease;
  z-index: 4;
}

.menu button, .menu .menu-btn {
  color: var(--muted);
  padding: 8px 4px;
  cursor: pointer;
  user-select: none;
}
.menu button:active, .menu .menu-btn:active { color: var(--fg); }

body.typing .menu { opacity: .45; }
body.typing .menu:hover, body.typing .menu:focus-within { opacity: 1; }

/* ---------- Sheet ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
}
.overlay[hidden] { display: none; }

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .25);
  animation: fade .2s ease;
}

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: 720px;
  margin: 0 auto;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--sheet);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  animation: up .28s cubic-bezier(.2, .8, .2, 1);
}

.sheet-grip {
  flex: none;
  display: block;
  width: 100%;
  height: 22px;
  cursor: pointer;
  position: relative;
}
.sheet-grip::after {
  content: "";
  position: absolute;
  left: 50%; top: 9px;
  width: 36px; height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: var(--faint);
}

.sheet-body {
  overflow-y: auto;
  padding: 4px 20px calc(env(safe-area-inset-bottom) + 28px);
  -webkit-overflow-scrolling: touch;
}

@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Sheet content ---------- */

.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 14px;
}
.head h2 { font-size: 1.1765rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.head .nav { display: flex; gap: 4px; color: var(--muted); }
.head .nav button { padding: 4px 10px; font-size: 1.0588rem; color: var(--muted); }
.head .nav button:disabled { opacity: .3; }

.summary { color: var(--muted); font-size: 0.8235rem; line-height: 1.5; margin-bottom: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.chip {
  font-size: 0.7647rem;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
}
.chip.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 12px;
  font-size: 0.7647rem;
  color: var(--muted);
}
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { padding: 5px 12px; color: var(--muted); }
.seg button.on { background: var(--line); color: var(--fg); }

.cards { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px 10px;
  touch-action: pan-y;
}
.card.dragging, .swipe.dragging .card { opacity: .6; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
.card.archived { opacity: .55; }

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7059rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.card-top .grow { flex: 1; }
.card-top .handle { cursor: grab; padding: 2px 6px; font-size: 0.8235rem; letter-spacing: -2px; touch-action: none; }

.card-text {
  font-family: var(--font);
  font-size: 0.9118rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  cursor: pointer;
}
.card-text.empty { color: var(--muted); font-style: italic; }

.card .thumbs { padding-top: 8px; }
.card .thumb { width: 60px; height: 60px; }

.card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  font-size: 0.7353rem;
}
.card-actions button { color: var(--muted); padding: 4px 8px 4px 0; margin-right: 10px; }
.card-actions button.on { color: var(--fg); }

select.cat {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.7059rem;
  background: transparent;
  color: var(--muted);
}
select.cat.set { color: var(--fg); border-color: var(--faint); }

.primary {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 500;
}
.primary:disabled { opacity: .35; }

.empty-state { color: var(--muted); text-align: center; padding: 40px 0; font-size: 0.8824rem; }

.day-label {
  font-size: 0.7059rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}

.search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--card);
  outline: none;
  font-size: 0.9412rem;
}

/* ---------- Settings ---------- */

.group { margin: 18px 0 6px; }
.group h3 {
  font-size: 0.7059rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.row {
  display: flex;
  flex-wrap: wrap; /* grosse Schrift: Bedienelement rutscht unter den Titel */
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.8824rem;
}
.row:last-child { border-bottom: 0; }
.row .hint { font-size: 0.7353rem; color: var(--muted); margin-top: 2px; }
.row input[type="time"], .row input[type="number"], .row input[type="email"], .row input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--card);
  font-size: 0.8824rem;
}
.row input[type="number"] { width: 72px; }
.row input[type="email"], .row input[type="text"] { flex: 1; min-width: 0; }
.row input[type="range"] { width: 140px; accent-color: var(--accent); }
.row .link { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 0.8235rem; }
.row .danger { color: var(--danger); font-size: 0.8235rem; }
.small { font-size: 0.7647rem; color: var(--muted); line-height: 1.5; }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: var(--line);
  transition: background .2s;
}
.switch span::after {
  content: ""; position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

.cats { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0; }
.cats .chip button { margin-left: 6px; color: var(--muted); }

/* ---------- Einstellungen: Kopf ---------- */

.about {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 6px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.about-mark {
  width: 48px; height: 48px; flex: none;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  position: relative;
}
.about-mark::after {
  content: ""; position: absolute; inset: 9px;
  background: var(--fg);
  -webkit-mask: url("icons/mark.png") center / contain no-repeat;
  mask: url("icons/mark.png") center / contain no-repeat;
}
.about-text { flex: 1; min-width: 0; }
.about-name { font-size: 1.1765rem; font-weight: 600; letter-spacing: -.01em; }
.about-sub { font-size: 0.7647rem; color: var(--muted); margin-top: 2px; }
.about-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.support-btn {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.8235rem;
  font-weight: 500;
  text-decoration: none;
}
.about-actions a.link { font-size: 0.7353rem; color: var(--muted); }

/* ---------- Erinnerung ---------- */

.remind { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; color: var(--muted); font-size: 0.7353rem; }
.remind-label { position: relative; cursor: pointer; padding: 4px 0; }
.remind-input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.remind.on { color: var(--fg); }
.remind.due { color: var(--danger); }
.remind button { color: var(--muted); padding: 4px 6px; font-size: 0.8235rem; }
.tag { color: var(--muted); font-size: 0.7059rem; }

/* ---------- Woche ---------- */

.mode { margin: -4px 0 14px; }
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 6px 0 18px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.6765rem; color: var(--muted); padding: 6px 0; border-radius: 10px; }
.week-day .dot { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 0.6471rem; color: var(--muted); }
.week-day.has .dot { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.week-day.open .dot { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--danger); }
.week-day.today { color: var(--fg); font-weight: 600; }
.bars { display: flex; flex-direction: column; gap: 7px; margin: 6px 0 16px; }
.bar { display: grid; grid-template-columns: 90px 1fr 28px; align-items: center; gap: 10px; font-size: 0.7647rem; color: var(--muted); }
.bar i { display: block; height: 6px; border-radius: 3px; background: var(--faint); }
.bar span:last-child { text-align: right; }
.section-label { font-size: 0.7059rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
.rediscover .card { border-style: dashed; }

/* ---------- Einführung ---------- */

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 40; /* unter der Face-ID-Sperre */
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 44px) 0 calc(env(safe-area-inset-bottom) + 20px);
}
.ob-skip { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 18px; color: var(--muted); font-size: 0.8824rem; padding: 8px; }
.ob-track {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.ob-track::-webkit-scrollbar { display: none; }
.ob-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  padding: 0 max(24px, calc((100% - 520px) / 2)); /* volle Breite fürs Blättern, Inhalt auf dem iPad schmal */
  overflow-y: auto;
}
.ob-slide img {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 52vh;
  object-fit: cover;
  object-position: top;
  border-radius: 20px;
  border: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
  flex: none;
}
.ob-slide h2 { font-size: 1.4118rem; font-weight: 650; letter-spacing: -.015em; margin: 22px 0 10px; }
.ob-slide ul { margin: 0; padding: 0 0 8px 18px; color: var(--muted); font-size: 0.9118rem; line-height: 1.45; }
.ob-slide li { margin: 6px 0; }
.ob-text { justify-content: center; }
.ob-text h2 { font-size: 1.6471rem; }
.ob-text ul { list-style: none; padding-left: 0; font-size: 1rem; }
.ob-text li { margin: 14px 0; color: var(--fg); }
@media (max-height: 720px) {
  .ob-slide img { max-height: 40vh; }
  .ob-slide h2 { font-size: 1.2353rem; margin: 16px 0 6px; }
  .ob-slide ul { font-size: 0.8529rem; }
  .ob-slide li { margin: 4px 0; }
}
.ob-dots { display: flex; justify-content: center; gap: 8px; margin: 16px 0 4px; }
.ob-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); transition: background .2s, width .2s; }
.ob-dots i.on { background: var(--fg); width: 20px; border-radius: 4px; }
.ob-next { width: auto; margin: 12px 24px 0; }

/* ---------- Sperre ---------- */

.lock {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.lock[hidden] { display: none; }
.lock-mark { width: 3px; height: 34px; border-radius: 2px; background: var(--fg); animation: blink 1.1s steps(1) infinite; }
.lock button { color: var(--muted); font-size: 0.8824rem; padding: 10px 18px; border: 1px solid var(--line); border-radius: 999px; }
.lock-hint { color: var(--muted); font-size: 0.7647rem; min-height: 1em; margin: 0; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Wischen ---------- */

.swipe {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
}
.swipe .card { position: relative; z-index: 1; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 22px;
  font-size: 0.8235rem;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transition: opacity .15s, filter .15s;
}
.swipe-bg-left { justify-content: flex-start; }
.swipe-bg-right { justify-content: flex-end; }
.swipe-bg.archive { background: #6f6b64; }
.swipe-bg.delete { background: #b44a33; }
.swipe[data-dir="right"] .swipe-bg-left,
.swipe[data-dir="left"] .swipe-bg-right { opacity: .75; }
.swipe.armed[data-dir="right"] .swipe-bg-left,
.swipe.armed[data-dir="left"] .swipe-bg-right { opacity: 1; filter: saturate(1.2); }

.swipe-hint { font-size: 0.7059rem; color: var(--muted); text-align: center; margin: 16px 0 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 104px);
  transform: translate(-50%, 20px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-size: 0.8235rem;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 46; /* auch über der Bildansicht */
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast button { color: var(--bg); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}

/* Tastatur (iPad/Mac, „Tastaturbedienung“): sichtbarer Fokus */
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 6px; }
#note:focus-visible, [tabindex="-1"]:focus { outline: none; }
/* Textfelder: kein dicker Rahmen – der Cursor zeigt den Fokus, die Linie wird nur etwas kräftiger */
textarea:focus-visible, select:focus-visible,
input:not([type="checkbox"]):not([type="range"]):not([type="radio"]):focus-visible { outline: none; border-color: var(--muted); }

/* ---------- iPad / grosse Bildschirme (iPhone bleibt unverändert) ---------- */

@media (min-width: 768px) {
  #editor {
    max-width: 880px;
    padding: calc(env(safe-area-inset-top) + 88px) 64px 120px;
  }
  #note { font-size: calc(var(--fs) + 2px); line-height: 1.65; }
  .thumb { width: 96px; height: 96px; }
  body::before { width: min(36vw, 320px); }

  .menu { font-size: 0.8824rem; gap: 44px; padding-bottom: calc(env(safe-area-inset-bottom) + 22px); }
  .suggest { bottom: calc(env(safe-area-inset-bottom) + 60px); justify-content: center; }

  .sheet { max-width: 760px; }
  .sheet-body { padding-left: 32px; padding-right: 32px; }
  .head h2 { font-size: 1.4118rem; }
  .card-text { font-size: 0.9706rem; }
  .summary, .row { font-size: 0.9412rem; }

  .ob-slide img { max-height: 58vh; }
  .ob-slide h2 { font-size: 1.6471rem; }
  .ob-slide ul { font-size: 1rem; }
  .ob-next { width: 360px; align-self: center; }
}

/* iPad quer: Sheet schwebt als Karte statt am Rand zu kleben */
@media (min-width: 1024px) and (orientation: landscape) {
  .sheet {
    bottom: 24px;
    max-height: calc(100dvh - 80px);
    border-radius: 22px;
  }
}

/* ---------- Maus & Trackpad (Mac, iPad mit Trackpad) – auf Touch unsichtbar ---------- */

.kbd-hint { display: none; }
/* Touch: Knöpfe unsichtbar (Wischen), aber für VoiceOver/Sprachsteuerung erreichbar */
.mouse-actions { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (hover: hover) and (pointer: fine) {
  .kbd-hint { display: block; padding-top: 8px; }
  .mouse-actions { position: static; width: auto; height: auto; overflow: visible; clip-path: none; display: flex; gap: 14px; justify-content: flex-end; margin-top: 4px; opacity: 0; transition: opacity .15s; font-size: 0.7353rem; }
  .mouse-actions button { color: var(--muted); padding: 4px 0; }
  .mouse-actions button:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
  .mouse-actions .danger:hover { color: var(--danger); }
  .card:hover .mouse-actions, .card:focus-within .mouse-actions { opacity: 1; }
  .card:hover { border-color: var(--faint); }
  .menu button:hover, .menu .menu-btn:hover { color: var(--fg); }
  .chip:hover, .seg button:hover { color: var(--fg); }
}

/* Einführung in breiten Querformat-Fenstern (Mac, iPad quer): Bild links, Text rechts */
@media (min-width: 900px) and (orientation: landscape) {
  .ob-slide {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 56px;
    padding: 0 64px;
  }
  .ob-slide img { width: auto; height: min(70vh, 640px); max-height: none; aspect-ratio: 4 / 5; }
  .ob-slide h2, .ob-slide ul { max-width: 420px; }
  .ob-slide > h2 { margin-top: 0; }
  .ob-slide:not(.ob-text) { display: grid; grid-template-columns: auto minmax(0, 440px); grid-template-rows: 1fr auto auto 1fr; align-content: center; column-gap: 64px; }
  .ob-slide:not(.ob-text) img { grid-row: 1 / -1; }
  .ob-slide:not(.ob-text) h2 { grid-row: 2; grid-column: 2; font-size: 1.8824rem; margin: 0 0 14px; }
  .ob-slide:not(.ob-text) ul { grid-row: 3; grid-column: 2; font-size: 1.0588rem; }
  .ob-text { flex-direction: column; align-items: flex-start; padding-left: max(64px, calc((100% - 520px) / 2)); }
}

/* iPad-App auf dem Mac: macOS legt beim Schreiben eine graue Leiste (ca. 44 px) unten über das Fenster → Menü darüber */
.mac .menu { bottom: 44px; padding-bottom: 14px; }
.mac .suggest { bottom: 104px; }
.mac .toast { bottom: 150px; }

/* ---------- Bild gross ---------- */
.imgview {
  position: fixed; inset: 0; z-index: 45; /* über Sheets, unter der Face-ID-Sperre */
  background: #0b0b0b;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  animation: imgview-in .18s ease;
  touch-action: none; overflow: hidden; user-select: none; -webkit-user-select: none;
}
.imgview img { max-width: 100%; max-height: calc(100% - 64px); object-fit: contain; border-radius: 8px; will-change: transform; cursor: zoom-in; }
.imgview-bar { display: flex; gap: 12px; margin-top: 16px; position: relative; z-index: 1; }
.imgview-bar button { color: #fff; border: 1px solid rgba(255, 255, 255, .3); border-radius: 999px; padding: 8px 18px; font-size: 0.8824rem; }
.imgview-bar .danger { color: #ff8a73; border-color: rgba(255, 138, 115, .45); }
@keyframes imgview-in { from { opacity: 0; } }

/* ---------- Bild: Kamera oder Mediathek (iOS-App) ---------- */
.pick {
  position: fixed; z-index: 47; transform: translateX(-50%); /* auch über Sheets */
  display: flex; flex-direction: column; min-width: 180px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12); overflow: hidden;
  animation: imgview-in .15s ease;
}
.pick button { padding: 13px 18px; text-align: left; font-size: 0.8824rem; color: var(--fg); }
.pick button + button { border-top: 1px solid var(--line); }
.pick button:active { background: var(--line); }

/* ---------- Kontrast erhöhen (iOS-Einstellung) ---------- */
@media (prefers-contrast: more) {
  :root { --muted: #4f4c46; --faint: #8a867e; --line: #cfcac0; }
  :root[data-theme="dark"] { --muted: #c2bfb8; --faint: #77746e; --line: #44423e; }
  body.typing .menu { opacity: 1; }
  #note::placeholder { color: var(--muted); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --muted: #c2bfb8; --faint: #77746e; --line: #44423e; }
}

/* ---------- Feedback ---------- */
.feedback { padding: 4px 0 12px; }
.feedback[hidden] { display: none; }
.feedback-text {
  display: block; width: 100%; resize: vertical; min-height: 96px;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  background: var(--card); font-size: 0.8824rem; line-height: 1.45;
}
.feedback .primary { margin-top: 10px; }

.card-actions:empty { display: none; }
