/* Lexend: built for easy reading over long shifts. Self-hosted via /fonts. */
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/fonts/lexend-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/fonts/lexend-latin-ext-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0f1420;
  --panel: #161d2b;
  --panel-2: #1c2536;
  --line: #263044;
  --text: #e6eaf2;
  --muted: #8a95ab;
  --accent: #4f8cff;
  --accent-2: #3a6fd8;
  --mine: #2a4561;       /* muted slate blue: calm on the eyes, still clearly "ours" */
  --mine-text: #e8eef6;
  --theirs: #1f2839;
  --read: #6cc4ff;       /* "seen" ticks: bright enough to spot on --mine */
  --ok: #3fbf7f;
  --warn: #e6a23c;
  --bad: #e5534b;
  --g2g: #e5534b;
  --eldorado: #e6a23c;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 350;
  -webkit-font-smoothing: antialiased;
}
b, strong, h1, h2, h3, th { font-weight: 600; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--bad); margin: 0; }

input, select, textarea {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: grid; gap: 14px; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0; }

/* App shell */
#app-view { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; }
.tabs { display: flex; gap: 4px; }
.tabs a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.tabs a.active { color: var(--text); background: var(--panel-2); }
.spacer { flex: 1; }
.me { color: var(--muted); }
.shop-status { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.online { background: var(--ok); }
.dot.connecting { background: var(--warn); }
.dot.error { background: var(--bad); }

/* Chats */
.chats { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; }
.sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.sidebar-tools { display: grid; grid-template-columns: 1fr 150px; gap: 8px; padding: 12px 12px 6px; }
.toggle { display: flex; align-items: center; gap: 6px; padding: 0 12px 8px; }
.toggle input { width: auto; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-left: 3px solid transparent; cursor: pointer; border-bottom: 1px solid var(--line);
}
.conv:hover { background: var(--panel-2); }
.conv.active { background: var(--panel-2); border-left-color: var(--accent); }
.conv.g2g { border-left-color: color-mix(in srgb, var(--g2g) 60%, transparent); }
.conv.eldorado { border-left-color: color-mix(in srgb, var(--eldorado) 60%, transparent); }
.conv.active.g2g, .conv.active.eldorado { border-left-color: var(--accent); }
.conv-main { min-width: 0; }
.conv-top { display: flex; gap: 6px; align-items: baseline; }
.conv-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.conv-tags { display: flex; gap: 4px; margin: 2px 0; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.tag.shop.g2g { color: var(--g2g); border-color: color-mix(in srgb, var(--g2g) 40%, transparent); }
.tag.shop.eldorado { color: var(--eldorado); border-color: color-mix(in srgb, var(--eldorado) 40%, transparent); }
.conv-last { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-last b { color: var(--text); font-weight: 500; }
.wait { display: inline-flex; align-items: center; gap: 4px; }
.wait-emoji { font-size: 18px; line-height: 1; }
.badge { background: var(--bad); color: #fff; font-size: 11px; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--panel-2); object-fit: cover; display: grid; place-items: center; font-weight: 700; color: var(--muted); }

.chat { min-height: 0; display: flex; flex-direction: column; }
.chat-empty { flex: 1; display: grid; place-items: center; }
.chat-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chat-name { font-weight: 500; font-size: 16px; }
.back { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.load-more { align-self: center; margin-bottom: 8px; }
.day { align-self: center; color: var(--muted); font-size: 12px; margin: 10px 0 4px; }
.msg {
  align-self: flex-start; /* hug the text instead of stretching to max width */
  max-width: min(620px, 78%);
  padding: 8px 14px 8px;
  border-radius: 14px 14px 14px 4px;
  background: var(--theirs);
  font-size: 15.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.msg-text { white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: var(--mine); color: var(--mine-text); border-radius: 14px 14px 4px 14px; }
.msg.system { align-self: center; background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 14px; border-radius: 10px; }
/* Time sits at the end of the last line when it fits (chat-app style), otherwise drops below */
.msg-meta {
  float: right;
  margin: 7px 0 -3px 14px;
  font-size: 11.5px;
  line-height: 1.2;
  color: color-mix(in srgb, currentColor 55%, transparent);
  white-space: nowrap;
}
.msg::after { content: ""; display: block; clear: both; }
.ticks {
  width: 16px; height: 16px; margin-left: 4px; vertical-align: -4px;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.ticks.read { color: var(--read); }
/* A little extra air when the speaker changes */
.msg:not(.mine) + .msg.mine, .msg.mine + .msg:not(.mine) { margin-top: 6px; }
.msg a.file { display: block; color: inherit; margin-bottom: 4px; }
.msg img.attach { max-width: 260px; max-height: 260px; border-radius: 8px; display: block; margin-top: 4px; }
.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { resize: none; max-height: 160px; }
.composer-error { padding: 0 16px 10px; background: var(--panel); }

/* Settings */
.settings { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 20px; align-content: start; max-width: 1000px; width: 100%; margin: 0 auto; }
.settings h2 { margin: 0 0 6px; }
.settings h3 { margin: 0; grid-column: 1 / -1; font-size: 15px; }
.grid-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form button { justify-self: start; }
.shop-row { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 10px; display: grid; gap: 8px; }
.shop-row-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.shop-row-head .actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.report { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: 12px/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-x: auto; margin: 0; }
.table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table .cell-actions { text-align: right; }
.list-empty { padding: 16px; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .shop-status { display: none; }
  .chats { grid-template-columns: 1fr; }
  .chats.open .sidebar { display: none; }
  .chats:not(.open) .chat { display: none; }
  .back { display: inline-block; }
  .grid-form { grid-template-columns: 1fr; }
  .settings { padding: 12px; }
}
