/* Haushalt – Layout und Komponenten. Farben/Formen kommen aus tokens-*.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: var(--body-weight);
  font-size: 17px;
  line-height: 1.35;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* UI-Elemente nicht markierbar, Inhalte schon */
.tabbar,
.btn,
.tab,
.row,
.section-title,
.page-header {
  -webkit-user-select: none;
  user-select: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------- Grundgerüst */

:root {
  --gutter: 16px;
  --tabbar-h: 50px;
  --content-max: 680px;
  --pad-left: max(var(--gutter), env(safe-area-inset-left));
  --pad-right: max(var(--gutter), env(safe-area-inset-right));
  --sidebar-w: 0px;
}

.page {
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad-right)
    calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 32px) var(--pad-left);
  margin-left: var(--sidebar-w);
}

.page-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  margin: 8px 0 14px;
}

.large-title {
  font-family: var(--font-title);
  font-size: var(--title-size);
  font-weight: var(--title-weight);
  letter-spacing: var(--title-tracking);
  line-height: 1.1;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-top: 2px;
}

/* ------------------------------------------------------------- Tab-Bar */

.tabbar {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  padding: 4px var(--pad-right) env(safe-area-inset-bottom) var(--pad-left);
  background: var(--surface-blur);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}

.tabbar-brand {
  display: none;
}

.tab {
  flex: 1;
  max-width: 120px;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--tab-inactive);
  font-size: 10.5px;
  font-weight: var(--strong-weight);
  transition: color 0.15s, background-color 0.2s;
}

.tab .icon {
  font-size: 25px;
}

.tab[aria-current="page"] {
  color: var(--tab-active);
}

/* ------------------------------------------------------------- Icons */

.icon {
  display: inline-flex;
  width: 1em;
  height: 1em;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex: none;
}

.icon-svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-emoji {
  font-size: 0.92em;
  font-style: normal;
}

[data-theme="clean"] .icon-emoji,
[data-theme="playful"] .icon:not(.is-svg-only) > .icon-svg {
  display: none;
}

/* ------------------------------------------------------------- Karten/Listen */

.section-title {
  margin: 22px 16px 7px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: var(--body-weight);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.section-title.is-danger {
  color: var(--danger);
}

.section-title.is-warning {
  color: var(--warning);
}

.section-footer {
  margin: 7px 16px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card + .card {
  margin-top: 14px;
}

.card-pad {
  padding: 16px;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 16px;
  color: inherit;
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
}

.row + .row::before,
.card > :not(:first-child) > .row:first-of-type::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: var(--row-sep-inset, 16px);
  border-top: 0.5px solid var(--separator);
}

.card.has-icons {
  --row-sep-inset: 58px;
}

a.row:active,
button.row:active {
  background: var(--surface-2);
}

.row-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-s);
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  flex: none;
}

[data-theme="playful"] .row-icon {
  background: var(--surface-2);
  font-size: 19px;
}

.row-icon.is-green {
  background: var(--success);
}

.row-icon.is-orange {
  background: var(--warning);
}

.row-icon.is-red {
  background: var(--danger);
}

.row-icon.is-purple {
  background: var(--accent-2);
}

.row-body {
  flex: 1;
  min-width: 0;
}

.row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 1px;
}

.row-sub .is-danger {
  color: var(--danger);
}

.row-sub .is-warning {
  color: var(--warning);
}

.row-trailing {
  color: var(--text-muted);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.row-chevron {
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 17px;
}

.amount {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: var(--strong-weight);
}

/* Zeile, deren Inhalt ein Button ist (öffnet Details) */
.row-button {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

span.row-title,
span.row-sub {
  display: block;
}

button.row.row-button {
  display: flex;
  padding: 8px 16px;
}

.row-icon.is-muted {
  background: var(--surface-2);
  color: var(--text-muted);
}

.row-trailing.is-overdue {
  color: var(--danger);
}

.row-trailing.is-today {
  color: var(--warning);
}

.note {
  white-space: pre-wrap;
  color: var(--text-muted);
  font-size: 15px;
  padding: 4px 0;
}

/* ------------------------------------------------------------- Putzplan */

.task-group.is-overdue .section-title,
.task.is-overdue .due {
  color: var(--danger);
}

.task-group.is-today .section-title,
.task.is-today .due {
  color: var(--warning);
}

/* Abhak-Kreis: 28px sichtbar, 44px Tippfläche */
.check {
  position: relative;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--separator);
  background: none;
  padding: 0;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}

.check::after {
  content: "";
  position: absolute;
  inset: -8px;
}

.task.is-overdue .check {
  border-color: var(--danger);
}

.task.is-today .check {
  border-color: var(--warning);
}

/* Häkchen (per CSS gezeichnet) */
.check::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 3px;
  width: 7px;
  height: 13px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.18s ease-out;
}

.task.is-completing .check {
  background: var(--success);
  border-color: var(--success);
}

.task.is-completing .check::before {
  transform: rotate(45deg) scale(1);
}

.task.is-completing .row-body {
  opacity: 0.45;
  transition: opacity 0.25s 0.1s;
}

.task.is-completing .row-title {
  text-decoration: line-through;
}

details.paused {
  margin-top: 8px;
}

details.paused summary {
  cursor: pointer;
  list-style: none;
}

details.paused summary::-webkit-details-marker {
  display: none;
}

details.paused summary::after {
  content: " ›";
  display: inline-block;
  transition: transform 0.15s;
}

details.paused[open] summary::after {
  transform: rotate(90deg);
}

/* ------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius-m);
  background: var(--surface-2);
  color: var(--accent);
  font-weight: var(--strong-weight);
  cursor: pointer;
  transition: transform 0.12s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-danger {
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.btn-round {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-row > .btn {
  flex: 1;
}

.row.is-action {
  color: var(--accent);
  justify-content: flex-start;
  cursor: pointer;
}

.row.is-action.is-danger {
  color: var(--danger);
}

/* ------------------------------------------------------------- Formulare */

.field {
  display: block;
  padding: 10px 16px;
}

.field + .field {
  border-top: 0.5px solid var(--separator);
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 0;
  padding: 4px 0;
  background: none;
  font-size: 17px; /* ≥16px verhindert Auto-Zoom auf iOS */
  outline: none;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.field-inline .field-label {
  margin: 0;
  font-size: 17px;
  color: var(--text);
  flex: 1;
}

.field-inline input,
.field-inline select {
  width: auto;
  text-align: right;
  color: var(--accent);
}

.field-inline input[type="number"] {
  width: 4.5em;
  padding: 6px 8px;
  border-radius: var(--radius-s);
  background: var(--surface-2);
  text-align: center;
  color: var(--text);
}

.field select {
  -webkit-appearance: none;
  appearance: none;
}

.field textarea {
  resize: vertical;
}

/* iOS-artiger Schalter aus einer Checkbox */
.switch-row {
  cursor: pointer;
}

.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 51px;
  height: 31px;
  flex: none;
  margin: 0;
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  transition: background-color 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgb(0 0 0 / 0.2);
  transition: transform 0.2s;
}

.switch:checked {
  background: var(--success);
}

.switch:checked::after {
  transform: translateX(20px);
}

.form-error {
  margin: 12px 4px 0;
  padding: 10px 14px;
  border-radius: var(--radius-m);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  font-size: 15px;
}

/* ------------------------------------------------------------- Auth-Seiten */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top) + 24px) var(--pad-right)
    calc(env(safe-area-inset-bottom) + 24px) var(--pad-left);
}

.auth-box {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  display: block;
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border-radius: 22px;
  box-shadow: var(--shadow-float);
}

.auth-title {
  text-align: center;
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: var(--title-weight);
}

.auth-sub {
  text-align: center;
  color: var(--text-muted);
  margin: 6px 0 24px;
}

.auth-box .btn-primary {
  margin-top: 18px;
}

/* ------------------------------------------------------------- Theme-Auswahl */

.theme-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.theme-option {
  position: relative;
  cursor: pointer;
  text-align: center;
  font-size: 15px;
  font-weight: var(--strong-weight);
}

.theme-option input {
  position: absolute;
  opacity: 0;
}

.theme-preview {
  display: block;
  height: 112px;
  margin-bottom: 8px;
  border-radius: 16px;
  border: 3px solid transparent;
  padding: 12px;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}

.theme-option input:checked + .theme-preview {
  border-color: var(--accent);
  transform: scale(1.02);
}

.theme-option input:focus-visible + .theme-preview {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Die Vorschauen zeigen bewusst feste Farben des jeweiligen Themes. */
.theme-preview.is-clean {
  background: #f2f2f7;
  font-family: -apple-system, system-ui, sans-serif;
}

.theme-preview.is-playful {
  background: #fff5f8;
  font-family: "Nunito", ui-rounded, system-ui, sans-serif;
}

.tp-title {
  display: block;
  font-weight: 800;
  font-size: 15px;
  color: #000;
}

.is-playful .tp-title {
  color: #4a3248;
}

.tp-line {
  display: block;
  height: 14px;
  margin-top: 8px;
  border-radius: 4px;
  background: #fff;
}

.is-playful .tp-line {
  border-radius: 999px;
  box-shadow: 0 3px 8px rgb(255 123 172 / 0.2);
}

.tp-dot {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-top: 10px;
  border-radius: 50%;
  background: #007aff;
}

.is-playful .tp-dot {
  background: #ff7bac;
  box-shadow: 26px 0 0 #b79cff, 52px 0 0 #7adcc0;
}

/* ------------------------------------------------------------- Diverses */

.empty-state {
  padding: 32px 24px;
  text-align: center;
}

.empty-state .icon {
  font-size: 44px;
  color: var(--accent);
}

.empty-state h2 {
  margin-top: 12px;
  font-size: 20px;
  font-weight: var(--strong-weight);
}

.empty-state p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 15px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: var(--strong-weight);
  vertical-align: middle;
}

.invite-link {
  display: block;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  background: var(--surface-2);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  -webkit-user-select: all;
  user-select: all;
  margin-bottom: 12px;
}

.steps {
  margin: 0;
  padding: 0 0 0 22px;
}

.steps li + li {
  margin-top: 10px;
}

/* ------------------------------------------------------------- Kosten */

.filters {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-m);
  background: var(--surface-2);
  color: var(--text-muted);
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font-size: 17px;
  outline: none;
  color: var(--text);
}

.filter-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter-selects select {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-m);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  font-size: 15px;
  -webkit-appearance: none;
  appearance: none;
  /* kleiner Pfeil als Hinweis auf die Auswahl (data:-URI ist per CSP erlaubt) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238a8a8e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 8px;
}

.month-label {
  font-size: 18px;
  font-weight: var(--strong-weight);
}

.btn-plain {
  background: none;
  min-width: 44px;
  padding: 8px 10px;
}

.btn-icon {
  font-size: 20px;
}

.expense .amount {
  white-space: nowrap;
}

.clip {
  font-size: 15px;
}

/* Kategoriefarben: Kacheln im clean-Theme farbig (Farbe aus der Kategorie-ID) */
[data-theme="clean"] .cat-icon[data-color="0"] {
  background: var(--success);
}

[data-theme="clean"] .cat-icon[data-color="1"] {
  background: var(--accent);
}

[data-theme="clean"] .cat-icon[data-color="2"] {
  background: var(--accent-2);
}

[data-theme="clean"] .cat-icon[data-color="3"] {
  background: var(--warning);
}

[data-theme="clean"] .cat-icon[data-color="4"] {
  background: var(--danger);
}

[data-theme="clean"] .cat-icon[data-color="5"] {
  background: var(--text-muted);
}

/* Budgets */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.section-head .section-title {
  margin-top: 0;
}

.section-link {
  font-size: 15px;
  color: var(--accent);
}

.budgets {
  display: grid;
  gap: 16px;
}

.budget {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.budget-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 5px;
}

.budget-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 16px;
}

.budget-name {
  font-weight: var(--strong-weight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-left {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.budget.is-over .budget-left {
  color: var(--danger);
  font-weight: var(--strong-weight);
}

.budget-sub {
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.budget-bar {
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}

.budget-bar::-webkit-progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
}

.budget-bar::-webkit-progress-value {
  background: var(--success);
  border-radius: 999px;
}

.budget-bar::-moz-progress-bar {
  background: var(--success);
  border-radius: 999px;
}

.budget.is-over .budget-bar::-webkit-progress-value {
  background: var(--danger);
}

.budget.is-over .budget-bar::-moz-progress-bar {
  background: var(--danger);
}

.budget-hint {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: inherit;
  text-decoration: none;
  font-size: 15px;
}

.budget-hint > .icon {
  font-size: 24px;
  color: var(--accent);
  flex: none;
}

/* Kategorien verwalten */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--accent);
  text-decoration: none;
  font-size: 16px;
}

.section-footer.intro {
  margin: 0 16px 12px;
}

.row-button.is-archived .row-title {
  color: var(--text-muted);
}

.field-inline input.input-narrow {
  width: 7em;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  border: 0;
  margin: 0;
}

.icon-choice {
  position: relative;
  display: grid;
  place-items: center;
}

.icon-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.icon-tile {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-m);
  background: var(--surface-2);
  color: var(--text);
  font-size: 22px;
  border: 2px solid transparent;
}

.icon-choice input:checked + .icon-tile {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.icon-choice input:focus-visible + .icon-tile {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.breakdown {
  display: grid;
  gap: 12px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  font-size: 15px;
}

.breakdown-bar {
  grid-column: 1 / -1;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}

.breakdown-bar::-webkit-progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
}

.breakdown-bar::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

.breakdown-bar::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

/* Fixe Summenleiste über der Tab-Bar */
.sum-bar {
  position: fixed;
  z-index: 15;
  left: calc(var(--sidebar-w) + var(--pad-left));
  right: var(--pad-right);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 10px 16px;
  border-radius: var(--radius-l);
  background: var(--surface-blur);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-float);
}

.sum-bar > div + div {
  text-align: right;
}

.sum-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}

.sum-value {
  display: block;
  font-size: 18px;
  font-weight: var(--strong-weight);
  font-variant-numeric: tabular-nums;
}

body:has(.sum-bar) .toast-area {
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 84px);
}

/* Platz für die Summenleiste am Seitenende */
#kosten-content {
  padding-bottom: 76px;
}

.amount-field input {
  font-size: 28px;
  font-weight: var(--strong-weight);
  font-variant-numeric: tabular-nums;
}

.field input[type="file"] {
  font-size: 15px;
}

.detail-hero {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 20px 16px;
  text-align: center;
}

.detail-hero .row-icon {
  width: 44px;
  height: 44px;
  font-size: 24px;
  border-radius: var(--radius-m);
}

.detail-amount {
  font-family: var(--font-title);
  font-size: 32px;
  font-weight: var(--title-weight);
  font-variant-numeric: tabular-nums;
}

.detail-title {
  color: var(--text-muted);
}

.doc-thumb img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border: 0.5px solid var(--separator);
  border-radius: var(--radius-s);
}

/* ------------------------------------------------------------- Toast */

.toast-area {
  position: fixed;
  z-index: 40;
  left: var(--pad-left);
  right: var(--pad-right);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: var(--radius-m);
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  box-shadow: var(--shadow-float);
  animation: toast-in 0.22s ease-out;
}

.toast-text {
  flex: 1;
}

.toast-action {
  flex: none;
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--bg) 18%, transparent);
  color: var(--bg);
  font-weight: var(--strong-weight);
  cursor: pointer;
}

.toast-area {
  gap: 8px;
}

.toast.is-hiding {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

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

dialog.sheet {
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
  margin: auto 0 0;
  padding: 0 var(--pad-right) calc(env(safe-area-inset-bottom) + 20px) var(--pad-left);
  border: 0;
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
  overscroll-behavior: contain;
}

dialog.sheet::backdrop {
  background: var(--backdrop);
}

dialog.sheet[open] {
  animation: sheet-up 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

dialog.sheet[open]::backdrop {
  animation: fade-in 0.25s ease-out;
}

.sheet-grabber {
  width: 36px;
  height: 5px;
  margin: 8px auto 4px;
  border-radius: 3px;
  background: var(--separator);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-bottom: 8px;
}

.sheet-header h2 {
  flex: 1;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  font-weight: var(--strong-weight);
}

.sheet-header .btn {
  min-height: 44px;
  padding: 6px 4px;
  background: none;
  font-weight: var(--body-weight);
}

.sheet-header .btn.is-strong {
  font-weight: var(--strong-weight);
}

.sheet-danger {
  margin-top: 24px;
}

#sheet-content > .card + .card,
#sheet-content > form + .card {
  margin-top: 14px;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* ------------------------------------------------------------- Breite Fenster */

/* iPad hochkant, iPad Split View, große iPhones quer */
@media (min-width: 700px) {
  dialog.sheet {
    width: min(540px, 92vw);
    margin: auto;
    padding-bottom: 20px;
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-float);
  }

  dialog.sheet[open] {
    animation: pop-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .sheet-grabber {
    visibility: hidden;
  }

  .tab {
    flex-direction: row;
    gap: 8px;
    font-size: 13px;
    max-width: 180px;
  }

  .tab .icon {
    font-size: 22px;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

/* iPad quer / großes Fenster: Seitenleiste statt Tab-Bar, gleiches Markup */
@media (min-width: 1024px) {
  :root {
    --sidebar-w: 248px;
    --content-max: 760px;
  }

  .page {
    padding-bottom: calc(env(safe-area-inset-bottom) + 40px);
  }

  .tabbar {
    top: 0;
    right: auto;
    width: var(--sidebar-w);
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    padding: calc(env(safe-area-inset-top) + 20px) 12px 20px max(12px, env(safe-area-inset-left));
    border-top: 0;
    border-right: 0.5px solid var(--separator);
  }

  .tabbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 18px;
    font-family: var(--font-title);
    font-size: 22px;
    font-weight: var(--title-weight);
    color: var(--text);
  }

  .tabbar-brand img {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }

  .tab {
    flex: none;
    max-width: none;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-m);
    font-size: 16px;
    color: var(--text);
  }

  .tab .icon {
    color: var(--accent);
  }

  .tab[aria-current="page"] {
    background: var(--accent);
    color: var(--accent-text);
  }

  .tab[aria-current="page"] .icon {
    color: inherit;
  }

  .toast-area {
    left: calc(var(--sidebar-w) + var(--gutter));
    bottom: calc(env(safe-area-inset-bottom) + 24px);
  }

  .sum-bar {
    bottom: calc(env(safe-area-inset-bottom) + 16px);
  }
}

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