/* Colour themes. Monokai is the default dark theme; light is the alternative. */
:root {
  /* Monokai */
  --bg: #272822;
  --fg: #f8f8f2;
  --muted: #908e7e;
  --accent: #66d9ef;
  --accent-fg: #272822;
  --field: #3e3d32;
  --line: #49483e;
  --danger: #f92672;
  --highlight: #a6e22e;
  --bubble-out: #3e3d32;
  --bubble-out-fg: #f8f8f2;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fafaf6;
  --fg: #272822;
  --muted: #6f6d5f;
  --accent: #1d7a94;
  --accent-fg: #ffffff;
  --field: #ecebe2;
  --line: #d7d5c7;
  --danger: #c2185b;
  --highlight: #4f7d12;
  --bubble-out: #d4ecf3;
  --bubble-out-fg: #272822;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 system-ui, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  height: 100%;
}

.login {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 360px;
  margin: 0 auto;
  padding: 16px;
  padding-top: 20vh;
}

.login h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px;
}

.login input {
  font: inherit;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--field);
  color: var(--fg);
}

.login button {
  font: inherit;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
}

/* Chat list and conversation */
.chats { list-style: none; padding: 0; margin: 0; }
.chats li { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.chats li:active { background: var(--field); }
.chats li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chats .avatar { flex: 0 0 40px; height: 40px; border-radius: 50%; background: var(--field); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; }
.chats .chat-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chats .badge { flex: 0 0 auto; background: var(--accent); color: var(--accent-fg); border-radius: 10px; padding: 1px 8px; font-size: 13px; }
.chats .favorite { flex: 0 0 auto; min-width: 44px; min-height: 44px; font: inherit; font-size: 20px; line-height: 1; border: 0; border-radius: 22px; background: none; color: var(--muted); cursor: pointer; }
.chats .favorite[aria-pressed="true"] { color: var(--highlight); }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 16px 16px 4px; }
.chats-title, .header h1 { font-size: 18px; margin: 12px 16px; }
.header { display: flex; align-items: center; border-bottom: 1px solid var(--line); padding: 8px 12px; gap: 8px; }
.header h1 { margin: 0; }
.back { font: inherit; background: none; border: 0; color: var(--accent); padding: 8px; cursor: pointer; }
.messages { list-style: none; margin: 0; padding: 12px 16px; overflow-y: auto; flex: 1; }
.msg { max-width: 80%; margin: 6px 0; padding: 8px 12px; border-radius: 14px; background: var(--field); }
.msg.out { margin-left: auto; background: var(--accent); color: var(--accent-fg); }
.msg.service { margin: 6px auto; color: var(--muted); background: none; text-align: center; font-size: 13px; }
.msg .from { font-size: 13px; color: var(--accent); margin-bottom: 2px; }
.msg .time { font-size: 11px; opacity: 0.7; margin-top: 2px; text-align: right; }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.composer { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.composer input { flex: 1; font: inherit; padding: 10px 12px; border: 0; border-radius: 18px; background: var(--field); color: var(--fg); }
.composer .send { font: inherit; padding: 10px 16px; border: 0; border-radius: 18px; background: var(--accent); color: var(--accent-fg); }

/* Conversation fills the screen: fixed header, scrolling messages, fixed reply box */
.chat-view { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.chat-view .header { flex: 0 0 auto; }
.chat-view .messages { flex: 1 1 auto; min-height: 0; }
.chat-view .composer { flex: 0 0 auto; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.chat-view > .status { flex: 0 0 auto; margin: 0; padding: 0 16px; }

/* Media in messages */
.msg .media { margin-bottom: 4px; }
.msg .photo { display: block; max-width: 100%; max-height: 60vh; border-radius: 10px; }
.msg .file { color: inherit; text-decoration: underline; }
.msg .file-size, .msg .media-status { font-size: 12px; opacity: 0.75; }
.msg .media-button { font: inherit; font-size: 14px; padding: 8px 10px; border: 0; border-radius: 10px; background: rgba(127,127,127,0.2); color: inherit; }
.composer .attach { font: inherit; padding: 10px 12px; border: 0; border-radius: 18px; background: var(--field); color: var(--accent); }

/* Replies */
.msg { cursor: pointer; }
.msg .quote { font-size: 13px; border-left: 3px solid var(--highlight); padding: 2px 8px; margin-bottom: 4px; opacity: 0.85; white-space: pre-wrap; word-break: break-word; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.reply-bar[hidden] { display: none; }
.reply-bar .reply-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); }
.reply-bar .reply-cancel { font: inherit; border: 0; background: none; color: var(--muted); padding: 4px 8px; cursor: pointer; }

/* Theme toggle, fixed in the top-right corner. Headers leave room for it. */
.theme-toggle { position: fixed; top: calc(env(safe-area-inset-top) + 8px); right: 8px; z-index: 10; font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--field); color: var(--fg); cursor: pointer; }
.header, .chats-title { padding-right: 64px; }
.chats-title { margin-right: 0; }
.notify-enable { display: block; margin: 0 16px 8px; font: inherit; font-size: 14px; padding: 8px 12px; border: 0; border-radius: 10px; background: var(--field); color: var(--accent); }
