/* GögglMessenger: Gestaltung.
   Die Farben kommen aus dem Logo: sein Gelb, Schwarz für den Hahn und ein
   Signalrot für alles, was geprüft ist oder schiefging. Der Schriftzug ist
   eine Grafik aus dem Logo (web/wordmark-gelb.png). Sonst kommen nur
   Systemschriften vor, damit die App keine Anfrage an fremde Server stellt. */

:root {
  --yellow: #d79500; /* exakt der Hintergrund des Logos */
  --black: #000000;
  --ink: #1a1a1a;
  --paper: #f3f2ee;
  --sheet: #ffffff;
  --line: #d6d4cc;
  --muted: #5e5c55;
  --laser: #c81e1e;
  --focus: #0b57d0;

  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-digits: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 2.4rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--step-0) / 1.5 var(--font-text);
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Prüfsiegel: erscheint nur bei verifizierten Kontakten. */
.seal__wax {
  fill: var(--laser);
}

.seal__ring {
  fill: none;
  stroke: #fff;
  stroke-opacity: 0.6;
  stroke-width: 1.1;
}

/* ------------------------------------------------------------- Bedienelemente */

.button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--sheet);
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  border-color: var(--black);
}

.button--primary {
  border-color: var(--black);
  background: var(--black);
  color: #fff;
}

.button--primary:hover {
  background: #2b2b2b;
  border-color: #2b2b2b;
}

.button--danger {
  border-color: var(--laser);
  background: var(--laser);
  color: #fff;
}

.button--light {
  border-color: rgb(255 255 255 / 0.5);
  background: transparent;
  color: #fff;
}

.button--light:hover {
  border-color: var(--yellow);
  color: var(--yellow);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.link {
  border: 0;
  background: none;
  padding: 0.25rem 0;
  color: var(--muted);
  font-size: var(--step--1);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.link:hover,
.link--danger {
  color: var(--laser);
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--sheet);
  padding: 0.5rem 0.7rem;
}

input[type="text"]:focus-visible,
textarea:focus-visible {
  outline-offset: 0;
  border-color: var(--black);
}

.form-error {
  margin-top: 0.5rem;
  color: var(--laser);
  font-size: var(--step--1);
  font-weight: 600;
}

.boot {
  padding: 2rem;
  color: var(--muted);
}

/* -------------------------------------------------------------- Erster Start */

.welcome {
  min-height: 100%;
  display: grid;
  place-items: center;
  background: var(--yellow);
  color: var(--black);
  padding: clamp(1.25rem, 5vw, 4rem);
}

.poster {
  display: grid;
  grid-template-columns: minmax(0, 25rem) minmax(0, 30rem);
  align-items: center;
  gap: clamp(1.5rem, 5vw, 4.5rem);
  max-width: 63rem;
}

/* Das Logo hat denselben Hintergrund wie die Seite und steht deshalb ohne Rand. */
.poster__logo {
  display: block;
  width: 100%;
  height: auto;
}

.poster h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(1.6rem, 4.2vw, 2.3rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.poster p {
  max-width: 30em;
}

.server {
  margin-top: 1.5rem;
  max-width: 24rem;
}

.server label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.server input {
  border-color: var(--black);
}

.server__hint {
  margin-top: 0.4rem;
  font-size: var(--step--1);
}

.poster .button {
  margin-top: 1.5rem;
  padding: 0.75rem 1.4rem;
}

/* Auf Gelb ist Rot schlecht lesbar: Fehler stehen schwarz auf Weiß. */
.poster .form-error {
  width: fit-content;
  margin-top: 1rem;
  border-left: 4px solid var(--laser);
  background: var(--sheet);
  color: var(--black);
  padding: 0.5rem 0.75rem;
}

.poster__note {
  margin-top: 1.75rem;
  border-top: 2px solid var(--black);
  padding-top: 0.9rem;
  font-size: var(--step--1);
}

.maker {
  margin-top: 0.75rem;
  font-size: var(--step--1);
  font-weight: 700;
}

/* ----------------------------------------------------------------- Grundriss */

.shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(17rem, 21rem) 1fr;
  grid-template-rows: auto minmax(0, 1fr);
}

.banner {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  background: var(--laser);
  color: #fff;
  padding: 0.6rem 1rem;
}

.sidebar {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--sheet);
}

.chat {
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------- Seitenleiste */

.me {
  background: var(--black);
  color: #fff;
  padding: 0.9rem 1rem 0.9rem;
}

.me__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.me__icon {
  flex: none;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 8px;
}

.me__wordmark {
  min-width: 0;
  width: 10.5rem;
  height: auto;
}

.me__profile {
  margin-left: auto;
  border: 1px dashed rgb(255 255 255 / 0.6);
  border-radius: 4px;
  padding: 0 0.4rem;
  font-size: var(--step--1);
}

.me__label {
  margin-top: 1rem;
  font-size: var(--step--1);
  opacity: 0.8;
}

.me__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.me__id {
  font-family: var(--font-digits);
  font-size: var(--step-2);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.3;
  user-select: all;
}

.me__row .button {
  padding: 0.3rem 0.7rem;
  font-size: var(--step--1);
}

.connection {
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--step--1);
  opacity: 0.9;
}

.connection::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border: 1.5px solid var(--yellow);
  border-radius: 50%;
}

.connection[data-state="online"]::before {
  background: var(--yellow);
}

.add {
  border-bottom: 1px solid var(--line);
  padding: 0.9rem 1rem 1rem;
}

.add label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: var(--step--1);
  font-weight: 600;
}

.add__row {
  display: flex;
  gap: 0.5rem;
}

.add__row input {
  min-width: 0;
  font-family: var(--font-digits);
  text-transform: uppercase;
}

.add__row input::placeholder {
  font-family: var(--font-text);
  text-transform: none;
}

.contacts {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.1rem 0.75rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 5px solid transparent;
  background: none;
  padding: 0.7rem 1rem 0.7rem calc(1rem - 5px);
  text-align: left;
  cursor: pointer;
}

.contact:hover {
  background: var(--paper);
}

.contact[aria-current="true"] {
  border-left-color: var(--yellow);
  background: var(--paper);
}

.contact:focus-visible {
  outline-offset: -3px;
}

.contact__name {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-weight: 600;
}

.contact__name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact__name svg {
  flex: none;
  width: 0.95rem;
  height: 0.95rem;
}

.contact__time {
  color: var(--muted);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.contact__preview {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--step--1);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact__unread {
  justify-self: end;
  min-width: 1.35rem;
  border-radius: 1rem;
  background: var(--yellow);
  color: var(--black);
  padding: 0 0.4rem;
  font-size: var(--step--1);
  font-weight: 700;
  text-align: center;
}

.hint {
  flex: 1;
  padding: 1rem;
  color: var(--muted);
  font-size: var(--step--1);
}

.contacts:not(:empty) + .hint {
  display: none;
}

.contacts:empty {
  display: none;
}

.sidebar__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  padding: 0.5rem 1rem;
  color: var(--muted);
  font-size: var(--step--1);
}

/* ----------------------------------------------------------------------- Chat */

.chat__empty {
  flex: 1;
  display: grid;
  place-items: center;
  background: var(--yellow);
  padding: 2rem;
}

.chat__empty-note {
  background: var(--black);
  color: #fff;
  padding: 0.9rem 1.4rem;
  font-weight: 600;
}

.chat__open {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--sheet);
  padding: 0.7rem 1.25rem;
}

.chat__who {
  flex: 1;
  min-width: 0;
}

.chat__who h2 {
  overflow: hidden;
  font-size: var(--step-1);
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat__who p {
  color: var(--muted);
  font-family: var(--font-digits);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
}

.back {
  display: none;
  border: 0;
  background: none;
  padding: 0.25rem;
  cursor: pointer;
}

.back svg {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Prüfstatus des Kontakts: gestrichelter Kreis = offen, rotes Siegel = geprüft. */
.trust {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: var(--sheet);
  padding: 0.3rem 0.8rem 0.3rem 0.4rem;
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.trust:hover {
  border-color: var(--black);
}

.trust svg {
  width: 1.3rem;
  height: 1.3rem;
}

.trust[data-verified="false"] svg {
  border: 1.5px dashed var(--muted);
  border-radius: 50%;
}

.trust[data-verified="false"] svg use {
  display: none;
}

.trust[data-verified="true"] {
  border-color: var(--laser);
  color: var(--laser);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 1.25rem clamp(0.75rem, 3vw, 2rem);
  list-style: none;
}

.messages > :first-child {
  margin-top: auto;
}

.day {
  align-self: center;
  margin: 0.75rem 0 0.35rem;
  color: var(--muted);
  font-size: var(--step--1);
}

.msg {
  max-width: min(34rem, 85%);
  border-radius: 12px;
  padding: 0.5rem 0.8rem 0.4rem;
}

.msg--in {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
  background: var(--sheet);
}

/* Eigene Nachrichten in der Farbe des Logos, Schrift schwarz wie der Hahn. */
.msg--out {
  align-self: flex-end;
  border-bottom-right-radius: 3px;
  background: var(--yellow);
  color: var(--black);
}

.msg__text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.msg__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0 0.5rem;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.msg--in .msg__meta {
  color: var(--muted);
}

.msg[data-status="failed"] {
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--laser);
}

.msg[data-status="failed"] .msg__meta {
  color: var(--laser);
  font-weight: 600;
}

.msg__retry {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.msg-notice {
  align-self: center;
  max-width: 30rem;
  border-left: 4px solid var(--laser);
  background: var(--sheet);
  padding: 0.6rem 0.9rem;
  font-size: var(--step--1);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  border-top: 1px solid var(--line);
  background: var(--sheet);
  padding: 0.7rem clamp(0.75rem, 3vw, 2rem);
}

.composer textarea {
  field-sizing: content;
  min-height: 2.6rem;
  max-height: 9rem;
  resize: none;
  line-height: 1.4;
}

.composer .button {
  min-height: 2.6rem;
}

/* -------------------------------------------------------------------- Dialoge */

.dialog {
  width: min(29rem, calc(100vw - 2rem));
  border: 0;
  border-top: 6px solid var(--yellow);
  background: var(--sheet);
  color: var(--ink);
  padding: 1.75rem;
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.7);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.dialog h2 {
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.dialog h3 {
  margin-top: 1.5rem;
  font-size: var(--step-0);
}

.dialog h2 + p {
  margin-top: 0.5rem;
}

.dialog label {
  display: block;
  margin: 1.25rem 0 0.35rem;
  font-size: var(--step--1);
  font-weight: 600;
}

.dialog__id {
  color: var(--muted);
  font-family: var(--font-digits);
  letter-spacing: 0.04em;
}

.dialog__hint {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: var(--step--1);
}

.safety {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin: 0.6rem 0 0.8rem;
  background: var(--black);
  color: var(--yellow);
  padding: 0.9rem 1.1rem;
  font-family: var(--font-digits);
  font-size: var(--step-2);
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.5rem 0 0.75rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 10;
  max-width: min(32rem, calc(100vw - 2rem));
  translate: -50% 0;
  background: var(--black);
  color: #fff;
  padding: 0.7rem 1rem;
  font-size: var(--step--1);
  box-shadow: 0 10px 30px -12px rgb(0 0 0 / 0.8);
}

/* --------------------------------------------------------------- Kleine Geräte */

@media (max-width: 720px) {
  .poster {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .poster__logo {
    width: min(72vw, 17rem);
    margin: 0 auto;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .shell[data-pane="list"] .chat,
  .shell[data-pane="chat"] .sidebar {
    display: none;
  }

  .sidebar {
    border-right: 0;
  }

  .back {
    display: block;
  }

  .chat__head {
    padding-inline: 0.75rem;
  }

  .safety {
    font-size: var(--step-1);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .dialog[open] {
    animation: unfold 160ms ease-out;
  }

  @keyframes unfold {
    from {
      opacity: 0;
      translate: 0 0.5rem;
    }
  }
}
