/* Tagwerk – warmes Papier, Serifen, Bernstein */
:root {
  --paper: #F3EDE5; --paper-deep: #EDE6D8; --card: #FFFDF8; --card-raised: #FFFFFF;
  --ink: #2A2622; --ink-2: #78705F; --amber: #C27A1F; --amber-soft: #F3E3C6; --line: #E3DACA;
  --danger: #D9382E; --shadow: 0 2px 6px rgba(0,0,0,.05);
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --rounded: ui-rounded, -apple-system, system-ui, sans-serif;
  --radius: 16px; --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17150F; --paper-deep: #211E17; --card: #2A2620; --card-raised: #332E27;
    --ink: #EFE8DA; --ink-2: #A89F8E; --amber: #E39A3A; --amber-soft: #3D2F18; --line: #3A342B;
    --shadow: 0 2px 8px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 17px; overscroll-behavior-y: none; }
body { -webkit-text-size-adjust: 100%; -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; font-family: inherit; font-size: inherit; color: inherit; }
button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.hidden { display: none !important; }
svg.i { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }

#app { display: flex; flex-direction: column; height: 100dvh; height: 100vh; }
@supports (height: 100dvh) { #app { height: 100dvh; } }
#views { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-top: env(safe-area-inset-top); }
.view { padding: 8px 0 24px; min-height: 100%; }

/* Kopfzeilen */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 20px 0; }
.wordmark { display: inline-flex; align-items: center; gap: 6px; color: var(--amber); font: italic 700 15px var(--serif); }
.screen-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 20px 10px; }
.screen-head h1 { margin: 0; font: 700 34px/1.1 var(--serif); }
.screen-head .sub { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; }
.day-head { padding: 10px 16px 8px; text-align: center; }
.day-head .row { display: flex; align-items: center; justify-content: space-between; }
.weekday { font: 600 12px var(--rounded); letter-spacing: 2px; text-transform: uppercase; color: var(--amber); }
.day-title { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 0; font: 700 26px/1.15 var(--serif); color: var(--ink); }
.day-title .chev { color: var(--ink-2); font-size: 12px; }
.day-meta { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }

/* Knöpfe */
.round { width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--card); border: 1px solid var(--line); color: var(--amber); flex: none; }
.round.small { width: 36px; height: 36px; color: var(--ink-2); }
.round.filled { background: var(--amber); border-color: transparent; color: #fff; box-shadow: 0 3px 8px rgba(194,122,31,.35); }
.round.muted { color: var(--ink-2); }
.round:active { transform: scale(.95); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font: 600 13px var(--rounded); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; background: var(--amber); color: #fff; font-weight: 600; }
.btn.secondary { background: var(--card); color: var(--amber); border: 1px solid var(--line); }
.btn.danger { background: rgba(217,56,46,.12); color: var(--danger); }
.btn.block { width: 100%; }
.textbtn { color: var(--amber); font-weight: 600; padding: 8px; }

/* Karten */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.entry { display: flex; gap: 12px; padding: 14px; margin: 0 16px 10px; }
.entry .stripe { width: 4px; border-radius: 2px; flex: none; }
.entry .body { flex: 1; min-width: 0; }
.entry .head { display: flex; align-items: center; gap: 6px; font: 700 12px var(--rounded); }
.entry .head .time { margin-left: auto; color: var(--ink-2); font-weight: 400; font-variant-numeric: tabular-nums; }
.entry .text { margin: 6px 0 0; white-space: pre-wrap; word-wrap: break-word; line-height: 1.35; }
.entry .reminder { margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ring { background: transparent !important; border: 1.5px solid currentColor; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--paper-deep); flex: none; }
mark { background: rgba(194,122,31,.28); color: inherit; font-weight: 700; border-radius: 3px; }

/* Leerzustand */
.empty { text-align: center; padding: 20px 32px; }
.empty img { width: 100%; max-width: 300px; border-radius: 22px; box-shadow: 0 6px 14px rgba(0,0,0,.08); }
.empty h2 { margin: 14px 0 6px; font: 600 20px var(--serif); }
.empty p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.4; }

/* Chips */
.chips-wrap { position: relative; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font: 500 15px var(--rounded); white-space: nowrap; color: var(--ink); flex: none; }
.chip.compact { padding: 6px 10px; font-size: 13px; }
.chip .dot { width: 11px; height: 11px; }
.chip.on { font-weight: 700; border-width: 1.5px; }

/* Eingabeleiste */
.inputbar { background: var(--paper-deep); border-top: 1px solid var(--line); padding: 10px 0 8px; }
.pending { display: flex; gap: 8px; padding: 6px 16px 0; overflow-x: auto; }
.pending .p { position: relative; flex: none; }
.pending img { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; }
.pending .rm { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.input-row { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px 0; }
.input-row .round, .input-row .mic { width: 40px; height: 40px; }
.input-row textarea { flex: 1; min-width: 0; min-height: 40px; max-height: 130px; resize: none; padding: 9px 12px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); line-height: 1.3; outline: none; font-size: 16px; }
.input-row textarea::placeholder { color: var(--ink-2); opacity: .8; }
.input-row textarea:focus { border-color: var(--amber); box-shadow: 0 0 0 .5px var(--amber); }
.mic { width: 42px; height: 42px; border-radius: 50%; background: var(--amber); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 3px 8px rgba(194,122,31,.35); position: relative; flex: none; }
.mic.rec { background: var(--danger); box-shadow: 0 3px 8px rgba(217,56,46,.35); }
.mic.rec::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid rgba(217,56,46,.35); animation: pulse 1.1s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: 1; } to { transform: scale(1.45); opacity: 0; } }
.status { padding: 6px 16px 0; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.status.err { color: var(--danger); }
.status.rec { color: var(--danger); }
.status a, .status button { color: var(--amber); font-weight: 600; font-size: 13px; margin-left: auto; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--amber); color: #fff; font: 700 11px var(--rounded); display: flex; align-items: center; justify-content: center; }

/* Tab-Leiste */
#tabbar { display: flex; justify-content: space-around; background: var(--paper-deep); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
#tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 14px; border-radius: 14px; color: var(--ink); font: 500 11px var(--rounded); min-width: 72px; }
#tabbar button svg.i { width: 24px; height: 24px; }
#tabbar button.on { color: var(--amber); background: var(--amber-soft); }
body.kb #tabbar { display: none; }

/* Kalender */
.cal-nav { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 10px; }
.cal-nav h2 { margin: 0; font: 700 22px var(--serif); }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 0 12px; }
.weekdays span { text-align: center; font: 600 12px var(--rounded); color: var(--ink-2); }
.weekdays span.we { color: var(--amber); }
.grid { margin-top: 6px; row-gap: 6px; }
.cell { height: 56px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px solid transparent; }
.cell.has { background: var(--card); border-color: var(--line); }
.cell .n { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 500 16px var(--rounded); font-variant-numeric: tabular-nums; }
.cell.we .n { color: var(--ink-2); }
.cell.today .n { background: var(--amber); color: #fff; font-weight: 700; }
.cell.sel:not(.today) .n { border: 1.5px solid var(--amber); }
.cell .dots { display: flex; gap: 3px; height: 8px; align-items: center; }
.cell .dots .dot { width: 6px; height: 6px; }
.cell .dots .more { font: 700 9px var(--rounded); color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 14px 20px 0; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

/* Suche */
.searchfield { display: flex; align-items: center; gap: 8px; margin: 0 16px; padding: 11px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.searchfield:focus-within { border-color: var(--amber); box-shadow: 0 0 0 .5px var(--amber); }
.searchfield input { flex: 1; border: 0; background: none; outline: none; min-width: 0; }
.searchfield svg { color: var(--ink-2); flex: none; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 20px 6px; font: 600 12px var(--rounded); letter-spacing: 1px; text-transform: uppercase; color: var(--amber); }
.group-head small { color: var(--ink-2); text-transform: none; letter-spacing: 0; font-weight: 400; }
.section-label { padding: 12px 20px 6px; font: 600 12px var(--rounded); letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-2); }

/* Termine */
.appt { display: flex; gap: 14px; padding: 14px; margin: 0 16px 10px; }
.appt .when { width: 84px; flex: none; }
.appt .when .rel { font: 600 12px var(--rounded); text-transform: uppercase; color: var(--amber); }
.appt .when .t { font: 700 20px var(--rounded); font-variant-numeric: tabular-nums; }
.appt .when .d { font-size: 12px; color: var(--ink-2); }
.appt .bar { width: 3px; border-radius: 2px; flex: none; }
.appt.past { opacity: .72; }
.appt .body { flex: 1; min-width: 0; }
.appt .body .cat { display: flex; align-items: center; gap: 6px; font: 700 12px var(--rounded); }
.appt .body .text { margin: 4px 0 0; }
.appt .body .rem { margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.banner { display: flex; align-items: center; gap: 10px; margin: 0 16px 10px; padding: 12px; border-radius: 12px; background: var(--amber-soft); font-size: 13px; }
.banner > span { flex: 1; min-width: 0; }
.banner > .i { flex-shrink: 0; }
.banner .pill { flex-shrink: 0; background: var(--card); }

/* Dialoge */
dialog { border: 0; padding: 0; background: var(--paper); color: var(--ink); width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.sheet { display: flex; flex-direction: column; height: 100%; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
.sheet-head h2 { margin: 0; font: 600 17px var(--sans); }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 16px calc(40px + env(safe-area-inset-bottom)); }
.sheet-body .section-label { padding: 16px 0 8px; }
.sheet-body .section-label:first-child { padding-top: 4px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.box .rowi { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.box .rowi + .rowi { border-top: 1px solid var(--line); }
.box textarea { width: 100%; border: 0; background: none; resize: none; min-height: 84px; outline: none; line-height: 1.35; }
.box input[type=date], .box input[type=time], .box select { background: var(--paper-deep); border: 0; border-radius: 8px; padding: 6px 10px; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: #c9c3b6; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--amber); }
.switch input:checked + span::before { transform: translateX(20px); }
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.photo-grid .ph { position: relative; aspect-ratio: 1; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.photo-grid .rm { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.photo-grid .add { aspect-ratio: 1; border: 1px dashed var(--line); border-radius: 10px; background: var(--card); color: var(--amber); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font: 600 11px var(--rounded); }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.list .item + .item { border-top: 1px solid var(--line); }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .cnt { color: var(--ink-2); font-size: 13px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; flex: none; }
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.palette button { width: 38px; height: 38px; border-radius: 50%; justify-self: center; position: relative; }
.palette button.on::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2.5px solid var(--ink); }
.palette button.on::before { content: "✓"; color: #fff; font-weight: 700; }
.muted { color: var(--ink-2); font-size: 13px; }
.center { text-align: center; }
.foot { padding: 6px 2px 0; font-size: 12px; color: var(--ink-2); line-height: 1.4; }

/* Fotoanzeige */
#viewer { background: #000; color: #fff; }
#viewer .vbar { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; z-index: 2; }
#viewer .vbar .round { background: rgba(255,255,255,.18); border: 0; color: #fff; }
#viewer .pages { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
#viewer .pages::-webkit-scrollbar { display: none; }
#viewer .page { flex: none; width: 100%; height: 100%; scroll-snap-align: start; display: flex; align-items: center; justify-content: center; }
#viewer .page img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 90px); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; pointer-events: auto; }
#toast button { color: var(--amber); font-weight: 700; margin-left: 10px; }
