/* Fragment Chat - Discord-ish dark theme */
:root {
  --bg-0: #1e1f22;        /* outermost */
  --bg-1: #2b2d31;        /* sidebar */
  --bg-2: #313338;        /* main chat */
  --bg-3: #383a40;        /* hover / inputs */
  --bg-4: #404249;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --text-0: #f2f3f5;
  --text-1: #dbdee1;
  --text-2: #b5bac1;
  --text-muted: #949ba4;
  --green: #23a55a;
  --red: #f23f42;
  --divider: #1f2023;
  --radius: 10px;
  --mono: ui-monospace, "JetBrains Mono", "Fira Code", monospace;
  --sans: "gg sans", -apple-system, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg-0);
  color: var(--text-0);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
button {
  font: inherit; cursor: pointer; border: 0; border-radius: 6px;
  background: var(--accent); color: white; padding: 10px 16px;
  min-height: 44px; transition: background .12s;
}
button:hover { background: var(--accent-hover); }
input, textarea {
  font: inherit; background: var(--bg-3); color: var(--text-0);
  border: 1px solid transparent; border-radius: 6px;
  padding: 12px 14px; min-height: 44px; outline: none;
  transition: border-color .12s, background .12s;
}
input:focus { border-color: var(--accent); }

/* ─────────────────────────  LANDING  ───────────────────────── */
.landing {
  display: flex; flex-direction: column; align-items: stretch;
  min-height: 100%; background: linear-gradient(180deg, #1e1f22 0%, #131418 100%);
}
.landing-hero {
  text-align: center; padding: 72px 24px 32px;
  border-bottom: 1px solid var(--divider);
}
.landing-hero h1 {
  font-size: 56px; margin: 0 0 12px;
  letter-spacing: -1px; font-weight: 800;
}
.landing-hero h1 span { color: var(--accent); }
.landing-hero p { max-width: 620px; margin: 8px auto; }
.landing-main {
  flex: 1; padding: 48px 24px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px; max-width: 1100px; margin: 0 auto; width: 100%;
}
.card {
  background: var(--bg-1); border-radius: var(--radius);
  padding: 24px; border: 1px solid var(--divider);
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.example {
  display: block; padding: 12px; background: var(--bg-0);
  border-radius: 6px; font-family: var(--mono); font-size: 13px;
  margin: 12px 0; word-break: break-all;
}
.example b { color: var(--accent); font-weight: 600; }
#join-form { display: grid; gap: 10px; grid-template-columns: 1fr 1fr auto; }
#join-form input { width: 100%; }
@media (max-width: 560px) { #join-form { grid-template-columns: 1fr; } }
.rooms-list { list-style: none; padding: 0; margin: 0; }
.room-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px; border-radius: 6px;
}
.room-row:hover { background: var(--bg-3); }
.room-name { font-weight: 600; }
.btn { padding: 10px 18px; border-radius: 6px; background: var(--accent);
       color: white !important; min-height: 44px; display: inline-flex;
       align-items: center; }
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.landing-footer {
  display: flex; justify-content: center; gap: 8px; padding: 24px;
  color: var(--text-muted); font-size: 13px;
}

/* ─────────────────────────  APP / ROOM  ───────────────────────── */
.app {
  display: grid; grid-template-columns: 280px 1fr; height: 100vh;
  background: var(--bg-0);
}
@media (max-width: 720px) {
  .app { grid-template-columns: 64px 1fr; }
  .server-meta, .channels, .storage-card { display: none; }
}

.sidebar {
  background: var(--bg-1);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--divider);
  min-width: 0;
}
.server-pill {
  margin: 12px; padding: 12px;
  background: var(--accent); color: white;
  border-radius: var(--radius);
  font-weight: 800; text-align: center; font-size: 18px;
}
.server-meta {
  padding: 12px 16px; border-bottom: 1px solid var(--divider);
}
.server-name { font-weight: 700; font-size: 16px; }
.channels {
  flex: 1; overflow-y: auto; padding: 12px 8px;
}
.channel-section {
  text-transform: uppercase; font-size: 11px; color: var(--text-muted);
  padding: 8px 8px 4px; letter-spacing: 0.5px;
}
.channel {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 8px; border-radius: 6px;
  color: var(--text-2); cursor: pointer;
  min-height: 44px;
}
.channel:hover { background: var(--bg-3); color: var(--text-0); }
.channel.active { background: var(--bg-4); color: var(--text-0); }
.channel .hash { color: var(--text-muted); font-weight: 600; }

.member-list {
  list-style: none; padding: 0; margin: 4px 0 0;
}
.member-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 6px;
  color: var(--text-2);
}
.member-list li:hover { background: var(--bg-3); color: var(--text-0); }
.member-dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 12px;
  flex-shrink: 0;
}
.member-list li .you {
  font-size: 10px; color: var(--text-muted);
  margin-left: auto; text-transform: uppercase; letter-spacing: 0.5px;
}

.sidebar-footer {
  padding: 12px; border-top: 1px solid var(--divider);
  display: grid; gap: 8px;
}
.storage-card {
  background: var(--bg-0); padding: 10px; border-radius: 8px;
}
.storage-label {
  font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.storage-bar {
  background: var(--bg-3); height: 8px; border-radius: 4px; overflow: hidden;
}
.storage-bar > div {
  background: var(--green); height: 100%; width: 0%; transition: width .3s;
}

.chat {
  display: grid; grid-template-rows: auto 1fr auto;
  min-width: 0; background: var(--bg-2);
}
.chat-header {
  display: flex; align-items: center; gap: 6px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
  font-weight: 700; font-size: 16px;
}
.chat-header .hash { color: var(--text-muted); font-weight: 700; }
.spacer { flex: 1; }

.messages {
  overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.system-msg {
  align-self: center; color: var(--text-muted); font-size: 13px;
  background: var(--bg-3); padding: 6px 12px; border-radius: 999px;
}
.msg {
  display: grid; grid-template-columns: 40px 1fr; gap: 12px;
  padding: 4px 0;
}
.msg .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-4); display: flex; align-items: center;
  justify-content: center; color: var(--text-0); font-weight: 700;
}
.msg .body { min-width: 0; }
.msg .meta {
  display: flex; gap: 8px; align-items: baseline;
}
.msg .author { font-weight: 600; color: var(--text-0); }
.msg .time   { color: var(--text-muted); font-size: 12px; }
.msg .text   { color: var(--text-1); word-wrap: break-word; }
.msg img.attachment {
  max-width: 320px; max-height: 240px;
  border-radius: 8px; margin-top: 4px; display: block;
}

.composer {
  display: flex; gap: 8px; padding: 16px 20px;
  border-top: 1px solid var(--divider);
  background: var(--bg-2);
}
.composer input {
  flex: 1; background: var(--bg-3);
  padding: 14px 16px; font-size: 15px;
}
.attach-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; min-width: 48px;
  background: var(--bg-3); color: var(--text-2);
  border-radius: 50%; cursor: pointer; font-size: 26px; font-weight: 300;
  user-select: none;
}
.attach-btn:hover { background: var(--bg-4); color: var(--text-0); }
.composer button { min-width: 96px; height: 48px; }

/* Key prompt modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); display: grid; place-items: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--bg-1); padding: 32px; border-radius: var(--radius);
  width: min(420px, 90vw); border: 1px solid var(--divider);
  display: grid; gap: 12px;
}
.modal-card h2 { margin: 0; }
