:root {
  color-scheme: dark;
  --ink: #f3f7f6;
  --muted: #9eaba8;
  --paper: #08070c;
  --panel: #121018;
  --panel-soft: #1d1827;
  --line: #342c45;
  --teal: #9b5cff;
  --teal-dark: #dccbff;
  --mint: #231437;
  --blue: #9b5cff;
  --blue-dark: #2b1746;
  --shadow: 0 24px 70px rgba(0, 0, 0, .42);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(135deg, rgba(155, 92, 255, .18), transparent 38%),
    linear-gradient(315deg, rgba(111, 63, 190, .18), transparent 32%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(290px, 360px) minmax(0, 1fr) minmax(280px, 330px);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar,
.security-panel {
  background: rgba(17, 25, 27, .9);
  backdrop-filter: blur(18px);
}

.sidebar {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-bar {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 40px 40px;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 16px;
}

.brand-mark,
.avatar,
.lock-symbol {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.brand-mark {
  width: 48px;
  height: 48px;
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, .14);
}

.logo-mark {
  overflow: hidden;
  background: #030606;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar:not(.logo-mark) {
  border-radius: 50%;
}

.brand-bar h1,
.conversation-title h2,
.panel-header h2,
.lock-card h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-bar h1 {
  font-size: 1.2rem;
}

.brand-black {
  color: #eef0f5;
}

.brand-chat {
  color: #a66bff;
}

.brand-bar p,
.conversation-title p,
.lock-card p,
.security-card p,
.form-note {
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.45;
}

.icon-button,
.text-button,
.primary-button,
.send-button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

.icon-button {
  width: 40px;
  background: #223033;
  color: var(--ink);
  font-weight: 800;
}

.icon-button:hover,
.text-button:hover,
.primary-button:hover,
.send-button:hover {
  transform: translateY(-1px);
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 18px 16px;
  padding: 10px 12px;
  border: 1px solid rgba(22, 140, 255, .34);
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
  font-size: .9rem;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(22, 140, 255, .15);
}

.search-box {
  padding: 0 18px 16px;
}

label {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1315;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 12px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(155, 92, 255, .18);
}

textarea.input-error {
  border-color: #ff6b6b;
  box-shadow: 0 0 0 3px rgba(255, 107, 107, .18);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px 8px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.text-button {
  min-height: 32px;
  padding: 0 12px;
  background: #223033;
  color: var(--teal-dark);
  font-weight: 800;
}

.chat-list {
  overflow: auto;
  padding: 0 10px 18px;
}

.chat-item {
  width: 100%;
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.chat-item:hover,
.chat-item.active {
  background: #1b292c;
}

.chat-open-button {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  padding: 12px 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: transform .18s ease;
}

.chat-delete-button {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 107, 107, .18);
  color: #ffb3b3;
  font-size: 1.35rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translate(14px, -50%) scale(.92);
  transition: opacity .18s ease, transform .18s ease;
}

.chat-item.delete-open .chat-open-button {
  transform: translateX(-56px);
}

.chat-item.delete-open .chat-delete-button {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%) scale(1);
}

.chat-delete-button:hover {
  background: rgba(255, 107, 107, .28);
  color: #ff9b9b;
}

.avatar {
  width: 44px;
  height: 44px;
  background: var(--blue);
}

.avatar.large {
  width: 48px;
  height: 48px;
  background: var(--blue);
  cursor: pointer;
}

.avatar.xl {
  width: 72px;
  height: 72px;
  font-size: 1.35rem;
}

.photo-avatar {
  overflow: hidden;
  background: #0c1315;
}

.photo-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-copy {
  min-width: 0;
}

.chat-name,
.chat-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-name {
  font-weight: 800;
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
}

.chat-preview,
.chat-time {
  color: var(--muted);
  font-size: .88rem;
}

.chat-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 10%, rgba(22, 140, 255, .09), transparent 24%),
    radial-gradient(circle at 76% 70%, rgba(16, 179, 165, .1), transparent 26%),
    rgba(8, 13, 15, .82);
}

.locked-view {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}

.lock-card {
  width: min(100%, 460px);
  padding: 28px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.lock-symbol {
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  background: var(--teal);
  font-size: 1.6rem;
}

.unlock-form {
  margin-top: 22px;
}

.profile-fields {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-fields label:not(:first-child) {
  margin-top: 4px;
}

.primary-button,
.send-button {
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(15, 118, 110, .22);
}

.primary-button {
  width: 100%;
  margin-top: 12px;
}

.reset-button {
  width: 100%;
  margin-top: 10px;
}

.conversation-view {
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.conversation-header {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 48px minmax(0, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 25, 27, .88);
  backdrop-filter: blur(16px);
}

.back-button {
  display: none;
}

.conversation-title {
  min-width: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 22px min(6vw, 58px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  width: fit-content;
  max-width: min(72%, 620px);
  padding: 10px 12px 8px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid rgba(255, 255, 255, .04);
  box-shadow: 0 10px 24px rgba(23, 33, 31, .08);
}

.message.me {
  align-self: flex-end;
  background: #0d2b4b;
  border-color: rgba(22, 140, 255, .28);
}

.message .author {
  color: var(--teal-dark);
  font-size: .78rem;
  font-weight: 800;
  margin-bottom: 3px;
}

.message p {
  margin: 0;
  line-height: 1.42;
}

.message-image {
  display: block;
  width: min(68vw, 320px);
  max-height: 360px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.message-audio {
  width: min(72vw, 320px);
  margin: 2px 0 4px;
}

.icon-button.recording {
  background: var(--coral, #d94f62);
  color: #fff;
}

.media-download {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  background: #223033;
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
  margin-bottom: 8px;
}

.message time {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: .74rem;
  text-align: right;
}

.message-status {
  margin-left: 6px;
  font-weight: 900;
  letter-spacing: 0;
}

.message-status.read {
  color: #35a8ff;
}

.composer {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 40px 40px minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(17, 25, 27, .92);
}

.composer label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.send-button {
  padding: 0 18px;
}

.security-panel {
  border-left: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.security-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  margin-bottom: 12px;
}

.security-card h3 {
  margin: 10px 0 0;
  font-size: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #223033;
  color: var(--teal-dark);
  font-size: .78rem;
  font-weight: 800;
}

.pill.strong {
  background: var(--teal);
  color: #fff;
}

code {
  display: block;
  margin-top: 10px;
  overflow-wrap: anywhere;
  color: var(--teal-dark);
  font-size: .88rem;
}

.contact-dialog {
  width: min(94vw, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.contact-dialog::backdrop {
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(4px);
}

.dialog-card {
  margin: 0;
  padding: 18px;
  background: var(--panel);
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.18rem;
}

.dialog-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.contact-list {
  display: grid;
  gap: 8px;
  max-height: min(52vh, 420px);
  overflow: auto;
  margin-bottom: 16px;
}

.contact-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1315;
  color: inherit;
  text-align: left;
}

.contact-item:hover {
  background: #1b292c;
}

.contact-copy {
  min-width: 0;
}

.contact-state {
  color: var(--teal-dark);
  font-size: .82rem;
  font-weight: 800;
}

.add-contact {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.add-contact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
}

.primary-button.compact {
  margin-top: 0;
  min-height: 44px;
  padding: 0 14px;
  white-space: nowrap;
}

.primary-button.full {
  width: 100%;
  margin-top: 10px;
}

.group-builder {
  display: grid;
  gap: 10px;
}

.group-contact-list {
  display: grid;
  gap: 8px;
}

.group-choice {
  display: grid;
  grid-template-columns: 22px 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1315;
}

.group-choice input {
  width: 18px;
  height: 18px;
}

.group-choice .avatar {
  width: 38px;
  height: 38px;
}

.settings-profile {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.settings-grid {
  display: grid;
  gap: 10px;
}

.toggle-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1315;
  color: var(--ink);
  font-size: .92rem;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  }

  .security-panel {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(86vw, 340px);
    transform: translateX(102%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
    z-index: 10;
  }

.security-panel.open {
  transform: translateX(0);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(92vw, 560px);
  min-height: 72px;
  padding: 12px 16px 12px 12px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, .14));
  backdrop-filter: blur(22px) saturate(150%);
  color: var(--ink);
  box-shadow: 0 18px 52px rgba(0, 0, 0, .42);
  cursor: pointer;
  transform: translateX(-50%);
}

.toast-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

.toast-avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .86);
  border-radius: 50%;
  background: #9b5cff;
}

.toast-copy {
  min-width: 0;
}

.toast-copy strong,
.toast-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-copy strong {
  color: #fff;
  font-size: .98rem;
  font-weight: 800;
}

.toast-copy span,
.toast-time {
  color: rgba(255, 255, 255, .82);
}

.toast-time {
  align-self: start;
  padding-top: 4px;
  font-size: .9rem;
}

.notification-button {
  width: 100%;
  margin-top: 12px;
}
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.chat-open {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .sidebar {
    min-height: 100vh;
    min-height: 100dvh;
  }

  .chat-panel,
  .conversation-view {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .chat-panel {
    display: none;
  }

  .app-shell.locked .sidebar {
    display: none;
  }

  .app-shell.locked .chat-panel {
    display: flex;
  }

  .app-shell.chat-open .sidebar {
    display: none;
  }

  .app-shell.chat-open .chat-panel {
    display: flex;
  }

  .back-button {
    display: inline-grid;
  }

  .conversation-header {
    grid-template-columns: 40px 44px minmax(0, 1fr) auto;
    padding: 12px;
  }

  .header-actions {
    gap: 6px;
  }

  .header-actions .icon-button {
    width: 36px;
  }

  .messages {
    padding: 16px 12px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .message {
    max-width: 86%;
  }

  .composer {
    position: sticky;
    bottom: 0;
    grid-template-columns: 40px 40px minmax(0, 1fr) 78px;
    padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  }

  .contact-dialog {
    width: calc(100vw - 24px);
  }

  .add-contact-row {
    grid-template-columns: 1fr;
  }
}

.settings-section {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(155, 92, 255, .05);
}

.settings-section h3 {
  margin: 0 0 6px;
  font-size: .95rem;
}

.blocked-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.blocked-user-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1315;
}

.avatar.small {
  width: 36px;
  height: 36px;
  font-size: .75rem;
}

.blocked-user-copy {
  display: grid;
  min-width: 0;
}

.blocked-user-copy small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-actions {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 18px;
}

.danger-button {
  min-height: 44px;
  border: 1px solid rgba(255, 92, 92, .45);
  border-radius: 8px;
  background: rgba(142, 31, 48, .2);
  color: #ff9a9a;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.danger-button:hover {
  background: rgba(142, 31, 48, .32);
}

.danger-button.full {
  width: 100%;
}

.secondary-danger {
  color: var(--ink);
  border-color: var(--line);
  background: #223033;
}

.message {
  position: relative;
}

.message-menu-button {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.message-menu-button:hover,
.message-menu-button:focus-visible {
  background: rgba(255, 255, 255, .08);
  color: var(--ink);
}

.message:not(.me) .author {
  padding-right: 30px;
}


/* Rechtliches / Account-Loeschung */
.legal-consent {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  margin-top: 12px;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}
.legal-consent input { margin-top: 3px; }
.legal-consent a, .legal-links a { color: #c8a8ff; text-decoration: none; }
.legal-consent a:hover, .legal-links a:hover { text-decoration: underline; }
.legal-links { display: grid; gap: 8px; margin-top: 10px; }
.legal-links a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1315;
  font-weight: 700;
}
.account-danger-zone { border-color: rgba(255, 92, 92, .28); background: rgba(142, 31, 48, .08); }
.delete-account-copy { display: grid; gap: 14px; }
.delete-account-copy p { margin: 0; color: var(--muted); line-height: 1.55; }
.delete-account-copy input {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1315;
  color: var(--ink);
  font: inherit;
}


/* PWA-Installationshinweis */
.install-banner{position:relative;z-index:80;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:10px 16px;background:linear-gradient(90deg,#191126,#24143d);border-bottom:1px solid rgba(155,92,255,.35);color:var(--ink)}.install-banner[hidden]{display:none}.install-banner>div:first-child{display:grid}.install-banner strong{font-size:.9rem}.install-banner span{font-size:.78rem;color:var(--muted)}.install-banner-actions{display:flex;align-items:center;gap:8px;flex-shrink:0}.install-help-card{max-width:560px}.install-help-platform{padding:14px;border:1px solid var(--line);border-radius:10px;background:#0c1315;margin:10px 0}.install-help-platform[hidden]{display:none}.install-help-platform h3{margin:0 0 8px}.install-help-platform ol{margin:0;padding-left:22px;color:var(--muted)}.install-help-platform li+li{margin-top:7px}.install-site-link{display:inline-block;margin-top:10px;color:#c8a8ff;text-decoration:none}.install-site-link:hover{text-decoration:underline}@media(max-width:640px){.install-banner{align-items:flex-start;flex-direction:column}.install-banner-actions{width:100%}.install-banner-actions .primary-button{flex:1}.install-banner-actions .text-button{flex:1}}

/* Supporter */
.supporter-settings{border-color:rgba(155,92,255,.45)!important;background:linear-gradient(135deg,rgba(155,92,255,.10),rgba(18,18,30,.25))}.supporter-settings-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.supporter-status{font-size:12px;font-weight:800;padding:6px 9px;border-radius:999px;background:rgba(155,92,255,.14);color:#caa7ff;white-space:nowrap}.supporter-link{display:inline-flex;text-decoration:none;justify-content:center;margin-top:8px}.supporter-status.active{background:rgba(95,211,156,.14);color:#74dfb2}
