:root {
  --brand: #1e4a52;
  --brand-ink: #f3f1ec;
  --bg: #f3f1ec;
  --panel: #ffffff;
  --text: #0c1d23;
  --muted: #55646a;
  --line: #d9d6cf;
  --mine: #1e4a52;
  --mine-text: #f6f4ef;
  --theirs: #ffffff;
  --accent: #b35c00;
  --focus: #b35c00;
  --danger: #a01818;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1110;
    --panel: #121b1d;
    --text: #f3f1ec;
    --muted: #a3b0b3;
    --line: #26343a;
    --mine: #2b6773;
    --mine-text: #f6f4ef;
    --theirs: #18252a;
    --accent: #ffb347;
    --focus: #ffb347;
    --danger: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, textarea, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

/* ---------- rozvržení ---------- */
.app { display: flex; flex-direction: column; height: 100dvh; max-width: 860px; margin: 0 auto; }

.top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .02em; }
.brand img { border-radius: 7px; }
.room { flex: 1; min-width: 0; }
.room h1 { margin: 0; font-size: 1rem; line-height: 1.2; }
.room p { margin: 0; font-size: .8rem; color: #cfdcdc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghost { background: transparent; border: 1px solid rgba(255,255,255,.35); color: inherit; border-radius: 8px; padding: 6px 10px; font-size: .85rem; cursor: pointer; min-height: 36px; }

/* ---------- zprávy ---------- */
.list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.day { align-self: center; font-size: .78rem; color: var(--muted); padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; margin: 6px 0; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 32ch; }

.msg { max-width: min(85%, 560px); align-self: flex-start; display: flex; flex-direction: column; gap: 2px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.meta { font-size: .75rem; color: var(--muted); padding: 0 4px; }
.bubble {
  background: var(--theirs); border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px; padding: 8px 12px;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.mine .bubble { background: var(--mine); color: var(--mine-text); border-color: transparent; border-radius: 16px 16px 4px 16px; }
.bubble a { color: inherit; text-decoration: underline; }
.orig { margin-top: 6px; padding-top: 6px; border-top: 1px dashed currentColor; opacity: .85; font-size: .92rem; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; padding: 0 4px; }
.link { background: none; border: 0; padding: 4px 0; font-size: .78rem; color: var(--muted); text-decoration: underline; cursor: pointer; min-height: 24px; }
.status { font-size: .78rem; color: var(--muted); }
.status.bad { color: var(--danger); }

.file {
  display: flex; align-items: center; gap: 10px; margin-top: 4px;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); text-decoration: none; max-width: 100%;
}
.mine .file { border-color: rgba(255,255,255,.25); }
.file svg { width: 28px; height: 28px; flex: none; color: var(--accent); }
.file .fn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .fs { font-size: .78rem; color: var(--muted); }
.thumb { display: block; margin-top: 4px; max-width: 100%; max-height: 320px; border-radius: 10px; }

/* ---------- psaní ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.field { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
textarea {
  width: 100%; resize: none; max-height: 40vh; min-height: 44px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); line-height: 1.4;
}
.icon {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--muted);
}
.icon svg { width: 24px; height: 24px; }
.send { background: var(--brand); color: var(--brand-ink); }
.send:disabled { opacity: .5; cursor: default; }
.pending-file { display: flex; align-items: center; gap: 8px; font-size: .85rem; padding: 6px 10px; border: 1px dashed var(--line); border-radius: 10px; }
.pending-file span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- přihlášení ---------- */
.gate { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px 16px; text-align: center; }
.gate img { border-radius: 14px; }
.gate h1 { margin: 6px 0 4px; font-size: 1.4rem; }
.gate p { margin: 0; max-width: 40ch; }
.primary { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 12px; padding: 12px 20px; font-weight: 700; cursor: pointer; min-height: 48px; }
.primary:disabled { opacity: .6; }
