:root {
  --bg: #fafaf9;
  --fg: #1a1a1a;
  --muted: #8a8a8a;
  --border: #e6e6e3;
  --accent: #2563eb;
  --bubble: #ffffff;
  --mine: #2563eb;
  --mine-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0d;
    --fg: #f5f5f4;
    --muted: #888885;
    --border: #2a2a28;
    --accent: #60a5fa;
    --bubble: #1a1a18;
    --mine: #2563eb;
    --mine-fg: #ffffff;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* Landing */
body.landing {
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
body.landing main {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
body.landing h1 {
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -0.04em;
  margin: 0 0 8px;
}
.tagline {
  color: var(--muted);
  margin: 0 0 28px;
}
#enter {
  display: flex; gap: 8px;
}
#enter input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bubble);
  color: var(--fg);
  font: inherit;
}
.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 14px;
}

/* Buttons */
button {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }
input:focus, button:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus { border-color: transparent; }

/* Room */
body.room {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
}

header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
header h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  flex: 1;
}
header h1::before { content: '#'; color: var(--muted); margin-right: 1px; }
.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 20px;
  line-height: 1;
}
.users {
  font-size: 12px;
  color: var(--muted);
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 75%;
  padding: 6px 12px 8px;
  border-radius: 14px;
  background: var(--bubble);
  border: 1px solid var(--border);
  align-self: flex-start;
}
.msg.mine {
  background: var(--mine);
  color: var(--mine-fg);
  border-color: transparent;
  align-self: flex-end;
}
.msg.mine .meta .name, .msg.mine .meta .time { color: rgba(255,255,255,.75); }
.msg.mine a { color: #fff; text-decoration: underline; }
.meta {
  display: flex; gap: 8px;
  font-size: 11px;
  margin-bottom: 1px;
}
.name { font-weight: 600; }
.time { color: var(--muted); }
.body {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.4;
}

.system {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
  padding: 2px 0;
}

footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
#composer {
  display: flex; gap: 8px;
}
#composer input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bubble);
  color: var(--fg);
  font: inherit;
}
#composer button {
  border-radius: 999px;
  padding: 10px 18px;
}

/* Dialog */
dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--fg);
  padding: 24px;
  width: min(90vw, 320px);
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
dialog::backdrop {
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
}
#nameform { display: flex; flex-direction: column; gap: 12px; }
#nameform h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
#nameform input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bubble);
  color: var(--fg);
  font: inherit;
}
