/* Wiederverwendbare Bausteine: Buttons, Karten, Abzeichen, Formulare, Dialoge … */

/* ---------- Seitenkopf ---------- */
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px 20px; margin-bottom: 22px;
}
.page-head-text { min-width: 0; flex: 1 1 320px; }
.page-intro { color: var(--text-muted); margin-top: 8px; max-width: 62ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.eyebrow {
  font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 8px;
}
.back {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap);
  color: var(--text-muted); font-weight: 500; margin: -6px 0 6px -6px; padding-right: 10px;
}
.back:hover { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 13px;
  font-weight: 600; font-size: 15px; white-space: nowrap;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .1s, color .15s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-quiet { color: var(--text-muted); }
.btn-quiet:hover { color: var(--text); background: var(--surface-2); }
.btn-danger { background: var(--signal-rust); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-danger-quiet { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; }
.btn-danger-quiet:hover { background: var(--danger-soft); }
.btn-glass {
  background: rgba(238, 234, 224, .14); color: var(--leeway-natural);
  border-color: rgba(238, 234, 224, .22);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.btn-glass:hover { background: rgba(238, 234, 224, .22); }
.btn-icon { width: var(--tap); padding: 0; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.link-more { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 14px; font-weight: 500; min-height: 36px; }
.link-more .icon { width: 16px; height: 16px; transition: transform .15s; }
.link-more:hover { color: var(--gold); }
.link-more:hover .icon { transform: translateX(2px); }

/* ---------- Segment-Umschalter ---------- */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 13px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: 10px;
  color: var(--text-muted); font-weight: 600; font-size: 14px;
}
.segmented button .icon { width: 17px; height: 17px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented.wide { display: flex; flex-wrap: wrap; }
.segmented.wide button { flex: 1 1 120px; justify-content: center; }

/* ---------- Panels & Karten ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-l); padding: 20px;
}
.panel > h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel > h2 .icon { color: var(--gold); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 36px; }
.panel-head h2 { display: flex; align-items: baseline; gap: 10px; }
.panel-head h2 .muted { font-size: 14px; font-weight: 500; }

/* ---------- Abzeichen ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-muted);
  max-width: 100%;
}
.badge .icon { width: 13px; height: 13px; }
.prio-low { background: var(--olive-soft); color: var(--text-muted); }
.prio-medium { background: var(--surface-2); color: var(--text-muted); }
.prio-high { background: var(--accent-soft); color: var(--gold); }
:root[data-theme="light"] .prio-high { background: rgba(200, 175, 124, .28); }
.prio-critical { background: var(--danger-soft); color: var(--danger); }
.status-doing { background: var(--accent-soft); color: var(--gold); }
.status-waiting { background: var(--olive-soft); color: var(--text); }
.due-danger { background: var(--danger-soft); color: var(--danger); }
.due-warn { background: rgba(200, 175, 124, .18); color: var(--warn); }
.due-soft, .due-muted { background: transparent; color: var(--text-muted); padding: 0 2px; }
.project-link { background: transparent; color: var(--text-muted); padding: 0 2px; overflow: hidden; text-overflow: ellipsis; }
.project-link:hover { color: var(--gold); }

.pstatus .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pstatus-active { background: var(--accent-soft); color: var(--gold); }
.pstatus-planning { background: var(--olive-soft); color: var(--text); }
.pstatus-idea { background: var(--surface-2); color: var(--text-muted); }
.pstatus-paused { background: var(--surface-2); color: var(--text-faint); }
.pstatus-done { background: var(--olive-soft); color: var(--good); }

/* ---------- Fortschritt ---------- */
.progress-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.progress { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; min-width: 60px; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--leeway-olive), var(--leeway-sand)); transition: width .4s var(--ease); }
.progress-label { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

/* ---------- Werkzeugleiste: Suche, Chips, Filter ---------- */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 0 14px; min-height: 48px; color: var(--text-faint);
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--gold); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 16px; min-height: 46px; color: var(--text); }
.search input::placeholder { color: var(--text-faint); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px; scroll-padding: 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 15px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-n { font-size: 12px; opacity: .7; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 760px) { .chips { margin: 0; padding: 2px 0; flex-wrap: wrap; } }

/* ---------- Formulare ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; grid-column: span 1; }
.field-wide { grid-column: 1 / -1; }
@media (max-width: 420px) { .form-grid { grid-template-columns: 1fr; } }
.field label { font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
.req { color: var(--gold); }
.hint { font-size: 12.5px; color: var(--text-faint); }
.field input, .field textarea, .select-wrap select {
  width: 100%; min-height: 48px; padding: 11px 14px;
  font-size: 16px; /* verhindert automatisches Zoomen auf dem iPhone */
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.field textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .select-wrap select:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}
.field input[type="date"] { display: flex; align-items: center; }
.field input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px;
  border-right: 1.8px solid var(--text-muted); border-bottom: 1.8px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.select-wrap select { padding-right: 40px; cursor: pointer; }
.select-wrap.compact select { min-height: 40px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; font-weight: 600; background: var(--surface); border-color: var(--border); border-radius: 999px; padding-left: 15px; max-width: 220px; }
@media (max-width: 759px) { .select-wrap.compact select { font-size: 16px; } }
.file-btn { cursor: pointer; margin-top: 12px; }

/* ---------- Dialoge (als Blatt) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto;
  width: min(580px, calc(100vw - 32px));
  max-height: min(860px, calc(100dvh - 48px));
  background: var(--surface); color: var(--text);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .26s var(--ease); }
dialog.sheet::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.sheet-inner { display: flex; flex-direction: column; min-height: 0; flex: 1; max-height: inherit; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 14px 10px 22px; }
.sheet-head h2 { font-family: var(--font-display); font-size: 22px; font-weight: 900; padding-top: 6px; }
.sheet-sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.sheet-body { padding: 8px 22px 18px; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface);
}
.sheet-foot .spacer { flex: 1; }
.confirm-text { color: var(--text-muted); line-height: 1.55; }
.sheet-confirm { width: min(440px, calc(100vw - 32px)); }
@media (max-width: 599px) {
  dialog.sheet {
    width: 100%; max-width: 100%; margin: auto 0 0;
    max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  dialog.sheet[open] { animation: sheet-up .3s var(--ease); }
  .sheet-foot .btn { flex: 1 1 auto; }
  .sheet-foot .spacer { display: none; }
  .sheet-form .sheet-foot .btn-danger-quiet { flex: 0 0 auto; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-more .nav-group-label { color: var(--text-faint); padding: 8px 2px 6px; }
.more-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.sheet-more .nav-item { color: var(--text); background: var(--bg-elev); min-height: 52px; }
.sheet-more .nav-item.is-active { background: var(--accent-soft); }
.sheet-more .nav-item.is-active::before { display: none; }
.sheet-more .nav-item .icon { color: var(--gold); }
.sheet-more .soon { color: var(--gold); border-color: var(--border-strong); }

/* ---------- Hinweise (Toasts) ---------- */
#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 200;
  bottom: calc(env(safe-area-inset-bottom) + 86px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px);
}
@media (min-width: 760px) { #toasts { bottom: calc(env(safe-area-inset-bottom) + 28px); } }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 14px;
  background: var(--leeway-graphite); color: var(--leeway-natural);
  box-shadow: var(--shadow-lift); font-size: 14.5px; font-weight: 500;
  animation: toast-in .25s var(--ease);
  transition: opacity .3s, transform .3s;
}
.toast .icon { color: var(--leeway-sand); width: 18px; height: 18px; }
.toast-danger .icon { color: #F0A27E; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Leerzustand ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 34px 16px; gap: 10px; }
.empty-icon {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--gold); margin-bottom: 6px;
}
.empty-icon .icon { width: 26px; height: 26px; }
.empty h3 { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 22px; }
.empty p { color: var(--text-muted); max-width: 46ch; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 10px; }

/* ---------- Hinweisbox ---------- */
.notice {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--radius-m);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
  margin-bottom: 20px;
}
.notice > .icon { color: var(--gold); width: 24px; height: 24px; }
.notice > div { flex: 1 1 240px; display: flex; flex-direction: column; font-size: 14.5px; }
.notice span { color: var(--text-muted); }

/* ---------- Hinweis „Neue Version verfügbar“ ---------- */
#update-banner {
  position: fixed; z-index: 250; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 12px);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 16px; border-radius: 16px;
  background: var(--leeway-graphite); color: var(--leeway-natural);
  box-shadow: var(--shadow-lift); font-weight: 700; font-size: 14.5px;
  animation: toast-in .3s var(--ease); max-width: calc(100vw - 32px);
}
#update-banner .icon { color: var(--leeway-sand); }
