/* ============================================================
   Slake default look.
   Want to restyle it? Don't edit this file — copy a theme from
   your themes folder (the "Edit" button in the app) and change
   the variables below. Saving the file repaints the app live.
   ============================================================ */
:root {
  --bg: #16161d;          /* message area */
  --panel: #1e1e28;       /* sidebar */
  --panel-2: #262634;     /* inputs, hover */
  --text: #ece9f2;
  --muted: #8d8aa0;
  --accent: #5b9dff;      /* buttons, active channel */
  --accent-text: #06142b;
  --line: #30303f;
  --danger: #ff6b81;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --wordmark: Georgia, "Iowan Old Style", serif;
  --msg-size: 15px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--msg-size)/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

button, input, textarea, select {
  font: inherit; color: inherit;
}
button {
  background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: var(--radius);
  padding: 9px 16px; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.secondary { background: var(--panel-2); color: var(--text); }
button.ghost { background: transparent; color: var(--muted); padding: 6px 10px; }
button.full { width: 100%; }
input, textarea, select {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

.wordmark {
  font-family: var(--wordmark); font-style: italic; font-weight: 700;
  letter-spacing: -0.02em; color: var(--accent);
}

/* ---------- Welcome ---------- */
.screen { height: 100vh; }
#welcome { display: grid; place-items: center; padding: 24px; }
.card { width: min(420px, 100%); }
.card h1 { font-size: 64px; margin: 0; line-height: 1; }
.card .sub { color: var(--muted); margin: 10px 0 32px; }
.card form { display: grid; gap: 8px; margin-bottom: 12px; }
.card label { font-size: 13px; color: var(--muted); }
.card .ghost.full { margin-top: 4px; font-size: 13px; }
.login-wait { display: grid; justify-items: center; gap: 12px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }
.login-wait b { color: var(--text); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pw-head { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.or { text-align: center; color: var(--muted); margin: 14px 0; font-size: 13px; }
.error { color: var(--danger); min-height: 1.4em; font-size: 14px; }

/* ---------- Chat layout ---------- */
#chat { display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.brand { padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.wordmark.small { font-size: 20px; }
.me-line { font-size: 13px; color: var(--muted); margin-top: 6px; }
.me-line b { color: var(--text); }

nav { flex: 1; overflow-y: auto; padding: 10px 8px 14px; }
.space { margin-top: 12px; }
.space-name {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  padding: 0 8px 6px; display: flex; gap: 6px; align-items: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.space-name .badge { letter-spacing: 0; text-transform: none; }
.space ul { list-style: none; margin: 0; padding: 0; }
.space li {
  padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.space li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space li:hover { background: var(--panel-2); color: var(--text); }
.space li.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.space li.unread { color: var(--text); font-weight: 700; }
.space li.gone { text-decoration: line-through; opacity: 0.6; }
.space li .dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.space li .live { flex: none; width: 6px; height: 6px; border-radius: 50%; background: #5ad48a; }
.space li.active .live { background: var(--accent-text); }
.new-room { padding: 4px 2px 0; }
.new-room input, .join input { width: 100%; font-size: 14px; }
.new-room input { background: transparent; border-color: transparent; padding: 5px 8px; }
.new-room input:focus { background: var(--panel-2); border-color: var(--line); }

.foot { padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.join input { padding: 8px 10px; font-size: 13px; }
.theme-row { display: flex; gap: 6px; }
.theme-row select { flex: 1; padding: 6px 8px; font-size: 13px; }
button.confirm { color: var(--danger) !important; }

/* ---------- Room ---------- */
.room { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.room-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.no-room { margin: auto; max-width: 420px; text-align: center; color: var(--muted); padding: 24px; }
.no-room h2 { color: var(--text); font-family: var(--wordmark); font-style: italic; font-size: 28px; margin: 0 0 10px; }
.no-room b { color: var(--text); }

.room-head {
  padding: 12px 18px 12px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.room-title { min-width: 0; font-weight: 700; font-size: 17px; }
.room-title > div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-sub { font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.room-actions { display: flex; gap: 6px; flex: none; }
.room-actions button { padding: 7px 12px; font-size: 13px; }
.hash { color: var(--muted); margin-right: 3px; }

.banner {
  background: var(--panel-2); color: var(--text); padding: 10px 22px; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--line);
}

.room-body { flex: 1; display: flex; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 22px; min-width: 0; }
.empty { color: var(--muted); text-align: center; margin-top: 14vh; }

.members {
  width: 250px; flex: none; border-left: 1px solid var(--line); background: var(--panel);
  padding: 14px; overflow-y: auto;
}
.members-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 10px; }
.members-head button { padding: 2px 8px; }
#memberList { list-style: none; margin: 0; padding: 0; }
#memberList li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; }
#memberList li .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#memberList li .tag { font-size: 11px; color: var(--muted); }
#memberList li button { padding: 3px 8px; font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin-top: 14px; }

.msg { display: grid; grid-template-columns: 38px 1fr; gap: 0 10px; margin-top: 14px; }
.msg.cont { margin-top: 2px; }
.msg.cont .avatar, .msg.cont .meta { display: none; }
.msg.cont .body { grid-column: 2; }
.avatar {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px; grid-row: span 2;
}
.meta { display: flex; align-items: baseline; gap: 8px; }
.name { font-weight: 700; }
.badge { font-size: 12px; letter-spacing: 1px; }
.time { font-size: 12px; color: var(--muted); }
.body { white-space: pre-wrap; overflow-wrap: anywhere; }
.body a { color: var(--accent); }
.note { color: var(--muted); font-size: 13px; margin: 10px 0 0 48px; }
.day {
  text-align: center; font-size: 12px; color: var(--muted);
  margin: 22px 0 6px; text-transform: uppercase; letter-spacing: 0.06em;
}

.composer { display: flex; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; max-height: 180px; line-height: 1.4; }
.composer.disabled { opacity: 0.4; pointer-events: none; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 16px;
  border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 10;
}

/* ---------- Files ---------- */
.attach { font-size: 22px; line-height: 1; padding: 6px 12px; color: var(--muted); }
.attach:hover { color: var(--text); }

.pending {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 22px; border-top: 1px solid var(--line); background: var(--panel);
}
.pending-file { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
.file-icon { font-size: 18px; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font-size: 13px; white-space: nowrap; }
.ttl { display: flex; align-items: center; gap: 4px; }
.ttl-label { color: var(--muted); font-size: 13px; margin-right: 4px; }
.ttl button { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 5px 10px; font-size: 13px; font-weight: 500; }
.ttl button.on { background: var(--panel-2); color: var(--text); border-color: var(--accent); }

.file {
  display: inline-grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: center;
  margin-top: 4px; padding: 10px 12px; max-width: 480px; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.file .file-icon { grid-row: span 2; font-size: 24px; }
.file .file-name { grid-column: 2; }
.file .file-sub { grid-column: 2; font-size: 12px; color: var(--muted); }
.file .file-act { grid-column: 3; grid-row: 1 / span 2; }
.file .file-act button { padding: 6px 12px; font-size: 13px; }
.file .bar { grid-column: 2; height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.file .bar span { display: block; height: 100%; background: var(--accent); }
.file.gone { background: transparent; border-style: dashed; opacity: 0.75; }
.file.gone .file-name { font-weight: 500; }

.drop {
  position: absolute; inset: 12px; display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  font-size: 18px; font-weight: 600; color: var(--text); pointer-events: none; z-index: 5;
}
.room-body { position: relative; }

/* ---------- Search ---------- */
.search { display: flex; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.search input { flex: 1; }
.result { padding: 10px 12px; border-radius: var(--radius); cursor: pointer; }
.result:hover { background: var(--panel-2); }
.result-where { font-size: 12px; color: var(--muted); }
.result-text { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.result mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 2px; }
.msg.flash { animation: flash 1.6s ease-out; border-radius: var(--radius); }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 28%, transparent); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .msg.flash { animation: none; outline: 2px solid var(--accent); } }

/* ---------- Update note ---------- */
.update {
  margin: 0 12px 10px; text-align: left; font-size: 13px; font-weight: 500;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--accent);
}
.update b { color: var(--accent); }

/* ---------- Avatars ---------- */
.avatar { overflow: hidden; color: #fff; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.emoji { background: var(--panel-2); font-size: 22px; }
.avatar.sm { width: 22px; height: 22px; border-radius: 6px; font-size: 13px; grid-row: auto; flex: none; }
.avatar.emoji.sm { font-size: 14px; }

.me-line {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 4px 6px 4px 4px;
  background: transparent; color: var(--muted); font-weight: 400; border-radius: var(--radius); width: 100%; text-align: left;
}
.me-line:hover { background: var(--panel-2); filter: none; }

.picker {
  margin: 8px 12px 0; padding: 12px; display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.picker-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.picker-head button { padding: 2px 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; }
.emoji-grid button { background: transparent; padding: 4px 0; font-size: 19px; min-width: 0; }
.emoji-grid button:hover { background: var(--panel); filter: none; }
.emoji-form { display: flex; gap: 6px; }
.emoji-form input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 14px; }
.emoji-form button { padding: 6px 10px; font-size: 13px; }
.picker .hint { margin: 0; }

/* ---------- Codes ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; z-index: 20; }
.dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px);
  padding: 24px 28px; width: min(380px, calc(100vw - 32px)); text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.dialog-title { color: var(--muted); font-size: 14px; }
.code { font-family: var(--mono); font-size: 44px; font-weight: 700; letter-spacing: 0.18em; margin: 10px 0 6px; color: var(--accent); user-select: all; }
.dialog-note { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0 0 18px; }
.dialog-actions { display: flex; gap: 8px; justify-content: center; }

/* ---------- Name clash ---------- */
.clash { margin: 8px 12px 0; padding: 12px; border: 1px solid var(--danger); border-radius: var(--radius); background: var(--panel-2); display: grid; gap: 8px; }
.clash p { margin: 0; font-size: 13px; line-height: 1.4; }
.clash-mark { font-size: 12px; cursor: help; }

/* ---------- Online ---------- */
.avatar { position: relative; overflow: visible; }
.avatar > img, .avatar { border-radius: 10px; }
.avatar > img { border-radius: inherit; }
.avatar .on {
  position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%;
  background: #3fcf7f; box-shadow: 0 0 0 2px var(--bg);
}
.avatar.sm .on { width: 8px; height: 8px; right: -2px; bottom: -2px; box-shadow: 0 0 0 2px var(--panel); }
.space li .person { display: flex; align-items: center; gap: 8px; min-width: 0; }
.space li .person span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space .hint-line { color: var(--muted); font-size: 12px; padding: 2px 10px 0; line-height: 1.4; }
#memberList li.online .who { color: var(--text); }

/* ---------- Version ---------- */
.version { font-size: 11px; color: var(--muted); opacity: 0.7; padding: 0 2px; }

/* ---------- Wallpaper ---------- */
.wall, .wall-dim { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.wall { background-size: cover; background-position: center; }
.wall-dim { background: var(--bg); }
.screen { position: relative; z-index: 1; }

/* ---------- Phones ---------- */
/* Narrow screens show your rooms, or one room full screen with a back arrow. */
.back { display: none; }
@media (max-width: 640px) {
  .screen { height: 100dvh; }
  #chat { grid-template-columns: 1fr; }
  #chat .room { display: none; }
  body.in-room #chat .sidebar { display: none; }
  body.in-room #chat .room { display: flex; }
  .sidebar { border-right: 0; padding-top: env(safe-area-inset-top); }
  .brand { padding-top: 14px; }
  .space li { padding: 10px 12px; font-size: 17px; }
  .back { display: inline-flex; align-items: center; justify-content: center; font-size: 34px; line-height: 1; padding: 0 12px 4px 0; margin-right: 2px; color: var(--accent); }
  .room-head { padding: calc(10px + env(safe-area-inset-top)) 14px 10px 10px; justify-content: flex-start; }
  .room-title { flex: 1; }
  .messages { padding: 10px 14px; }
  .composer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .composer textarea, input, select { font-size: 16px; }   /* stops iPhone zooming in */
  .members { position: fixed; inset: 0; width: auto; z-index: 30; border-left: 0; padding-top: calc(14px + env(safe-area-inset-top)); }
  .file { max-width: 100%; }
  .foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .no-room { padding: 32px 20px; }
  .card { padding: 0 6px; }
  .card h1 { font-size: 56px; }
}
