/* =========================================================================
   vinz.studio – Gestaltung
   Nur dunkel. Die Farbe kommt nur aus den Kringeln links, alles andere bleibt
   schwarz-weiß, damit Logo und Kringel wirken.
   ========================================================================= */

:root {
  /* Palette (nur dunkel)
     Tinte   #000000  Fläche der ganzen Seite – echtes Schwarz, durchgehend
     Graphit #1c1c1e  Felder und Zeilen
     Haar    #2c2c2e  Linien
     Kreide  #f5f5f7  Text und Hauptbutton
     Nebel   #bcbcc1  Nebentext (hell genug für Milchglas)
     Farbe kommt nur aus den Kringeln links und den Erkennungszeichen der Tools. */
  --bg: #000000;
  --brand-panel: #000000;
  --surface: #1c1c1e;
  --surface-2: #232325;
  --line: #2c2c2e;
  --line-soft: #1f1f21;
  --hover: #161618;
  --ink: #f5f5f7;
  --ink-2: #bcbcc1;
  --ink-3: #8a8a8f;
  --btn-bg: #f5f5f7;
  --btn-ink: #000000;
  --btn-hover: #ffffff;
  --focus-ring: rgba(245, 245, 247, 0.28);
  --error: #ff6b5e;
  --error-bg: #2a1412;
  --logo-filter: invert(1);

  /* Milchglas: so dunkel, dass Text darauf sicher lesbar bleibt (Kontrast > 4.5:1) */
  --glass: rgba(16, 16, 18, 0.55);
  --glass-solid: #121214;
  --card-w: clamp(360px, 30vw, 460px); /* Breite der Login-Karte am Desktop */
  --edge: clamp(32px, 5vw, 112px);     /* Abstand zum Bildschirmrand */
  --glass-blur: 16px;
  --glass-edge: rgba(255, 255, 255, 0.09);
  --glass-field: rgba(255, 255, 255, 0.07);
  --glass-field-hover: rgba(255, 255, 255, 0.1);
  --glass-row: rgba(255, 255, 255, 0.055);
  --glass-row-hover: rgba(255, 255, 255, 0.09);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

/* =========================================================================
   Aufbau: Die Linien füllen die ganze Seite. Das Logo steht links (schmal: oben),
   das Login schwebt als dunkle Milchglas-Karte darüber.
   ========================================================================= */
.page { container: page / inline-size; min-height: 100dvh; position: relative; }
.split { position: relative; min-height: 100dvh; display: flex; flex-direction: column; }

.brand {
  position: fixed;
  inset: 0;
  z-index: 0;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 24px 0;
  background: var(--brand-panel);
}
.logo { position: relative; z-index: 2; margin: 0; width: min(260px, 66vw); }
.logo img { display: block; width: 100%; height: auto; filter: var(--logo-filter); }

.panel {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(220px, 34vh, 280px) 12px 24px;
}

/* Die Karte: dunkles Milchglas */
.panel-inner {
  width: 100%;
  max-width: 440px;
  padding: 32px 24px 28px;
  border-radius: 28px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  border: 1px solid var(--glass-edge);
  box-shadow:
    0 1px 0 0 rgba(255, 255, 255, 0.06) inset,
    0 30px 80px -20px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(0, 0, 0, 0.4);
}
/* Ohne Weichzeichner-Unterstützung oder bei „Transparenz reduzieren“: undurchsichtig */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel-inner { background: var(--glass-solid); }
}
@media (prefers-reduced-transparency: reduce) {
  .panel-inner { background: var(--glass-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@container page (min-width: 860px) {
  /* Rechts eine feste Spur für die Karte, links füllt das Logo den restlichen Platz.
     So überlappen sich Logo und Karte bei keiner Bildschirmgröße. */
  .brand {
    align-items: center;
    padding: 48px calc(var(--card-w) + var(--edge) * 2) 48px var(--edge);
  }
  .logo { width: min(86%, 820px); }
  .panel {
    align-items: center;
    justify-content: flex-end;
    padding: 48px var(--edge);
  }
  .panel-inner { width: var(--card-w); max-width: none; padding: 48px 44px 44px; border-radius: 32px; }
}

/* ---------- Kringel (gezeichnet von squiggles.js) ---------- */
.squiggles { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; display: block; }

/* Knopf zum Anhalten (Schleifen über 5 Sekunden brauchen einen) */
.motion-toggle {
  position: absolute;
  z-index: 3;
  right: 8px;
  top: 8px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 160ms var(--ease-out), background-color 160ms var(--ease-out), transform 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.motion-toggle svg { width: 16px; height: 16px; fill: currentColor; }
.motion-toggle .i-play { display: none; }
.motion-toggle[aria-pressed="true"] .i-play { display: block; }
.motion-toggle[aria-pressed="true"] .i-pause { display: none; }
.motion-toggle:active { transform: scale(0.94); }
.motion-toggle:focus-visible { opacity: 1; outline: 2px solid var(--ink); outline-offset: 2px; }
@container page (min-width: 860px) {
  .motion-toggle { right: auto; top: auto; left: 20px; bottom: 20px; }
}

/* =========================================================================
   Formularseite
   ========================================================================= */
.step { animation: step-in 320ms var(--ease-out) both; }
@keyframes step-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.title {
  margin: 0 0 36px;
  font-family: var(--font-display);
  font-size: clamp(38px, 8cqi, 52px);
  line-height: 1.02;
  font-weight: 760;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.lead {
  margin: 12px 0 36px;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink-2);
  text-wrap: pretty;
}
.text { margin: -20px 0 28px; color: var(--ink); }
.title + .muted { margin-top: -20px; }
.muted { color: var(--ink-2); }
code { font-family: var(--mono); font-size: 0.9em; }
a { color: inherit; text-decoration-color: var(--ink-3); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }

.stack { display: flex; flex-direction: column; }
.stack .field + .label { margin-top: 20px; }
.label {
  font-size: 15px;
  font-weight: 560;
  color: var(--ink);
  margin: 0 0 10px 2px;
}
.field {
  width: 100%;
  height: 56px;
  padding: 0 18px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--glass-field);
  border: 1px solid transparent;
  border-radius: var(--radius);
  outline: none;
  caret-color: var(--ink);
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.field:hover { background: var(--glass-field-hover); }
.field:focus-visible { border-color: rgba(245, 245, 247, 0.55); box-shadow: 0 0 0 4px var(--focus-ring); background: var(--glass-field); }
.field[aria-invalid="true"] { border-color: var(--error); }
.field[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 4px rgba(255, 107, 94, 0.2); }
.field-mono { font-family: var(--mono); font-size: 13px; }
.field:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: 0 0 0 100px #262628 inset; caret-color: var(--ink); }

/* Passwortfeld mit Anzeigen-Knopf */
.field-wrap { position: relative; }
.field-wrap .field { padding-right: 56px; }
.reveal {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.reveal svg { width: 20px; height: 20px; }
.reveal .i-hide { display: none; }
.reveal[aria-pressed="true"] .i-hide { display: block; }
.reveal[aria-pressed="true"] .i-show { display: none; }
.reveal:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

.error {
  min-height: 20px;
  margin: 10px 2px 12px;
  font-size: 15px;
  color: var(--error);
}
.error:empty { min-height: 0; margin: 0 0 16px; }
.notice {
  margin: 0 0 24px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--error-bg);
  color: var(--error);
  font-size: 15px;
}
.notice p { margin: 0; }
.notice p + p { margin-top: 4px; }
.stack .btn { margin-top: 4px; }
.stack .field + .btn { margin-top: 28px; }

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font: inherit;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background-color 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.btn-link { width: 100%; margin-top: 8px; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"] span { opacity: 0; }
.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link {
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 15px;
  font-weight: 560;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--ink-3);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  cursor: pointer;
  transition: text-decoration-color 160ms var(--ease-out);
}
.link:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

.secret {
  display: block;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--glass-field);
  font-size: 13px;
  word-break: break-all;
  user-select: all;
}

/* ---------- Tool-Auswahl ---------- */
.who {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: -24px 0 24px;
}
.who-email { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.apps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.app {
  border-radius: calc(var(--radius) + 2px);
  background: var(--glass-row);
  overflow: hidden;
  animation: step-in 360ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 60ms + 60ms);
  transition: background-color 200ms var(--ease-out);
}

.app-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 14px 16px 14px 18px;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.app-row:focus-visible { outline: 2px solid rgba(245, 245, 247, 0.6); outline-offset: -2px; border-radius: calc(var(--radius) + 2px); }
.app-mark { flex: none; width: 32px; height: 32px; }
.app-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-name { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.app-desc { font-size: 15px; color: var(--ink-2); }
.app-chevron {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--ink-3);
  transition: transform 260ms var(--ease-out), color 160ms var(--ease-out);
}
.app-row[aria-expanded="true"] .app-chevron { transform: rotate(90deg); color: var(--ink); }
.app-row[aria-busy="true"] { cursor: progress; }
.app-row[aria-busy="true"] .app-chevron { opacity: 0.3; }
.app:active:not(.is-open) { background: var(--glass-row-hover); }

/* Passwort klappt weich auf (Höhe über grid-template-rows) */
.app-drawer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 300ms var(--ease-out);
}
.app.is-open .app-drawer { grid-template-rows: 1fr; }
.app-login {
  min-height: 0;
  overflow: hidden;
  padding: 0 18px;
  opacity: 0;
  transition: opacity 200ms var(--ease-out), padding 300ms var(--ease-out);
}
.app.is-open .app-login { padding: 2px 18px 18px; opacity: 1; transition-delay: 60ms; }
.app-login .field { background: rgba(0, 0, 0, 0.35); }
.app-login .field:hover { background: rgba(0, 0, 0, 0.45); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* =========================================================================
   Verwaltung (admin.php)
   ========================================================================= */
.admin { display: flex; flex-direction: column; }
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 20px 0;
}
.admin-logo { display: block; width: 96px; border-radius: 6px; }
.admin-logo img { display: block; width: 100%; height: auto; filter: var(--logo-filter); }
.admin-logo:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 4px; }
.admin-main { width: 100%; max-width: 760px; margin: 0 auto; padding: 32px 20px 64px; }
.admin-login { max-width: 360px; margin: 8vh auto 0; }
.admin-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.admin .title { font-size: 34px; letter-spacing: -0.025em; }
.admin-login .title { margin-bottom: 28px; }
.admin-bar .title { margin: 0; }
.btn-small { height: 44px; padding: 0 16px; font-size: 15px; }
.btn-quiet { background: transparent; color: var(--ink); padding: 0 16px; }
.btn-danger { background: transparent; color: var(--error); padding: 0 12px; }
.btn-danger.is-armed { background: var(--error); color: #fff; }
.hint { margin: 16px 2px 0; font-size: 14px; color: var(--ink-3); }
.small { font-size: 14px; }

.users {
  container: users / inline-size;
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  overflow: hidden;
}
.user + .user { border-top: 1px solid var(--line-soft); }
.user { animation: step-in 320ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms); }
.user-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out);
}
.user-row:active { background: var(--hover); }
.user-row:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
.user-main { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-weight: 650; }
.user-email { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.user-date { display: none; font-size: 14px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--hover);
  border: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--ink-2);
}
.tag-strong { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-ink); font-weight: 600; }

@container users (min-width: 600px) {
  .user-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; align-items: center; gap: 16px; }
  .user-date { display: block; }
}

.sheet {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.sheet[open] { animation: sheet-in 220ms var(--ease-out) both; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.sheet-title { margin: 0 0 20px; font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.sheet .error { margin: 6px 1px 0; min-height: 0; }
.sheet .error:empty { margin: 0; }
.sheet .stack .error + .label,
.sheet .stack .field + .label { margin-top: 16px; }
.checks { margin: 18px 0 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 4px; }
.checks .label { padding: 0; margin-bottom: 6px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.check input:disabled + span { color: var(--ink-3); }
.sheet-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.sheet-actions .btn { height: 44px; }
.spacer { flex: 1; }

/* ---------- Tools ---------- */
.field-hint { margin: 8px 2px 0; font-size: 13px; line-height: 1.4; color: var(--ink-3); }
.check-top { align-items: flex-start; padding: 6px 0; }
.check-top input { margin-top: 3px; }
.secret-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.secret-row .field { grid-column: 1 / -1; width: 100%; font-size: 12px; }
.secret-row .btn { margin-top: 0 !important; width: 100%; }
.sheet .field-hint + .error:empty { margin: 0; }
#tool-edit .stack .error:empty + .label,
#tool-edit .stack .field-hint + .error:empty + .label,
#tool-edit .checks + .error:empty + .label { margin-top: 16px; }
#t-redirect-fields .label { display: block; margin-top: 16px; }
#t-id:disabled { opacity: 0.6; }

/* ---------- Verbindung testen ---------- */
.test-form { margin-top: 16px; display: flex; flex-direction: column; }
.test-row { display: flex; gap: 10px; flex-wrap: wrap; }
.test-row .field { flex: 1 1 260px; width: auto; }
.test-row .btn { flex: none; }
.test-results { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.test-results:empty { display: none; }
.test-result { padding: 14px 16px; border-radius: calc(var(--radius) + 2px); background: var(--surface); border-left: 3px solid var(--line); }
.test-result.is-ok { border-left-color: #34c759; }
.test-result.is-bad { border-left-color: var(--error); }
.test-head { margin: 0 0 4px; font-weight: 650; }
.test-body { margin: 0; color: var(--ink-2); font-size: 15px; }
.test-url { margin: 8px 0 0; font-family: var(--mono); font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }

/* ---------- Aufräumen ---------- */
.cleanup { margin-top: 56px; }
.title-sub { font-size: 26px !important; }
.btn-quiet-outline { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.files {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface);
  overflow: hidden;
}
.files li + li { border-top: 1px solid var(--line-soft); }
.file-row { padding: 10px 16px; min-height: 52px; gap: 12px; }
.file-name { flex: 1; min-width: 0; font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; }
.file-meta { flex: none; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cleanup-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.btn-danger:disabled { opacity: 0.4; cursor: default; }
.warn { color: #ffb86b; }

/* =========================================================================
   Hover nur bei echter Maus, Bewegung nur wenn erwünscht
   ========================================================================= */
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--btn-hover); }
  .btn-quiet:hover { background: var(--hover); }
  .btn-danger:hover { background: var(--error-bg); }
  .btn-danger.is-armed:hover { background: var(--error); }
  .user-row:hover { background: var(--hover); }
  .app:not(.is-open):hover { background: var(--glass-row-hover); }
  .app-row:hover .app-chevron { color: var(--ink); }
  .reveal:hover { color: var(--ink); background: var(--glass-field-hover); }
  .link:hover { text-decoration-color: currentColor; }
  .motion-toggle:hover { opacity: 1; background: var(--hover); }
}

@media (prefers-reduced-motion: reduce) {
  .step, .app, .user, .sheet[open] { animation: none !important; }
  .app-drawer, .app-login, .app-chevron { transition: none !important; }
  .btn:active, .motion-toggle:active { transform: none; }
}
