/* Chat Watch mobile — same palette as the desktop app's dark theme (static/css/style.css). */

:root {
  --bg: #202020;
  --panel: #2b2b2b;
  --line: #3a3a3a;
  --text: #ffffff;
  --muted: #c0c0c0;
  --accent: #9147ff;
  --accent-soft: rgba(145, 71, 255, .16);
  --live: #22ff8f;
  --warn: #ffb338;
  --danger: #f87171;
  --stripe-b: #000000;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The page itself never scrolls: #app is pinned to the *visual* viewport by app.js,
   which is what keeps the message box above the iOS keyboard. */
html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body { position: fixed; inset: 0; }

#app {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;   /* height/transform set from visualViewport */
  background: var(--bg);
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; line-height: 1.45; }
.grow { flex: 1; min-width: 0; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.screen.center { align-items: center; justify-content: center; text-align: center; padding: 24px calc(24px + var(--safe-right)) 24px calc(24px + var(--safe-left)); gap: 6px; }

/* ── Buttons ── */
.btn {
  font: inherit; font-size: 15px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
  transition: border-color .1s, color .1s;
}
.btn:active { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:active { filter: brightness(1.12); }

/* ── Login / boot ── */
.big-logo { width: 96px; height: 96px; margin-bottom: 8px; }
.login-title { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: .2px; }
.login-sub { margin: 0 0 18px; }
.login-note { max-width: 320px; margin: 18px 0 0; }
.error-box {
  max-width: 340px; margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(220, 38, 38, .15);
  border: 1px solid rgba(220, 38, 38, .45);
  color: var(--danger);
  font-size: 13.5px; line-height: 1.4;
  text-align: left;
}
#boot-retry { margin-top: 12px; }

/* ── Header ── */
#top, #settings-top {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  min-height: calc(46px + var(--safe-top));
  padding: var(--safe-top) calc(8px + var(--safe-right)) 0 calc(12px + var(--safe-left));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#top h1, #settings-top h1 {
  margin: 0 auto 0 0;
  font-size: 15px; font-weight: 500; letter-spacing: 0;
  color: var(--muted);
}
#settings-top { padding-left: calc(4px + var(--safe-left)); }
#settings-top h1 { color: var(--text); }
.hdr-logo { width: 22px; height: 22px; flex: none; }
#auth-user { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; color: var(--muted); }
#auth-username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }
.hdr-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: none;
  background: none; border: none; border-radius: 8px;
  color: var(--muted); cursor: pointer; padding: 0;
}
.hdr-btn:active { background: var(--accent-soft); color: var(--text); }

.irc-dot { width: 9px; height: 9px; border-radius: 50%; background: #777; flex: none; }
.irc-dot.ready { background: var(--live); box-shadow: 0 0 6px rgba(34, 255, 143, .55); }
.irc-dot.connecting { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.irc-dot.closed { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

/* ── Channel tabs (scroll or swipe sideways) ── */
#tabs {
  flex: none;
  display: flex; gap: 2px;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 var(--safe-right) 0 var(--safe-left);
  scroll-snap-type: x proximity;
}
#tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  position: relative;
  display: flex; align-items: center; gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  font: inherit; font-size: 14px;
  color: var(--muted);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  scroll-snap-align: center;
}
.tab.active { color: var(--text); background: var(--accent-soft); border-bottom-color: var(--accent); }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: none; }
.tab.unread .dot { display: block; }
.tab.unread { color: var(--text); }
.tab.add { color: var(--accent); font-size: 20px; padding: 0 16px; }

/* ── Chat panes ── */
#panes { flex: 1; min-height: 0; position: relative; }
.pane {
  position: absolute; inset: 0;
  display: none;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 4px 0 6px;
}
.pane.active { display: block; }
.pane.empty-hint::before {
  content: "Waiting for messages…";
  display: block; padding: 18px 16px; color: var(--muted); text-align: center; font-size: 13px;
}
#empty { position: absolute; inset: 0; }

.msg {
  display: block;
  margin: 3px 0;
  padding: 3px calc(12px + var(--safe-right)) 3px calc(10px + var(--safe-left));
  border-left: 3px solid var(--uc, #888);
  line-height: 1.38;
  font-size: 15px;
  overflow-wrap: anywhere;
  word-break: normal;
}
.msg .user { color: var(--uc, #ddd); font-weight: 600; margin-right: 5px; }
.msg .body { color: var(--text); }
.msg.action .body { color: var(--uc, var(--text)); font-style: italic; }
.msg.own { background: rgba(255, 255, 255, 0.035); }
.msg a { color: #a98bff; text-decoration: underline; text-underline-offset: 2px; }

.role-badge {
  font-size: 10px; font-weight: 700;
  padding: 0 4px; border-radius: 3px;
  display: inline-block; vertical-align: middle;
  margin-right: 5px; line-height: 15px;
  color: #fff;
}
.role-badge.mod { background: #16a34a; }
.role-badge.vip { background: #be185d; }
.role-badge.sub { background: #2563eb; }
.role-badge.bits { background: #0891b2; }
.role-badge.first { background: #d97706; }
.chat-badge {
  width: 18px; height: 18px;
  display: inline-block; vertical-align: middle;
  margin: -2px 5px 0 0; border-radius: 2px;
}

.sys {
  padding: 4px 12px; margin: 2px 0;
  color: var(--muted); font-size: 12.5px; font-style: italic; text-align: center;
}
.sys.warn { color: var(--warn); }

#jump {
  position: absolute; right: 12px; bottom: 10px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
  font-size: 20px; line-height: 1;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .5);
  cursor: pointer;
}

/* ── Compose: pinned to the bottom of the (visual) viewport ── */
#compose {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 8px calc(10px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(10px + var(--safe-left));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
body.kb-open #compose { padding-bottom: 8px; }      /* the keyboard already covers the home-indicator area */
#compose-input {
  flex: 1; min-width: 0;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;                                   /* 16px+ stops iOS zooming the page on focus */
  outline: none;
  appearance: none; -webkit-appearance: none;
}
#compose-input::placeholder { color: var(--muted); opacity: .8; }
#compose-input:focus { border-color: var(--accent); }
#compose-input:disabled { opacity: .55; }
#char-counter { font-size: 11px; color: var(--muted); flex: none; }
#char-counter.over { color: var(--danger); }
#send-btn {
  flex: none;
  height: 40px; padding: 0 12px;
  background: transparent; border: none;
  color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
  cursor: pointer;
}
#send-btn:disabled { opacity: .35; cursor: default; }

/* ── Settings ── */
#settings { z-index: 20; }
#settings-body {
  flex: 1; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 6px calc(14px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(14px + var(--safe-left));
}
#settings h2 {
  margin: 20px 0 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted);
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px;
}
.card.row { display: flex; align-items: center; gap: 12px; }
.add-row { display: flex; gap: 8px; }
#add-input {
  flex: 1; min-width: 0; height: 44px;
  padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
  font-family: inherit; font-size: 16px; outline: none;
}
#add-input:focus { border-color: var(--accent); }
#add-input::placeholder { color: var(--muted); opacity: .8; }
#add-msg { margin: 8px 2px 0; }
#add-msg.err { color: var(--danger); }
#channel-list { margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.channel-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 4px 0 14px; min-height: 44px;
}
.channel-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-delete {
  width: 44px; height: 44px; flex: none;
  background: none; border: none; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; border-radius: 8px;
}
.channel-delete:active { color: var(--danger); background: rgba(220, 38, 38, .12); }

/* ── Toast ── */
#toast {
  position: fixed; left: 50%; top: calc(56px + var(--safe-top));
  transform: translate(-50%, -12px);
  max-width: min(88vw, 420px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #3a3a3a; color: var(--text);
  border: 1px solid #4a4a4a;
  font-size: 13.5px; line-height: 1.35; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 100;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.noscript { padding: 24px; text-align: center; color: var(--muted); }
