:root {
  --bg: #f6f7f9;
  --fg: #1b1f24;
  --muted: #5d6673;
  --card: #ffffff;
  --line: #d9dde3;
  --accent: #1f5fbf;
  --danger: #b3261e;
  --ok: #1e7a3c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --fg: #e6e8eb;
    --muted: #9aa3ad;
    --card: #1e2227;
    --line: #343a42;
    --accent: #6ea2ff;
    --danger: #ff8a80;
    --ok: #7bd88f;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* iPhone and iPad: follow Dynamic Type (Settings → Display → Text Size). Everything
   below is in rem/em, so the whole UI scales with it. */
@supports (font: -apple-system-body) {
  @media (pointer: coarse) { html { font: -apple-system-body; } }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: .9375rem;
  line-height: 1.45;
  overflow-wrap: break-word;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: .75rem max(1rem, env(safe-area-inset-right)) .75rem max(1rem, env(safe-area-inset-left));
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 1.0625rem; margin: 0; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; }
main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem max(1rem, env(safe-area-inset-right)) 1rem max(1rem, env(safe-area-inset-left));
}
h2 { font-size: 1.1875rem; margin: .5rem 0 .75rem; }
h3 { font-size: .9375rem; margin: 1rem 0 .375rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .8125rem; }
label { display: block; margin: .625rem 0 .25rem; font-weight: 600; }
input, select {
  width: 100%;
  max-width: 26rem;
  padding: .4375rem .5625rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
}
button {
  margin-top: .625rem;
  padding: .4375rem .875rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
button.secondary, button.tab, button.link {
  background: transparent;
  color: var(--accent);
}
button.tab, button.link { margin-top: 0; }
button.tab[aria-current="page"] { background: var(--accent); color: #fff; }
button.link { border-color: transparent; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) {
  button, button.tab[aria-current="page"], button.danger { color: #10141a; }
}
/* Touch: targets of at least 44 pt (Apple HIG). */
@media (pointer: coarse) {
  button, input, select { min-height: 2.75rem; }
  button.open { min-width: 2.75rem; }
}

/* --- tables: rows above 700 px, cards below ------------------------------------- */
.grid {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: .875rem;
}
.grid th, .grid td {
  padding: .375rem .5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
}
/* Long addresses and messages break anywhere instead of widening the page; the other
   columns keep whole words, so the table layout does not squeeze them to one letter. */
.grid td.email { overflow-wrap: anywhere; min-width: 9em; }
.grid th { font-weight: 600; }
.grid td.nowrap { white-space: nowrap; overflow-wrap: normal; }
.grid tbody tr.clickable { cursor: pointer; }
.grid tbody tr.clickable:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.grid td.hash { font-family: ui-monospace, Menlo, monospace; font-size: .75rem; word-break: break-all; }
.grid td.msg { width: 38%; min-width: 12rem; }
.grid .clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.grid button.open {
  margin: 0;
  padding: .125rem .375rem;
  font-variant-numeric: tabular-nums;
}
.grid td.actions button { margin: 0; }
.grid td.empty { color: var(--muted); }

@media (max-width: 700px) {
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid { background: transparent; border: 0; font-size: .9375rem; }
  .grid thead {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
  }
  .grid tr {
    margin: 0 0 .75rem;
    padding: .5rem .875rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  .grid td {
    display: grid;
    grid-template-columns: minmax(6.5em, 35%) minmax(0, 1fr);
    gap: .75rem;
    padding: .3125rem 0;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  }
  .grid td:last-child { border-bottom: 0; }
  .grid td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
  }
  .grid td.nowrap { white-space: normal; }
  .grid td.hash::before { font-family: system-ui, -apple-system, sans-serif; font-size: .9375rem; word-break: normal; }
  .grid td.msg { display: block; width: 100%; min-width: 0; }
  .grid td.email { min-width: 0; }
  .grid td.msg::before { display: block; margin-bottom: .125rem; }
  .grid td.msg .clamp { -webkit-line-clamp: 8; line-clamp: 8; }
  .grid td.empty, .grid td.actions, .grid td.idcell { display: block; }
  .grid td.empty::before, .grid td.actions::before, .grid td.idcell::before { content: none; }
  .grid td.idcell button.open { padding: .25rem 0; font-weight: 600; text-align: left; }
  .grid td.idcell button.open::before { content: "Eintrag "; }
  .grid td.actions button { width: 100%; margin-top: .25rem; }
  .grid tbody tr.clickable:hover { background: var(--card); }
  .grid tbody tr { container-type: inline-size; }
}
/* Large Dynamic Type sizes: the label goes above its value once the card is narrow
   relative to the text size (container units follow the font size). */
@container (max-width: 18em) {
  .grid td { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

.pager { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-top: .5rem; }
.pager button { margin-top: 0; }
.fields {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: .25rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .625rem .75rem;
  margin: 0;
}
.fields dt { color: var(--muted); }
.fields dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .fields { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .fields dt { margin-top: .5rem; font-weight: 600; }
  .fields dt:first-child { margin-top: 0; }
}
.message {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .625rem .75rem;
  font: inherit;
  max-width: 100%;
}
.status { min-height: 1.4em; margin: 0 0 .5rem; }
.status.error { color: var(--danger); }
.status.ok { color: var(--ok); }
dialog {
  max-width: 34rem;
  width: calc(100% - 2rem);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
p.actions button, p > button { margin-right: .25rem; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0 0 .75rem; }
.filters label { margin: 0; }
.filters select { width: auto; }

#who { align-self: center; font-size: .8125rem; }
#view-login p button { margin-top: 0; }
#view-login .hint button.link { padding: 0; font-size: inherit; min-height: 0; }
[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }
