/* =========================================================
   Navigation — Klar
   - .app-header   : 60 px bar, brand or back, avatar on the right
   - .bottom-nav   : the four main areas, flush at the bottom edge
   - .icon-button  : icon-only action with a 44 px touch target
   ----------------------------------------------------------
   The reference draws both bars inside a phone frame. Here they
   belong to the window: the header sticks to the top, the
   navigation to the bottom, and both keep clear of the safe areas.
   ========================================================= */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-top);
}

.app-header__inner {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  min-height: var(--app-header-h);
  /* Die Referenz gibt dem Kopf 20 px, dem Inhalt 18 px. Das ist kein
     Versehen: der Kopf trägt runde Touchziele, die optisch weiter
     innen stehen als ein Textblock mit derselben Kante. */
  padding-left: max(20px, var(--safe-left));
  padding-right: max(20px, var(--safe-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-header__lead {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.app-header__trail {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.app-header__back {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  line-height: 1;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast);
}

.app-header__back:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--tint);
}

.app-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.6px;
}
.app-header__brand:hover {
  color: var(--ink);
}

/* Die Größe der Marke steht bei den Symbolen (klar-icons.css,
   ``.app-header__brand svg`` = 24 px), nicht hier. */
.app-header__logo {
  color: var(--accent);
  line-height: 1;
  display: inline-flex;
  flex: none;
}

.app-header__title {
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header__actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Avatar: initials, centred, on the accent tint. */
.app-header__avatar,
.avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  line-height: 1;
  flex: none;
  background: var(--tint);
  color: var(--accent);
  border: 1px solid var(--line);
  font-size: var(--text-sm);
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  padding: 0;
  overflow: hidden;
}

/* Der Kreis im Kopf ist ein Link und damit ein Touchziel — 44 px, nicht 40
   wie der rein anzeigende Avatar in Listen. */
.app-header__avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

.app-header__avatar:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Icon action */
.icon-button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast);
}
.icon-button:hover {
  background: var(--tint);
  color: var(--accent);
}

.icon-button--ghost,
.icon-button--plain {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.icon-button--ghost:hover,
.icon-button--plain:hover {
  background: var(--tint);
  color: var(--accent);
}

.icon-button--accent {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.icon-button--accent:hover {
  background: var(--accent);
  color: #fff;
  filter: brightness(1.07);
}

/* ---------------- Bottom navigation ----------------
   Home, Tagebuch, Rezepte, Mehr. A sub-view keeps the area it
   belongs to marked (UIUX.md) — the view sets ``nav_active``. */

.bottom-nav {
  --nav-cols: 4;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 9px max(12px, var(--safe-left)) max(12px, var(--safe-bottom)) max(12px, var(--safe-right));
  background: var(--surface);
  border-top: 1px solid var(--line);
  min-height: var(--bottom-nav-h);
}

.bottom-nav__inner {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--nav-cols), minmax(0, 1fr));
  gap: 4px;
}

.bottom-nav__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 54px;
  border-radius: 13px;
  text-decoration: none;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  border: 0;
  background: transparent;
  min-width: 0;
  transition:
    color var(--t-fast),
    background var(--t-fast);
}
.bottom-nav__item span {
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.bottom-nav__item:hover {
  color: var(--ink);
}

.bottom-nav__item.is-active {
  color: var(--accent);
  background: var(--tint);
}

/* Short viewports and an open keyboard: the bar must not eat the
   form. ``svh`` cannot see the keyboard, so this is height-based. */
@media (max-height: 420px) {
  .bottom-nav {
    min-height: 58px;
    padding-top: 4px;
  }
  .bottom-nav__item {
    min-height: 44px;
    flex-direction: row;
    gap: 7px;
  }
  .bottom-nav__item svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 360px) {
  .bottom-nav__item span {
    font-size: var(--text-2xs);
  }
  .app-header__brand {
    font-size: max(1rem, 16px);
  }
}
