/* ── Tokens ──────────────────────────────────────────── */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3250;
  --accent: #c0392b;
  --accent2: #2a9d8f;
  --text: #e8eaf0;
  --text-muted: #8a8fa8;
  --radius: 12px;
  --font: system-ui, -apple-system, sans-serif;

  /* Bubble colours — dark theme (--team-color overrides --bubble-mine-bg when set) */
  --team-color: #1a4a7a;
  --bubble-mine-bg: var(--team-color);
  --bubble-mine-meta: rgba(255,255,255,.65);
  --bubble-admin-bg: #2d6a2d;
  --bubble-admin-border: #3a7a3a;
  --bubble-admin-label: rgba(255,255,255,.75);
}

:root[data-theme="light"] {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface2: #ede9e2;
  --border: #ccc8bf;
  --accent: #c0392b;
  --accent2: #1a7a6e;
  --text: #1a1a1a;
  --text-muted: #555;

  /* Bubble colours — light theme */
  --team-color: #1a5a9a;
  --bubble-mine-bg: var(--team-color);
  --bubble-mine-meta: rgba(255,255,255,.70);
  --bubble-admin-bg: #1e5c1e;
  --bubble-admin-border: #2a7a2a;
  --bubble-admin-label: rgba(255,255,255,.80);
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* non-chat pages scroll normally */
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .65rem 1rem;
  flex-shrink: 0;
}
.header-inner {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header-logo {
  font-size: 1.05rem; font-weight: 700; letter-spacing: .03em;
  color: var(--text); text-decoration: none;
}
.header-right { display: flex; align-items: center; gap: .6rem; }
.header-team-link {
  display: flex; align-items: center; gap: .45rem;
  text-decoration: none; color: var(--text);
}
.header-team-link:hover { opacity: .8; }
.header-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--border); flex-shrink: 0;
}
.header-avatar-placeholder {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--team-color, var(--accent)); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700; border: 2px solid var(--border); flex-shrink: 0;
}
.header-team-name {
  font-size: .85rem; color: var(--text-muted);
  max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: .22rem .48rem; cursor: pointer; font-size: 1rem; line-height: 1;
  color: var(--text); transition: border-color .15s; flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent2); }

/* ── Test bar ────────────────────────────────────────── */
.test-bar {
  background: #2a9d5c; color: #fff;
  text-align: center; padding: .35rem 1rem;
  font-size: .85rem; font-weight: 600; flex-shrink: 0;
}
.test-bar a { color: #fff; text-decoration: underline; }

/* ── Main ────────────────────────────────────────────── */
.main-content {
  flex: 1; min-height: 0;
  max-width: 700px; width: 100%;
  margin: 0 auto; padding: 1rem;
  display: flex; flex-direction: column;
}

/* ── Non-chat pages (center-box, setup) ─────────────── */
.center-box {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 60vh; text-align: center; gap: 1rem;
}
.advent-icon { font-size: 4rem; }
.center-box h1 { font-size: 1.8rem; color: var(--text); }
.login-msg { font-size: 1.15rem; color: var(--text-muted); }
.admin-link-small { font-size: .85rem; margin-top: 1rem; }
.admin-link-small a { color: var(--text-muted); }

.setup-box { max-width: 480px; margin: 1.5rem auto; }
.setup-box h1 { margin-bottom: .4rem; color: var(--text); }
.setup-box > p { color: var(--text-muted); margin-bottom: 1.25rem; }
.setup-form { display: flex; flex-direction: column; gap: .7rem; }
.setup-form label { font-weight: 600; font-size: .9rem; color: var(--text); }
.optional { font-weight: 400; color: var(--text-muted); }
.setup-form input[type=text],
.setup-form input[type=file] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .65rem .9rem;
  font-size: 1rem; width: 100%;
}
.setup-form input[type=text]::placeholder { color: var(--text-muted); }
.current-photo img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; }

/* Color picker */
.color-picker { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .25rem; }
.color-option { cursor: pointer; }
.color-swatch {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: .9rem; color: #fff; font-weight: 700;
  border: 3px solid transparent; transition: border-color .15s, transform .1s;
}
.color-option input:checked + .color-swatch {
  border-color: #fff; transform: scale(1.15);
  box-shadow: 0 0 0 2px rgba(255,255,255,.3);
}
:root[data-theme="light"] .color-option input:checked + .color-swatch {
  border-color: #333;
  box-shadow: 0 0 0 2px rgba(0,0,0,.2);
}

/* Setup QR */
.setup-qr { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1.5rem; text-align: center; }
.setup-qr-label { font-size: .85rem; color: var(--text-muted); margin-bottom: .5rem; }
.setup-qr-img { display: inline-block; background: #fff; padding: 8px; border-radius: 8px; }
.setup-qr-img svg { width: 180px; height: 180px; display: block; }
.setup-qr-url { margin-top: .5rem; color: var(--text-muted); font-size: .8rem; word-break: break-all; }

/* Buttons */
.btn { display: inline-block; padding: .7rem 1.5rem; border-radius: 8px; border: none; cursor: pointer; font-size: 1rem; font-weight: 600; transition: opacity .15s; }
.btn:hover { opacity: .85; }
.btn-primary { background: #2a9d5c; color: #fff; }

/* ── Chat page ───────────────────────────────────────── */
.chat-page { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* Day divider */
.day-divider {
  display: flex; align-items: center; gap: .6rem;
  color: var(--text-muted); font-size: .78rem; margin: .4rem 0; flex-shrink: 0;
}
.day-divider::before, .day-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.day-divider span { white-space: nowrap; padding: 0 .4rem; }

/* Chat scroll area */
.chat-area {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: .5rem 0;
  display: flex; flex-direction: column; gap: .5rem;
  -webkit-overflow-scrolling: touch;
}

/* Bubbles */
.chat-bubble {
  border-radius: var(--radius);
  padding: .6rem .85rem;
  max-width: 88%; min-width: 60px;
  word-break: break-word; line-height: 1.5;
  color: var(--text);
  background: var(--surface2);
}
.chat-bubble.mine {
  background: var(--bubble-mine-bg);
  color: #fff;
  align-self: flex-end;
}
.chat-bubble.admin-msg {
  background: var(--bubble-admin-bg);
  color: #fff;
  align-self: flex-start;
  border: 1px solid var(--bubble-admin-border);
}

.bubble-label {
  font-size: .75rem; font-weight: 700; margin-bottom: .3rem;
  color: var(--bubble-admin-label);
}
.bubble-meta-admin {
  font-size: .72rem; margin-top: .3rem;
  color: var(--bubble-admin-label); opacity: .75;
}
.bubble-meta {
  font-size: .72rem;
  color: var(--bubble-mine-meta);
  margin-bottom: .15rem;
  display: flex; align-items: center; gap: .4rem;
}
.delete-btn {
  background: none; border: none;
  color: var(--bubble-mine-meta);
  cursor: pointer; font-size: .8rem; padding: 0 .1rem; line-height: 1;
  margin-left: auto; opacity: .7;
}
.delete-btn:hover { opacity: 1; color: #ff8080; }

.chat-img {
  display: block; max-width: 100%; max-height: 300px;
  border-radius: 8px; margin-top: .4rem; object-fit: contain;
}
.chat-audio { margin-top: .4rem; width: 100%; }

/* Input area */
.input-area {
  border-top: 1px solid var(--border);
  padding: .6rem 0 .4rem;
  display: flex; flex-direction: column; gap: .45rem;
  flex-shrink: 0;
}
.input-row { display: flex; gap: .45rem; align-items: flex-end; }
#text-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: .6rem .8rem;
  font-size: .95rem; resize: none;
  font-family: var(--font); line-height: 1.4;
}
#text-input::placeholder { color: var(--text-muted); }
#text-input:focus { outline: none; border-color: var(--accent2); }

.icon-btn {
  font-size: 1.5rem; cursor: pointer;
  padding: .15rem .3rem; user-select: none;
  display: flex; align-items: center;
  border-radius: 8px; transition: background .15s;
}
.icon-btn:hover { background: var(--surface2); }

.send-btn {
  background: #1a6abf; color: #fff;
  border: none; border-radius: 10px;
  padding: .55rem 1rem; font-size: .95rem;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.send-btn:disabled { opacity: .5; }

#preview-wrap { display: flex; gap: .5rem; align-items: center; }
#preview-img { height: 68px; border-radius: 6px; object-fit: cover; }
.remove-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 6px;
  padding: .22rem .55rem; cursor: pointer; font-size: .85rem;
}
.remove-btn:hover { border-color: var(--accent); color: var(--text); }

.chat-bubble.mine.kind-bericht {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.kind-badge { font-size: .7rem; opacity: .8; }

.chat-bubble.hint-msg-bubble {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: .85rem;
  align-self: flex-end;
  padding: .4rem .8rem;
}

.hint-btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  padding: .45rem .9rem; font-size: .88rem;
  cursor: pointer; align-self: flex-start;
}
.hint-btn:hover { border-color: var(--accent2); }
.hint-msg { color: var(--accent2); font-size: .88rem; padding: .2rem 0; }

.past-note {
  text-align: center; color: var(--text-muted);
  padding: .75rem; font-size: .9rem;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
