/**
 * tz-framework – Core Stylesheet
 *
 * Served automatically at /tz-assets/tz.css via Router::serveFrameworkAssets().
 *
 * Theming
 * -------
 * Colors are defined as CSS custom properties in :root (light) and [data-theme="dark"].
 * The <html> element receives data-theme="light|dark|auto" from the server (APP_DEFAULT_THEME).
 * A small inline script in <head> applies the user's saved preference from localStorage
 * before this file is parsed, preventing a flash of the wrong theme.
 *
 * Extending
 * ---------
 * Override variables in your own stylesheet:
 *   :root { --primary: #7c3aed; }
 * Inject your stylesheet via View::addStyle('/my.css') or {styles} in your layout.
 */

/* ── Custom Properties (light theme) ──────────────────────────────────────── */
:root {
  color-scheme: light;
  /* Surfaces */
  --bg:              #f9f6f2;
  --surface:         #ffffff;

  /* Brand */
  --primary:         #ea580c;
  --primary-dark:    #c2410c;
  --primary-fg:      #ffffff;

  /* Text */
  --text:            #1c1917;
  --muted:           #78716c;

  /* Borders & shadows */
  --border:          #e5ddd4;
  --radius:          8px;
  --shadow:          0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);

  /* Navigation */
  --nav-bg:          #1c1917;
  --nav-fg:          rgba(255, 255, 255, 0.80);
  --nav-fg-active:   #ffffff;
  --nav-hover-bg:    rgba(255, 255, 255, 0.12);

  /* Alerts */
  --alert-error-bg:  #fef2f2;
  --alert-error-bd:  #fecaca;
  --alert-error-fg:  #dc2626;
  --alert-success-bg:#f0fdf4;
  --alert-success-bd:#bbf7d0;
  --alert-success-fg:#16a34a;
  --alert-info-bg:   #fff7ed;
  --alert-info-bd:   #fed7aa;
  --alert-info-fg:   #c2410c;

  /* Form errors */
  --error-fg:        #dc2626;
  --error-bd:        #fca5a5;

  /* Buttons */
  --btn-ghost-bg:    #ede8e3;
  --btn-ghost-hover: #ddd7cf;
  --btn-ghost-fg:    #1c1917;
}

/* ── Dark Theme ────────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  color-scheme: dark;
  --bg:              #1a1816;
  --surface:         #252220;
  --primary:         #fb923c;
  --primary-dark:    #f97316;
  --text:            #f5ede4;
  --muted:           #a09890;
  --border:          #3c3530;
  --shadow:          0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);

  --nav-bg:          #141210;
  --nav-fg:          rgba(255, 255, 255, 0.78);
  --nav-fg-active:   #ffffff;
  --nav-hover-bg:    rgba(255, 255, 255, 0.10);

  --alert-error-bg:  #2d1516;
  --alert-error-bd:  #7f1d1d;
  --alert-error-fg:  #fca5a5;
  --alert-success-bg:#162016;
  --alert-success-bd:#14532d;
  --alert-success-fg:#86efac;
  --alert-info-bg:   #291c0e;
  --alert-info-bd:   #7c4a1a;
  --alert-info-fg:   #fdba74;

  --error-fg:        #f87171;
  --error-bd:        #ef4444;

  --btn-ghost-bg:    #38332d;
  --btn-ghost-hover: #46403a;
  --btn-ghost-fg:    #f0ebe5;
}

/* ── Auto: follow system preference ───────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    color-scheme: dark;
    --bg:              #1a1816;
    --surface:         #252220;
    --primary:         #fb923c;
    --primary-dark:    #f97316;
    --text:            #f5ede4;
    --muted:           #a09890;
    --border:          #3c3530;
    --shadow:          0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);

    --nav-bg:          #141210;
    --nav-fg:          rgba(255, 255, 255, 0.78);
    --nav-fg-active:   #ffffff;
    --nav-hover-bg:    rgba(255, 255, 255, 0.10);

    --alert-error-bg:  #2d1516;
    --alert-error-bd:  #7f1d1d;
    --alert-error-fg:  #fca5a5;
    --alert-success-bg:#162016;
    --alert-success-bd:#14532d;
    --alert-success-fg:#86efac;
    --alert-info-bg:   #291c0e;
    --alert-info-bd:   #7c4a1a;
    --alert-info-fg:   #fdba74;

    --error-fg:        #f87171;
    --error-bd:        #ef4444;

    --btn-ghost-bg:    #38332d;
    --btn-ghost-hover: #46403a;
    --btn-ghost-fg:    #f0ebe5;
  }
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a {
  color: var(--primary);
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

/* ── Page header ───────────────────────────────────────────────────────────── */
/* Standard top row: title on the left, action buttons on the right.           */
/* Usage: <div class="tz-page-header"><h1 class="tz-page-title">…</h1>         */
/*          <div class="tz-page-actions"><a class="btn">…</a></div></div>      */
.tz-page-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.tz-page-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}
.tz-page-subtitle {
  margin: .15rem 0 0;
  font-size: .88rem;
  color: var(--muted);
  font-weight: 400;
}
.tz-page-actions {
  margin-left: auto;
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 480px) {
  .card { padding: 1rem; }
}
h1 {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}
h2 {
  font-size: 1.35rem;
  margin-bottom: 0.75rem;
}
p {
  color: var(--muted);
  margin-bottom: 1rem;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.55rem 1.4rem;
  background: var(--primary);
  color: var(--primary-fg);
  border-radius: var(--radius);
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.25;
  -webkit-appearance: none;
  appearance: none;        /* removes native <button> platform rendering */
  vertical-align: middle;
  box-sizing: border-box;
  transition: background 0.15s;
}
.btn:hover {
  background: var(--primary-dark);
  color: var(--primary-fg);
}
.btn-ghost {
  background: var(--btn-ghost-bg);
  color: var(--btn-ghost-fg);
}
.btn-ghost:hover {
  background: var(--btn-ghost-hover);
}
/* Small button variant – for pagination, back links, inline actions */
.btn-sm {
  font-size: .85rem;
  padding: .35rem .85rem;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: var(--text);
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
  font-family: inherit;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.20);
}

/* Number input spinners – subtle, unobtrusive */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.45;
  cursor:  pointer;
  margin:  0;
}
input[type="number"]:hover::-webkit-inner-spin-button,
input[type="number"]:hover::-webkit-outer-spin-button,
input[type="number"]:focus::-webkit-inner-spin-button,
input[type="number"]:focus::-webkit-outer-spin-button {
  opacity: 0.8;
}

.form-group {
  margin-bottom: 1.1rem;
}

/* ── Form errors ───────────────────────────────────────────────────────────── */
.field-error {
  display: block;
  font-size: 0.85rem;
  color: var(--error-fg);
  margin-top: 0.3rem;
}
input.has-error,
select.has-error,
textarea.has-error {
  border-color: var(--error-bd);
}
.form-group.has-error label {
  color: var(--error-fg);
}

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.1rem;
  font-size: 0.95rem;
}
.alert-error {
  background: var(--alert-error-bg);
  border: 1px solid var(--alert-error-bd);
  color: var(--alert-error-fg);
}
.alert-success {
  background: var(--alert-success-bg);
  border: 1px solid var(--alert-success-bd);
  color: var(--alert-success-fg);
}
.alert-info {
  background: var(--alert-info-bg);
  border: 1px solid var(--alert-info-bd);
  color: var(--alert-info-fg);
}

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.tz-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
.tz-table th,
.tz-table td {
  padding: .45rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tz-table th:first-child,
.tz-table td:first-child { padding-left: 1.25rem; }
.tz-table th:last-child,
.tz-table td:last-child  { padding-right: 1.25rem; }
.tz-table thead th {
  font-size: .73rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.tz-table tbody tr:last-child td { border-bottom: none; }
.tz-table tbody tr:hover { background: var(--surface); }

/* ── Star Rating ───────────────────────────────────────────────────────────── */
.tz-stars { display: inline-flex; gap: .15rem; font-size: 1.3rem; cursor: pointer; }
.tz-stars span { color: var(--muted); transition: color .1s; }
.tz-stars span.is-active { color: #f59e0b; }
.tz-stars.is-readonly { cursor: default; }
.tz-stars-display { display: inline-flex; gap: .1rem; font-size: .9rem; color: #f59e0b; }

/* ── Header ────────────────────────────────────────────────────────────────── */
/* Respects iOS safe-area-inset-top so the brand/nav row is not drawn behind
   the Dynamic Island or notch. Kicks in only when viewport-fit=cover is set
   in the viewport meta (see layout.html); otherwise env() returns 0 and
   there's no visible difference on devices without a notch. */
header {
  background: var(--nav-bg);
  color: var(--nav-fg-active);
  padding: env(safe-area-inset-top) max(2rem, env(safe-area-inset-right)) 0 max(2rem, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  position: relative;
  z-index: 100;
}
.tz-hdr-left {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--nav-fg-active);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  white-space: nowrap;
  padding: 0.9rem 0;
  flex-shrink: 0;
}
.tz-logo {
  height: 2rem;
  width: auto;
  max-height: 2rem;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}
/* Logo-only mode: hide app name text on all screens */
.brand.tz-brand-logo-only .brand-text { display: none }
.tz-hdr-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0.4rem 0;
}
/* Login / register links (guest only) */
.tz-hdr-right > a {
  color: var(--nav-fg);
  text-decoration: none;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  transition: background 0.15s;
  font-size: 0.95rem;
}
.tz-hdr-right > a:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-fg-active);
}
/* Theme toggle button */
#tz-theme-btn {
  background: none;
  border: none;
  color: var(--nav-fg);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  transition: background 0.15s;
}
#tz-theme-btn:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-fg-active);
}

/* ── User dropdown menu ────────────────────────────────────────────────────── */
.tz-user-menu { position: relative }
.tz-user-drop {
  display: none;
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  background: var(--surface);
  border-radius: 6px;
  min-width: 160px;
  z-index: 300;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.13);
  border: 1px solid var(--border);
  padding: 0.3rem 0;
}
.tz-user-menu.open .tz-user-drop { display: block }
.tz-user-drop a,
.tz-user-drop button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.45rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.1s;
}
.tz-user-drop a:hover,
.tz-user-drop button:hover { background: var(--bg) }
.tz-user-drop form { display: flex }

/* ── Burger button (mobile only) ───────────────────────────────────────────── */
.tz-burger {
  display: none;
  background: none;
  border: none;
  color: var(--nav-fg-active);
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  font-size: 1.3rem;
  line-height: 1;
  transition: background 0.15s;
}
.tz-burger:hover { background: var(--nav-hover-bg) }

/* ── Avatar link ───────────────────────────────────────────────────────────── */
.tz-av-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.45rem;
  background: none;
  border: none;
  cursor: pointer;
}
.tz-av-link img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
}
.tz-av-link .mdi {
  font-size: 1.4rem;
  line-height: 1;
}

/* ── Theme switcher button ─────────────────────────────────────────────────── */
#tz-theme-btn .tz-icon-light { display: none; }
#tz-theme-btn .tz-icon-dark  { display: inline; }
[data-theme="dark"] #tz-theme-btn .tz-icon-light { display: inline; }
[data-theme="dark"] #tz-theme-btn .tz-icon-dark  { display: none; }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] #tz-theme-btn .tz-icon-light { display: inline; }
  [data-theme="auto"] #tz-theme-btn .tz-icon-dark  { display: none; }
}

/* ── Dynamic public nav ────────────────────────────────────────────────────── */
.tz-pub-nav { display: flex; align-items: center; margin-left: 1rem }
.tz-ni { position: relative }
.tz-nl {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--nav-fg);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}
.tz-nl:hover,
.tz-nl.active { background: var(--nav-hover-bg); color: var(--nav-fg-active) }
.tz-caret { font-size: 0.65rem; opacity: 0.75; margin-left: 0.1rem }
.tz-drop {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border-radius: 6px;
  min-width: 180px;
  z-index: 200;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.13);
  border: 1px solid var(--border);
  padding: 0.65rem 0 0.3rem;
}
.tz-ni:hover .tz-drop { display: block }
.tz-drop a,
.tz-drop span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.tz-drop a:hover { background: var(--bg); color: var(--primary) }
.tz-drop a.active { color: var(--primary); font-weight: 600 }
.tz-drop-hdr {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: default;
  padding: 0.45rem 1rem 0.2rem;
}

/* ── Static subnav ─────────────────────────────────────────────────────────── */
.tz-subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.35rem 2rem;
  display: flex;
  gap: 0.15rem;
  flex-wrap: wrap;
  align-items: center;
}
.tz-snl {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.12s, color 0.12s;
}
.tz-snl:hover { background: var(--bg); color: var(--text) }
.tz-snl.active { color: var(--primary); font-weight: 600 }
.tz-subnav-hdr {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 0.4rem;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 2.5rem max(1rem, env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Prose content (.tz-prose) ─────────────────────────────────────────────── */
/* Used for user-generated content (pages module). Scoped to avoid style leakage. */
.tz-prose { line-height: 1.75 }
.tz-prose h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
  line-height: 1.25;
  color: var(--text);
}
.tz-prose h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 1rem 0 0.4rem;
  line-height: 1.3;
  color: var(--text);
}
.tz-prose h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0.8rem 0 0.35rem;
  color: var(--text);
}
.tz-prose p { color: var(--text); margin-bottom: 0.75rem }
.tz-prose ul,
.tz-prose ol { padding-left: 1.5rem; margin-bottom: 0.75rem }
.tz-prose li { color: var(--text); margin-bottom: 0.2rem }
.tz-prose blockquote {
  border-left: 3px solid var(--border);
  padding: 0.3rem 0.85rem;
  color: var(--muted);
  margin: 0.75rem 0;
  font-style: italic;
}
.tz-prose pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  overflow-x: auto;
  margin-bottom: 0.75rem;
}
.tz-prose code {
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: monospace;
  color: var(--text);
}
.tz-prose pre code { background: transparent; padding: 0; font-size: inherit }
.tz-prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 0.5rem 0;
  display: block;
}
.tz-prose figure { margin: 0.5rem 0 }
.tz-prose figure img { margin: 0 }
.tz-prose figure[data-align="left"] {
  float: left;
  margin: 0 1.25rem 0.75rem 0;
  max-width: 45%;
}
.tz-prose figure[data-align="right"] {
  float: right;
  margin: 0 0 0.75rem 1.25rem;
  max-width: 45%;
}
.tz-prose figure[data-align="center"] {
  display: block;
  margin: 0.5rem auto;
  text-align: center;
}
.tz-prose figcaption {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.25rem;
  font-style: italic;
}
.tz-prose::after { content: ''; display: table; clear: both }
.tz-prose hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0 }
.tz-prose a { color: var(--primary); text-decoration: underline }
.tz-prose a:hover { text-decoration: none }
.tz-prose strong { font-weight: 700; color: var(--text) }

/* ── Mobile header ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Keep the safe-area-inset-top so the PWA standalone header is not drawn
     under the iOS status bar (notch / Dynamic Island). Without this, taps
     in the top strip are swallowed by the OS and the menu becomes unusable
     when the site is pinned to the home screen. */
  header { padding: env(safe-area-inset-top) max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left)); position: relative }
  .tz-hdr-left { flex: none }
  .tz-burger { display: flex }
  /* Public nav: drops below the header as an overlay */
  .tz-pub-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--nav-bg);
    margin-left: 0;
    padding: 0.35rem 0 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    z-index: 200;
  }
  header.tz-nav-open .tz-pub-nav { display: flex }
  /* Nav items: full-width rows */
  .tz-nl { padding: 0.55rem 1rem; border-radius: 0 }
  /* Dropdown menus: show flat below parent (no hover on mobile) */
  .tz-pub-nav .tz-drop {
    display: block;
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.12);
    padding: 0;
    min-width: 0;
  }
  .tz-pub-nav .tz-drop a { padding: 0.5rem 1.5rem; color: var(--nav-fg) }
  .tz-pub-nav .tz-drop a:hover { background: var(--nav-hover-bg) }
  .tz-caret { display: none }
  /* Mobile: hide app name text when a logo is present */
  .brand.tz-brand-has-logo .brand-text { display: none }
}

/* ── Datetime two-line display ─────────────────────────────────────────────── */
/* Applied to <td class="tz-dt"> — tz.js splits the text into date + time spans */
.tz-dt { vertical-align: top }
.tz-dt .tz-dt-date,
.tz-dt .tz-dt-time {
  display: block;
  white-space: nowrap;
  font-family: monospace;
  color: var(--muted);
}
.tz-dt .tz-dt-date { font-size: 0.77rem }
.tz-dt .tz-dt-time { font-size: 0.72rem; opacity: 0.75 }

/* ── Admin two-column layout ───────────────────────────────────────────────── */
.tz-admin-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 0 1.5rem;
  align-items: start;
}
/* Prevent grid children from overflowing their track (allows overflow-x:auto to work) */
.tz-admin-layout > * { min-width: 0 }
.tz-admin-aside {
  position: sticky;
  top: 1.25rem;
}
.tz-admin-aside .card {
  margin-bottom: 0;
  padding: 1.1rem 1rem;
}
.tz-jump-nav-hdr {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.15rem 0.6rem 0.4rem;
}
.tz-jump-nav {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.tz-jump-nav a {
  display: block;
  padding: 0.35rem 0.6rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.tz-jump-nav a:hover,
.tz-jump-nav a.active {
  background: var(--bg);
  color: var(--primary);
}
.tz-jump-nav a.active { font-weight: 600 }
.tz-filter-panel label {
  font-size: 0.82rem;
  margin-bottom: 0.2rem;
}
.tz-filter-panel input,
.tz-filter-panel select {
  font-size: 0.875rem;
  padding: 0.38rem 0.6rem;
}
.tz-filter-panel .form-group { margin-bottom: 0.7rem }
.tz-filter-panel .form-group:last-child { margin-bottom: 0 }
@media (max-width: 720px) {
  .tz-admin-layout {
    grid-template-columns: 1fr;
    row-gap: 1rem;
  }
  .tz-admin-aside {
    position: static;
  }
}

/* ── Responsive form grid ──────────────────────────────────────────────────── */
/* Use .tz-form-grid for any multi-column form layout. On mobile (<640px) it
   automatically collapses to a single column with full-width inputs. */
.tz-form-grid {
  display: grid;
  gap: 0.75rem;
}
.tz-form-grid .tz-form-field { display: flex; flex-direction: column }
.tz-form-grid label {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.tz-form-grid input,
.tz-form-grid select,
.tz-form-grid textarea {
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 640px) {
  .tz-form-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Collapsible details (for forms / sections) ───────────────────────────── */
/* Use a <details class="tz-collapse"> with <summary> for collapsible card sections. */
details.tz-collapse {
  margin: 0;
}
details.tz-collapse > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.1rem 0;
  user-select: none;
}
details.tz-collapse > summary::-webkit-details-marker { display: none }
details.tz-collapse > summary::before {
  content: '▸';
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.15s;
  display: inline-block;
}
details.tz-collapse[open] > summary::before {
  transform: rotate(90deg);
}
details.tz-collapse > .tz-collapse-body {
  margin-top: 0.75rem;
}

/* ── Notification Bell ─────────────────────────────────────────────────────── */
.tz-notif-wrap {
  position: relative;
}

.tz-notif-btn {
  display:          flex;
  align-items:      center;
  justify-content:  center;
  position:         relative;
  width:            2.25rem;
  height:           2.25rem;
  border:           none;
  border-radius:    var(--radius);
  background:       transparent;
  color:            var(--nav-fg);
  font-size:        1.2rem;
  cursor:           pointer;
  transition:       background 0.15s;
}

.tz-notif-btn:hover,
.tz-notif-wrap.open .tz-notif-btn {
  background: var(--nav-hover-bg);
  color:      var(--nav-fg-active);
}

.tz-notif-badge {
  position:         absolute;
  top:              .15rem;
  right:            .15rem;
  min-width:        1rem;
  height:           1rem;
  padding:          0 .25rem;
  background:       #dc2626;
  color:            #fff;
  font-size:        .65rem;
  font-weight:      700;
  line-height:      1rem;
  text-align:       center;
  border-radius:    1rem;
  pointer-events:   none;
}

.tz-notif-drop {
  display:          none;
  position:         absolute;
  top:              calc(100% + .4rem);
  right:            0;
  width:            320px;
  max-height:       480px;
  overflow-y:       auto;
  background:       var(--surface);
  border:           1px solid var(--border);
  border-radius:    var(--radius);
  box-shadow:       var(--shadow);
  z-index:          200;
}

.tz-notif-wrap.open .tz-notif-drop {
  display: block;
}

.tz-notif-item {
  display:          block;
  padding:          .75rem 1rem;
  border-bottom:    1px solid var(--border);
  text-decoration:  none;
  color:            var(--text);
  transition:       background 0.12s;
}

.tz-notif-item:last-of-type {
  border-bottom: none;
}

.tz-notif-item:hover {
  background: var(--bg);
}

.tz-notif-item.tz-notif-unread {
  border-left: 3px solid var(--primary);
}

.tz-notif-item-app {
  font-size:      .67rem;
  font-weight:    700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color:          var(--muted);
  margin-bottom:  .15rem;
}

.tz-notif-item-title {
  font-size:    .875rem;
  font-weight:  600;
  margin-bottom: .15rem;
  white-space:  nowrap;
  overflow:     hidden;
  text-overflow: ellipsis;
}

.tz-notif-item-body {
  font-size:    .8rem;
  color:        var(--muted);
  margin-bottom: .2rem;
  display:      -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow:     hidden;
}

.tz-notif-item-time {
  font-size: .72rem;
  color:     var(--muted);
}

.tz-notif-empty {
  padding:    1.5rem 1rem;
  text-align: center;
  font-size:  .875rem;
  color:      var(--muted);
}

.tz-notif-footer {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         .6rem 1rem;
  border-top:      1px solid var(--border);
  background:      var(--bg);
  gap:             .5rem;
}

.tz-notif-footer-all {
  font-size:       .8rem;
  color:           var(--primary);
  text-decoration: none;
}

.tz-notif-footer-all:hover { text-decoration: underline; }

.tz-notif-mark-all {
  font-size:   .78rem;
  color:       var(--muted);
  background:  none;
  border:      none;
  cursor:      pointer;
  padding:     0;
  line-height: 1;
}

.tz-notif-mark-all:hover { color: var(--text); }

@media (max-width: 480px) {
  .tz-notif-drop {
    position: fixed;
    left:     0;
    right:    0;
    width:    100%;
    top:      56px; /* fallback; overridden by JS on open */
  }
}

/* ── Asset picker ──────────────────────────────────────────────────────── */
/* Body scroll lock while the modal is open — prevents the background page
   from scrolling when the user reaches the top/bottom of the grid. */
body.tz-asset-picker-open { overflow: hidden; }

#tz-ap-grid {
  /* Uniform square-ish tiles so portrait + landscape images look consistent */
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
}
.tz-asset-item {
  position: relative;
  box-sizing: border-box;
  border: 2px solid transparent;
  border-radius: .35rem;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  transition: border-color .15s;
  /* Classic 1:1 aspect ratio via the padding-top trick. We used to use
     aspect-ratio:1/1 but on iOS Safari inside a CSS grid it was flaky and
     produced visible tile overlap. padding-top:100% works everywhere. */
  height: 0;
  padding-top: 100%;
  /* Force a GPU compositing layer so border-radius + overflow:hidden clips
     the absolutely-positioned child image correctly on iOS Safari. */
  transform: translateZ(0);
  isolation: isolate;
}
.tz-asset-item:hover { border-color: #93c5fd; }
.tz-asset-item.is-selected { border-color: var(--primary); }
.tz-asset-item img {
  /* Absolutely position the image so it fills the aspect-ratio box without
     fighting flex layout passes (the combo was causing visible overlap
     between tiles on mobile Safari). */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tz-asset-name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  font-size: .65rem;
  color: #fff;
  padding: .5rem .35rem .25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,0) 100%);
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
  pointer-events: none;
}

/* ── Asset picker: mobile / narrow responsive ─────────────────────────── */
/* Breakpoint raised to 900px so tablets + narrow windows also get the
   stacked bottom-sheet layout. Below this width the side-by-side grid +
   preview layout squeezes the grid into a strip that was the root cause
   of bug #18 ("Bildselekt taugt so nichts, man kann nicht scrollen"). */
@media (max-width: 900px) {
  /* Modal becomes full-screen. We use 100dvh (dynamic viewport height) so
     iOS Safari's collapsing browser chrome doesn't steal modal space, and
     use max() around the safe-area-inset values so there's always at least
     some breathing room even if env() resolves to 0 (older iOS / unsupported
     browsers). */
  #tz-asset-picker-modal > div {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    padding-top: max(env(safe-area-inset-top), .5rem) !important;
    padding-bottom: max(env(safe-area-inset-bottom), .5rem) !important;
    padding-left: env(safe-area-inset-left) !important;
    padding-right: env(safe-area-inset-right) !important;
    box-sizing: border-box !important;
  }
  /* Body stacks vertically */
  #tz-ap-body {
    flex-direction: column !important;
    position: relative;
  }
  #tz-ap-grid {
    width: 100% !important;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
    padding: .75rem !important;
    gap: .5rem !important;
    -webkit-overflow-scrolling: touch;
  }
  /* Preview slides up as a fixed bottom sheet over the grid */
  #tz-ap-preview {
    position: absolute !important;
    left: 0; right: 0; bottom: 0;
    width: auto !important;
    border-left: none !important;
    border-top: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, .25);
    flex-direction: row !important;
    align-items: center;
    gap: .75rem !important;
    padding: .75rem 1rem !important;
    max-height: none !important;
    overflow-y: visible !important;
    flex-wrap: wrap;
    z-index: 5;
  }
  #tz-ap-prev-img { width: 60px !important; max-height: 60px !important; flex-shrink: 0; }
  #tz-ap-prev-name { flex: 1 1 auto; min-width: 0; font-size: .82rem !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
  #tz-ap-prev-meta { display: none }
  #tz-ap-prev-rotate { flex: 0 0 auto }
  #tz-ap-select { width: auto !important; flex-shrink: 0; padding: .4rem .8rem }
}
