/* Elias Fahrner · Portal – schlicht, dunkelgrüner Akzent, Hell/Dunkel */

:root {
  --bg: #F3F5F2;
  --surface: #FFFFFF;
  --surface-2: #F7F9F6;
  --field: #FFFFFF;
  --line: #DCE1DB;
  --line-strong: #C4CCC3;
  --text: #161A17;
  --muted: #59625C;
  --accent: #1F5135;
  --accent-hover: #173F29;
  --accent-ink: #FFFFFF;
  --accent-text: #1F5135;
  --soft: #E3EDE5;
  --focus: #3E8E60;
  --danger: #B42318;
  --danger-soft: #FCE9E7;
  --ok: #1F5135;
  --shadow: 0 1px 2px rgba(16, 24, 18, .04), 0 4px 16px rgba(16, 24, 18, .04);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1110; --surface: #161A18; --surface-2: #1B201D; --field: #101312;
    --line: #2A312D; --line-strong: #3A433E; --text: #E6EAE7; --muted: #9AA39D;
    --accent: #2D6A47; --accent-hover: #357A52; --accent-text: #86C79F; --soft: #1A2A20;
    --danger: #F28B82; --danger-soft: #3A1D1B; --ok: #86C79F;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1110; --surface: #161A18; --surface-2: #1B201D; --field: #101312;
  --line: #2A312D; --line-strong: #3A433E; --text: #E6EAE7; --muted: #9AA39D;
  --accent: #2D6A47; --accent-hover: #357A52; --accent-text: #86C79F; --soft: #1A2A20;
  --danger: #F28B82; --danger-soft: #3A1D1B; --ok: #86C79F;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 28px; }
h2 { font-size: 17px; margin-bottom: 14px; }
p { margin: 0; }
a { color: var(--accent-text); }
a:hover { color: var(--accent-hover); }
:root[data-theme="dark"] a:hover { color: var(--text); }
code { font-family: var(--mono); font-size: .88em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); overflow-wrap: anywhere; }
strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Bausteine ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 17px; min-height: 44px; min-width: 0; }
.brand:hover { color: var(--text); }
.brand-mark { display: inline-flex; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #FFFFFF; align-items: center; justify-content: center; flex: none; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 15px;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--accent-ink); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--line); font-weight: 500; }
.btn-outline:hover:not(:disabled) { border-color: var(--focus); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover { border-color: var(--danger); }
.btn-block { width: 100%; min-height: 48px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { border-color: var(--focus); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.sm { width: 36px; height: 36px; }

.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: none; }
}

.pill { display: inline-flex; align-self: flex-start; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--soft); color: var(--accent-text); font-size: 12.5px; font-weight: 500; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--soft); color: var(--accent-text); font-size: 11.5px; font-weight: 600; vertical-align: 2px; }
.badge-soft { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.avatar { display: inline-flex; width: 34px; height: 34px; border-radius: 50%; background: var(--soft); color: var(--accent-text); align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.card-danger { border-color: var(--line); }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-err { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--soft); color: var(--ok); }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Formulare ---------- */
.form { display: flex; flex-direction: column; gap: 16px; align-items: stretch; }
.form > .btn:not(.btn-block) { align-self: flex-start; }
.inline-form { display: inline-flex; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend { font-size: 13.5px; font-weight: 500; padding: 0; }
.hint { font-size: 12.5px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="search"] {
  width: 100%; min-width: 0; height: 44px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--field); color: var(--text); font: inherit;
}
input[type="text"]:hover, input[type="password"]:hover { border-color: var(--line-strong); }
input[type="text"]:focus, input[type="password"]:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
input::placeholder { color: var(--muted); opacity: .75; }
.pw { position: relative; display: flex; }
.pw input { padding-right: 48px; }
.pw-toggle { position: absolute; right: 2px; top: 2px; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.pw-toggle:hover, .pw-toggle[aria-pressed="true"] { color: var(--text); }
.check { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
.check:has(input:disabled) { color: var(--muted); cursor: default; }

.icon-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-opt { position: relative; cursor: pointer; }
.icon-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.icon-box { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: var(--radius-sm); border: 1px solid var(--line); color: var(--muted); background: var(--field); }
.icon-opt:hover .icon-box { border-color: var(--line-strong); color: var(--text); }
.icon-opt input:checked + .icon-box { border-color: var(--accent-text); background: var(--soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-text); }
.icon-opt input:focus-visible + .icon-box { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Anmelden ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px 20px; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px 16px 48px; }
.auth-card { width: 100%; max-width: 410px; padding: 34px 30px; display: flex; flex-direction: column; gap: 22px; }
.auth-card h1 { margin-top: 8px; }
.auth-foot { padding: 20px; text-align: center; font-size: 13px; color: var(--muted); }

/* ---------- Kopfleiste & Navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 10px; max-width: 1280px; margin: 0 auto; padding: 10px 24px; }
.topbar .brand { margin-right: auto; }
.user-chip { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px 0 5px; border-radius: 999px; color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500; }
.user-chip:hover { background: var(--surface-2); color: var(--text); }
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.layout { display: flex; flex-wrap: wrap; gap: 32px; max-width: 1280px; margin: 0 auto; padding: 32px 24px 56px; }
.sidenav { flex: 0 1 210px; display: flex; flex-direction: column; gap: 4px; align-self: flex-start; position: sticky; top: 90px; }
.snav-link { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 500; }
.snav-link:hover { background: var(--surface); color: var(--text); }
.snav-link.is-active { background: var(--soft); color: var(--accent-text); font-weight: 600; }
.content { flex: 999 1 560px; min-width: 0; }
.bnav { display: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.page-head p { margin-top: 6px; }
.back { display: inline-block; margin-bottom: 8px; font-size: 14px; text-decoration: none; }
.search { display: flex; align-items: center; gap: 8px; height: 44px; width: 280px; max-width: 100%; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.search:focus-within { border-color: var(--focus); }
.search input { border: 0; height: 40px; padding: 0; background: transparent; outline: none; }

/* ---------- Kacheln ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tile {
  display: flex; flex-direction: column; gap: 14px; min-height: 172px; padding: 20px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--focus); color: var(--text); transform: translateY(-1px); }
.tile-icon { display: inline-flex; width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--soft); color: var(--accent-text); align-items: center; justify-content: center; }
.tile-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.tile-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.tile-desc { font-size: 14px; color: var(--muted); }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.tile-url { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.tile-open { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-text); font-weight: 600; flex: none; }
.tile-add { align-items: center; justify-content: center; gap: 10px; border-style: dashed; border-width: 1.5px; background: transparent; color: var(--muted); font-weight: 500; box-shadow: none; }
.tile-add:hover { color: var(--text); }
.no-results { margin-top: 16px; }
.empty { text-align: center; color: var(--muted); }

/* ---------- Verwaltung ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.card-wide { grid-column: 1 / -1; }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.row-icon { display: inline-flex; width: 38px; height: 38px; border-radius: 9px; background: var(--soft); color: var(--accent-text); align-items: center; justify-content: center; flex: none; }
.row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-acts { display: flex; align-items: center; gap: 6px; flex: none; }
.rows.hosted { margin-top: 14px; }
.mono { font-family: var(--mono); font-size: 13.5px; }
.card .muted + .form { margin-top: 14px; }

/* ---------- Handy ---------- */
@media (max-width: 760px) {
  h1 { font-size: 24px; }
  .topbar-in { padding: 8px 16px; gap: 8px; }
  .user-name, .btn-logout span { display: none; }
  .btn-logout { width: 44px; padding: 0; }
  .user-chip { padding: 0; }
  .user-chip .avatar { width: 40px; height: 40px; }
  .layout { padding: 20px 16px 104px; gap: 0; }
  .sidenav { display: none; }
  .bnav {
    display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .bnav-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500; }
  .bnav-link.is-active { color: var(--accent-text); font-weight: 600; }
  .page-head { margin-bottom: 18px; }
  .search { width: 100%; height: 46px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { min-height: 140px; padding: 16px; gap: 12px; }
  .tile-icon { width: 40px; height: 40px; }
  .tile-name { font-size: 15px; }
  .tile-desc { font-size: 13px; }
  .tile-foot { display: none; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 18px; }
  .auth-card { padding: 28px 20px; border: 0; background: transparent; box-shadow: none; }
  .auth-main { align-items: flex-start; padding-top: 24px; }
  input[type="text"], input[type="password"], input[type="search"] { font-size: 16px; height: 48px; }
  .row { flex-wrap: wrap; }
  .row-main { flex: 1 1 calc(100% - 52px); }
  .row-acts { margin-left: 50px; }
}
@media (max-width: 360px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- 1.2.0: einspaltige Seiten ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; max-width: 860px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.form-row, .form.form-row { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.form-row > .btn, .form-row > .inline-form, .form.form-row > .btn:not(.btn-block) { flex: none; align-self: flex-end; }
p.grow { align-self: center; }
.grow { flex: 1 1 260px; min-width: 0; }
.field-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0 0 18px; }
.facts div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; min-width: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.form + .facts { margin: 18px 0 0; }
.add-box { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.add-box summary { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); cursor: pointer; font-weight: 600; list-style: none; }
.add-box summary::-webkit-details-marker { display: none; }
.add-box summary:hover { border-color: var(--focus); }
.add-box[open] summary { margin-bottom: 16px; }
.hint-box { margin-top: 16px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.badge-warn { background: var(--danger-soft); color: var(--danger); }
.note-lock { display: flex; align-items: center; gap: 6px; margin: -6px 0 14px; font-size: 13.5px; }
.tile-foot { justify-content: flex-end; }
