:root {
  --bg: #0a0f24;
  --bg2: #10173a;
  --card: #151d45;
  --card2: #1b2552;
  --line: #26306a;
  --text: #f2ecdf;
  --muted: #9aa2c7;
  --orange: #ff8a3d;
  --orange2: #ff6b2c;
  --gold: #f5c26b;
  --green: #5fd3a0;
  --red: #ff6b7a;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1d2a6b 0%, transparent 60%),
              linear-gradient(180deg, var(--bg2) 0%, var(--bg) 70%);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
.sky {
  position: fixed; inset: 0; pointer-events: none; opacity: .55; z-index: 0;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 120px 80px, #ffe9b0 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 200px 160px, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 300px 40px, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 60px 220px, #ffd88a 50%, transparent 51%);
  background-size: 340px 260px;
}
.hidden { display: none !important; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: rgba(10, 15, 36, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.title { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; min-width: 0; }
.title #title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { background: none; border: 0; color: var(--gold); font-size: 30px; line-height: 1; padding: 0 14px 4px 4px; min-width: 40px; min-height: 36px; }
.shift { border: 0; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; }
.shift.on { background: rgba(95, 211, 160, .15); color: var(--green); }
.shift.off { background: rgba(255, 107, 122, .12); color: var(--red); }
main { position: relative; z-index: 1; padding: 12px 16px 96px; max-width: 760px; margin: 0 auto; }
.center { text-align: center; padding: 48px 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
h2 { font-size: 15px; margin: 18px 4px 8px; color: var(--gold); font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-size: 13.5px; font-weight: 600;
}
.chip.on { background: var(--orange); border-color: var(--orange); color: #1a0f05; }
.chip .n { margin-left: 6px; opacity: .8; }
.search {
  font-family: inherit;
  width: 100%; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; padding: 10px 12px; font-size: 15px; outline: none; margin-bottom: 10px;
}
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 24px; color: var(--gold); }
.stat span { color: var(--muted); font-size: 12.5px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: block; color: inherit; text-align: left; width: 100%;
}
.item:active { background: var(--card2); }
.row { display: flex; align-items: center; gap: 8px; }
.row .grow { flex: 1; min-width: 0; }
.name { font-weight: 700; }
.last { color: var(--muted); font-size: 13.5px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.time { color: var(--muted); font-size: 12px; flex: none; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.b-new { background: rgba(255, 138, 61, .18); color: var(--orange); }
.b-active { background: rgba(95, 211, 160, .15); color: var(--green); }
.b-closed { background: rgba(154, 162, 199, .15); color: var(--muted); }
.b-red { background: rgba(255, 107, 122, .15); color: var(--red); }
.b-gold { background: rgba(245, 194, 107, .15); color: var(--gold); }
.unread {
  flex: none; min-width: 22px; height: 22px; border-radius: 11px; background: var(--orange);
  color: #1a0f05; font-size: 12px; font-weight: 800; display: grid; place-items: center; padding: 0 6px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.btn {
  border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 700; font-size: 14px;
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
}
.btn.primary { background: linear-gradient(135deg, var(--orange), var(--orange2)); color: #1a0f05; border: 0; }
.btn.danger { color: var(--red); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; }
.chat { display: flex; flex-direction: column; gap: 6px; padding-bottom: 120px; }
.msg { max-width: 84%; padding: 8px 12px; border-radius: 16px; word-wrap: break-word; }
.msg .t { white-space: pre-wrap; }
body.composing .tabs { display: none; }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.msg.in { align-self: flex-start; background: var(--card2); border-bottom-left-radius: 6px; }
.msg.out { align-self: flex-end; background: rgba(255, 138, 61, .18); border: 1px solid rgba(255, 138, 61, .35);
  border-bottom-right-radius: 6px; }
.msg.sel { outline: 2px solid var(--gold); }
.msg .who { font-size: 12px; font-weight: 700; color: var(--gold); margin-bottom: 2px; }
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10, 15, 36, .95); border-top: 1px solid var(--line);
}
.composer .replyto { font-size: 12.5px; color: var(--gold); padding: 0 4px 6px; display: flex; gap: 8px; }
.composer .replyto span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.composer .row textarea {
  flex: 1; resize: none; max-height: 120px; min-height: 42px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); padding: 10px 12px; font: inherit; outline: none;
}
.send { width: 44px; height: 42px; border-radius: 14px; border: 0; font-size: 18px;
  background: linear-gradient(135deg, var(--orange), var(--orange2)); color: #1a0f05; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: flex;
  background: rgba(10, 15, 36, .95); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; background: none; border: 0; color: var(--muted); padding: 9px 4px 10px; font-size: 11.5px; font-weight: 600;
}
.tabs button i { display: block; font-style: normal; font-size: 20px; margin-bottom: 2px; }
.tabs button.on { color: var(--orange); }
.tabs .dot { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--orange);
  color: #1a0f05; font-size: 10px; margin-left: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.modal { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; }
.sheet {
  width: 100%; max-height: 85vh; overflow: auto; background: var(--bg2); border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 12px; color: var(--gold); }
.sheet textarea, .sheet input[type=text], .sheet input[type=number] {
  width: 100%; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 10px 12px; font: inherit; margin-bottom: 10px;
}
.opt { display: block; width: 100%; text-align: left; margin-bottom: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 20;
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-size: 14px;
  max-width: 90vw; text-align: center;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch span { flex: 1; }
.switch input { width: 22px; height: 22px; accent-color: var(--orange); }
.pzsides { display: flex; gap: 8px; margin-bottom: 10px; }
.pzsides .item { padding: 10px; font-size: 13px; }
.msg.b { align-self: flex-end; background: rgba(245, 194, 107, .12); border: 1px solid rgba(245, 194, 107, .3);
  border-bottom-right-radius: 6px; }
.msg.a { align-self: flex-start; background: var(--card2); border-bottom-left-radius: 6px; }
