/* Mohrizops - one stylesheet, no framework. Dark by default, light if the
   operating system asks for it. Built to work on a phone as well as a laptop. */

:root {
  --bg: #0f1216;
  --bg-2: #161b22;
  --bg-3: #1d2430;
  --line: #27303c;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #2f81f7;
  --green: #2ea043;
  --amber: #d29922;
  --red: #e5534b;
  --bubble-us: #1f3b2c;
  --bubble-them: #1d2430;
  --radius: 12px;
  --head: 56px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa; --bg-2: #ffffff; --bg-3: #eef1f5; --line: #d8dee6;
    --text: #1b2127; --muted: #5c6773; --bubble-us: #d8f2e0; --bubble-them: #ffffff;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.error { color: var(--red); }

/* ---------- login ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(360px, 100%); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 24px; display: grid; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: -8px 0 6px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, textarea, select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
button {
  border: 1px solid transparent; border-radius: 10px; padding: 10px 14px;
  background: var(--bg-3); cursor: pointer;
}
button:hover { filter: brightness(1.12); }
button.primary { background: var(--accent); color: #fff; }
button.ghost { background: transparent; border-color: var(--line); }
button.icon { background: transparent; padding: 6px 9px; font-size: 16px; color: var(--muted); }

/* ---------- layout ---------- */
.app { height: 100%; display: grid; grid-template-columns: 340px 1fr; }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .app.on-chat .sidebar { display: none; }
  .app:not(.on-chat) .chat { display: none; }
}

/* ---------- sidebar ---------- */
.sidebar { border-right: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }
.side-head { height: var(--head); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; letter-spacing: .2px; }
.filters { display: flex; gap: 6px; padding: 10px 10px 4px; flex-wrap: wrap; }
.chip { font-size: 12.5px; padding: 5px 10px; border-radius: 999px; background: transparent; border: 1px solid var(--line); color: var(--muted); }
.chip.on { background: var(--bg-3); color: var(--text); border-color: var(--accent); }
.chip .count { display: inline-block; min-width: 16px; margin-left: 4px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 11px; }
.chip .count:empty, .chip .count.zero { display: none; }
.search { padding: 8px 10px; }
.chats { overflow-y: auto; flex: 1; min-height: 0; }

.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover { background: var(--bg-3); }
.row.active { background: var(--bg-3); box-shadow: inset 3px 0 0 var(--accent); }
.row .top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .snippet { grid-column: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .when { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.row .marks { grid-column: 2; display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.tag { font-size: 10.5px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.tag.wait { background: #3a2a12; border-color: #5c4216; color: #f0c674; }
.tag.alert { background: #3b1f1f; border-color: #6b2b2b; color: #ff9d9d; }
.tag.off { background: #2a2f3a; }
.tag.lines { background: transparent; }
@media (prefers-color-scheme: light) {
  .tag.wait { background: #fff4d6; border-color: #e8cd8a; color: #7a5500; }
  .tag.alert { background: #ffe3e3; border-color: #f3bcbc; color: #96251f; }
}

.side-foot { border-top: 1px solid var(--line); padding: 7px 12px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot.off { background: var(--muted); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.empty { flex: 1; display: grid; place-items: center; color: var(--muted); }
.chat-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { height: var(--head); display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.chat-head .who { min-width: 0; flex: 1; }
.chat-head .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { display: none; }
@media (max-width: 820px) { .back { display: block; } }

.pill { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; background: var(--bg-3); }
.pill.on { background: #15331f; border-color: #2c6b3f; color: #8ce0a4; }
.pill.off { background: #3a2222; border-color: #6d3030; color: #ffb3b3; }
@media (prefers-color-scheme: light) {
  .pill.on { background: #dff5e4; border-color: #9bd3ab; color: #17512c; }
  .pill.off { background: #ffe5e5; border-color: #eeb4b4; color: #8c2020; }
}

.card-strip { display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.card-strip:empty { display: none; }
.mini { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 12.5px; white-space: nowrap; background: var(--bg); }
.mini b { font-weight: 600; }
.mini.warn { border-color: #6b4a16; }
.mini.bad { border-color: #6b2b2b; }

.messages { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.day { align-self: center; font-size: 11.5px; color: var(--muted); background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; margin: 6px 0; }
.bubble { max-width: min(680px, 80%); padding: 8px 11px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; border: 1px solid var(--line); }
.bubble.them { align-self: flex-start; background: var(--bubble-them); border-bottom-left-radius: 4px; }
.bubble.us { align-self: flex-end; background: var(--bubble-us); border-bottom-right-radius: 4px; }
.bubble .meta { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); text-align: right; }

.hint-bar { padding: 8px 12px; border-top: 1px solid var(--line); background: #2a2413; font-size: 13px; }
@media (prefers-color-scheme: light) { .hint-bar { background: #fff8e1; } }

.composer { border-top: 1px solid var(--line); padding: 10px 12px; background: var(--bg-2); display: grid; gap: 8px; }
.composer textarea { resize: none; max-height: 160px; }
.composer-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- drawer ---------- */
.drawer { position: fixed; inset: 0 0 0 auto; width: min(560px, 100%); background: var(--bg-2); border-left: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20; }
.drawer-head { height: var(--head); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.drawer-head > div { display: flex; gap: 6px; align-items: center; }
.drawer-body { overflow-y: auto; padding: 14px; display: grid; gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--bg); }
.panel h4 { margin: 0 0 8px; font-size: 14px; }
.perms { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; }
.perms label { display: flex; gap: 7px; align-items: flex-start; }
.perms input { width: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); color: var(--text); width: min(460px, 92vw); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h3 { margin: 0 0 6px; }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 12px 0 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--bg-3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 50; }
[hidden] { display: none !important; }
