/* Gemeinsames, schlankes Styling fuer Admin- und User-Frontend. */
/* Theming ueber CSS-Variablen: Light (Default) + Dark via [data-theme="dark"]. */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e3e8ee;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;

  /* abgeleitete Flaechen/Effekte */
  --input-bg: #ffffff;
  --subtle: #eef1f5;     /* Segmented / Typetoggle Hintergrund */
  --subtle-2: #e5e7eb;   /* sekundaere Buttons / Tabs */
  --shadow: rgba(31, 41, 51, 0.06);
  --shadow-strong: rgba(0, 0, 0, 0.12);
  --token-bg: #f8fafc;
  --code-bg: #ffffff;
  --accent-focus: rgba(37, 99, 235, 0.12);

  /* Badges */
  --badge-fwd-bg: #dbeafe;   --badge-fwd-ink: #1e40af;
  --badge-trash-bg: #fef3c7; --badge-trash-ink: #92400e;
  --badge-on-bg: #dcfce7;    --badge-on-ink: #166534;
  --badge-off-bg: #fee2e2;   --badge-off-ink: #991b1b;

  /* Hinweise */
  --notice-err-bg: #fee2e2;  --notice-err-ink: #991b1b;
  --notice-ok-bg: #dcfce7;   --notice-ok-ink: #166534;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1419;
  --card: #171c23;
  --ink: #e6e9ee;
  --muted: #9aa4b2;
  --line: #2a323c;
  --accent: #3b82f6;
  --accent-ink: #ffffff;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;

  --input-bg: #1f262e;
  --subtle: #222b35;
  --subtle-2: #2a323c;
  --shadow: rgba(0, 0, 0, 0.40);
  --shadow-strong: rgba(0, 0, 0, 0.55);
  --token-bg: #1b222b;
  --code-bg: #11161c;
  --accent-focus: rgba(59, 130, 246, 0.28);

  --badge-fwd-bg: #1e3a5f;   --badge-fwd-ink: #93c5fd;
  --badge-trash-bg: #4a3410; --badge-trash-ink: #fcd34d;
  --badge-on-bg: #14532d;    --badge-on-ink: #86efac;
  --badge-off-bg: #4c1d1d;   --badge-off-ink: #fca5a5;

  --notice-err-bg: #4c1d1d;  --notice-err-ink: #fca5a5;
  --notice-ok-bg: #14532d;   --notice-ok-ink: #86efac;

  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
}

header.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header.topbar h1 {
  font-size: 1.15rem;
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lang-select {
  width: auto;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* Theme-Umschalter */
.theme-toggle {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 36px;
  height: 32px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--accent); }

.container {
  max-width: 960px;
  margin: 1.5rem auto;
  padding: 0 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--input-bg);
  color: var(--ink);
}
input::placeholder { color: var(--muted); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-focus);
}

.field { margin-bottom: 0.9rem; }

.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.row > .field { flex: 1; min-width: 160px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font-size: 0.9rem;
  background: var(--accent);
  color: var(--accent-ink);
}
button.secondary { background: var(--subtle-2); color: var(--ink); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.ghost:hover { color: var(--ink); border-color: var(--accent); }
button.danger { background: var(--danger); color: #fff; }
button.small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
button:disabled { opacity: 0.55; cursor: default; }
button:not(.small):not(.ghost):not(.secondary):hover { filter: brightness(1.05); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge.forward { background: var(--badge-fwd-bg); color: var(--badge-fwd-ink); }
.badge.trash { background: var(--badge-trash-bg); color: var(--badge-trash-ink); }
.badge.on { background: var(--badge-on-bg); color: var(--badge-on-ink); }
.badge.off { background: var(--badge-off-bg); color: var(--badge-off-ink); }

.muted { color: var(--muted); font-size: 0.85rem; }

.notice {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: none;
}
.notice.show { display: block; }
.notice.error { background: var(--notice-err-bg); color: var(--notice-err-ink); }
.notice.ok { background: var(--notice-ok-bg); color: var(--notice-ok-ink); }

.hidden { display: none !important; }

.login-wrap {
  max-width: 380px;
  margin: 4rem auto;
}

.inline-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

a { color: var(--accent); }
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: var(--subtle-2); color: var(--ink); }
.tabs button.active { background: var(--accent); color: var(--accent-ink); }

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.rule { border: none; border-top: 1px solid var(--line); }
.mailbody { white-space: pre-wrap; word-break: break-word; }

/* ===== Public start page: hero + adaptive composer ===================== */
.hero { text-align: center; margin: 2rem 0 1.5rem; }
.hero-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  margin: 0 0 0.4rem;
  letter-spacing: -0.02em;
}
.hero-sub { color: var(--muted); margin: 0; font-size: 1.02rem; }

/* Segmented mode switch */
.segmented {
  display: inline-flex;
  background: var(--subtle);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  margin: 0 auto 1rem;
  width: max-content;
  max-width: 100%;
}
.segmented .seg {
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-weight: 600;
  white-space: nowrap;
}
.segmented .seg.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px var(--shadow-strong);
}
/* center the segmented control as a block */
#modeNav { display: flex; justify-content: center; }
.public-center { text-align: center; }

/* Adaptive single-line composer */
.composer {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.6rem;
  box-shadow: 0 6px 24px var(--shadow);
}
.composer input,
.composer select { height: 44px; }
.composer .grow { flex: 1 1 220px; min-width: 0; }
.composer .num { width: 92px; flex: 0 0 auto; text-align: center; }
.composer > button { flex: 0 0 auto; padding-inline: 1.3rem; font-weight: 600; }

/* Type toggle pill inside composer */
.typetoggle {
  display: inline-flex;
  background: var(--subtle);
  border-radius: 10px;
  padding: 3px;
  flex: 0 0 auto;
}
.typetoggle .tt {
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 0 0.85rem;
  font-weight: 600;
  font-size: 0.85rem;
}
.typetoggle .tt.active { background: var(--accent); color: var(--accent-ink); }

/* local@domain compound field */
.at-field {
  display: inline-flex;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 0.5rem;
  flex: 1 1 240px;
  min-width: 0;
}
.at-field input {
  border: none;
  background: transparent;
  padding-inline: 0.2rem;
  flex: 1 1 60px;
  min-width: 0;
  height: 42px;
}
.at-field .at { color: var(--muted); padding: 0 0.15rem; }
.at-field select {
  border: none;
  background: transparent;
  width: auto;
  flex: 0 1 auto;
  padding-inline: 0.2rem;
  height: 42px;
}
.at-field input:focus,
.at-field select:focus { outline: none; box-shadow: none; }
.at-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-focus); }

.composer-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.6rem 0.2rem 0;
  text-align: center;
}

.panel { margin-bottom: 1.25rem; }
.manage-result {
  margin-top: 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}

/* Result card */
.result-card { border-color: var(--ok); }
.result-addr { font-size: 1.15rem; font-weight: 600; margin: 0.25rem 0 0.75rem; }
.token-box {
  background: var(--token-bg);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.9rem;
  margin-top: 0.75rem;
}
.token-code {
  display: block;
  word-break: break-all;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  margin: 0.4rem 0;
}

@media (max-width: 620px) {
  .composer { flex-direction: column; }
  .composer .grow,
  .composer .num,
  .composer > button,
  .at-field,
  .typetoggle { flex: 1 1 auto; width: 100%; }
  .composer .num { text-align: left; }
  .typetoggle .tt { flex: 1; }
}
