:root {
  --bg: #0b0f0d;
  --bg-2: #121815;
  --bg-3: #18211c;
  --line: #24302a;
  --text: #d7e0da;
  --muted: #7f8f87;
  --accent: #6fbf73;
  --accent-2: #2e7d32;
  --danger: #e05252;
  --warn: #d9a441;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
h1, h2, h3 { margin: 0 0 8px; }

.btn { background: var(--bg-3); color: var(--text); border: 1px solid var(--line); padding: 9px 14px; border-radius: var(--radius); cursor: pointer; font-size: 14px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #eafff0; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.danger { background: #3a1c1c; border-color: var(--danger); color: #ffd9d9; }
.btn.active { background: var(--accent-2); border-color: var(--accent); color: #eafff0; }
.btn.file { display: inline-block; }

.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 50% 0%, #16241c 0%, var(--bg) 60%); }
.auth-card { width: 100%; max-width: 380px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.brand-badge { background: var(--accent-2); color: #eafff0; font-weight: 800; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; letter-spacing: 1px; }
.brand-badge.sm { width: 34px; height: 34px; font-size: 13px; }
.brand h1 { font-size: 20px; letter-spacing: 2px; }
.brand p { margin: 2px 0 0; font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab { flex: 1; padding: 8px; background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: var(--radius); cursor: pointer; }
.auth-tab.active { color: var(--text); border-color: var(--accent); background: var(--bg-3); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
input, textarea, select { background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 10px; border-radius: 8px; font-size: 14px; width: 100%; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.auth-msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.auth-msg.error { color: var(--danger); }
.auth-msg.ok { color: var(--accent); }
.hint { font-size: 11px; color: var(--muted); }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.tb-left { display: flex; align-items: center; gap: 10px; }
.tb-user { display: flex; flex-direction: column; line-height: 1.2; }
.tb-user span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.tb-right { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); display: inline-block; }
.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.tab { flex: 0 0 auto; background: transparent; border: 1px solid transparent; color: var(--muted); padding: 8px 12px; border-radius: var(--radius); cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--text); background: var(--bg-3); border-color: var(--line); }

.content { height: calc(100vh - 108px); }
.panel { height: 100%; }
#map { height: calc(100% - 44px); width: 100%; background: #000; }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--bg-2); border-bottom: 1px solid var(--line); overflow-x: auto; }
.toolbar .spacer { flex: 1; }
.legend { position: absolute; bottom: 10px; left: 10px; background: rgba(11,15,13,.8); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 11px; display: flex; gap: 10px; }
.lg { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.lg.me { background: #4fc3f7; } .lg.team { background: #6fbf73; } .lg.other { background: #d9a441; }

.chat-layout { display: flex; height: 100%; }
.channels { width: 150px; border-right: 1px solid var(--line); overflow-y: auto; background: var(--bg-2); }
.channel { padding: 10px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.channel.active { color: var(--text); background: var(--bg-3); border-left: 3px solid var(--accent); }
.channel-sep { padding: 8px 10px 4px; font-size: 10px; letter-spacing: 1px; color: var(--muted); border-top: 1px solid var(--line); }
.channel.dm { font-size: 12px; }
.channel.add { color: var(--accent); font-size: 12px; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; background: var(--bg-2); }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; background: var(--bg-3); border: 1px solid var(--line); }
.msg .meta { font-size: 10px; color: var(--muted); margin-bottom: 3px; }
.msg.own { align-self: flex-end; background: #17301c; border-color: #2f5c38; }
.msg.announce { align-self: center; background: #2a2410; border-color: var(--warn); text-align: center; max-width: 95%; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--bg-2); }

.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 12px; overflow-y: auto; height: calc(100% - 44px); align-content: start; grid-auto-rows: min-content; }
.photo-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.photo-card img { width: 100%; height: 120px; object-fit: cover; display: block; }
.photo-card img { height: 110px; }
.photo-card .pc-meta { padding: 6px 8px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; overflow: hidden; }
.photo-card .pc-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.photo-card .pc-meta span:last-child { flex: 0 0 auto; }
.photo-caption { font-size: 12px; color: var(--muted); padding: 0 8px 8px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.admin-wrap { padding: 14px; overflow-y: auto; height: 100%; }
.pending-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.row { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; flex-wrap: wrap; }
.row .grow { flex: 1; }
.row select, .row input { width: auto; padding: 6px; font-size: 12px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.inline-form input { flex: 1; min-width: 120px; }

.profile-card { max-width: 420px; margin: 20px auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 20px; text-align: center; }
.avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-2); color: #eafff0; display: grid; place-items: center; font-size: 24px; font-weight: 700; margin: 0 auto 12px; }
.profile-link { margin-top: 14px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 9999; padding: 16px; }
.modal-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 16px; position: relative; }
.modal-close { position: absolute; top: 8px; right: 10px; background: transparent; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.modal-box img { width: 100%; border-radius: 10px; }
.comment { border-top: 1px solid var(--line); padding: 6px 0; font-size: 13px; }
.comment .meta { font-size: 10px; color: var(--muted); }

.toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: var(--bg-3); border: 1px solid var(--accent); color: var(--text); padding: 10px 16px; border-radius: 10px; z-index: 10000; font-size: 13px; max-width: 90%; }
.toast.err { border-color: var(--danger); }

.avatar-img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; margin: 0 auto 12px; display: block; border: 2px solid var(--accent-2); }
.profile-details { text-align: left; font-size: 12px; color: var(--muted); margin: 14px 0; display: flex; flex-direction: column; gap: 5px; }
.profile-details b { color: var(--text); font-weight: 600; }
.profile-card select { width: 100%; }
.profile-actions { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; flex-wrap: wrap; }
.install-hint { font-size: 13px; line-height: 1.6; }

.badge { display: inline-block; margin-left: 6px; background: var(--danger); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 10px; font-weight: 700; vertical-align: middle; }
.event-list, .notif-list { display: flex; flex-direction: column; gap: 10px; }
.event-card, .notif-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.notif-card.unread { border-color: var(--accent); }
.ev-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ev-desc { font-size: 13px; color: var(--text); margin: 6px 0; opacity: .9; }
.ev-counts { font-size: 12px; color: var(--accent); margin: 6px 0; }
.ev-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.ev-actions .spacer { flex: 1; }
textarea { background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 10px; border-radius: 8px; font-size: 14px; width: 100%; font-family: var(--font); }

.pv-back { position: absolute; left: 10px; top: 10px; }
#profile-view { position: relative; }
.pv-callsign { font-size: 13px; color: var(--accent); margin-bottom: 2px; }
.pv-bio { text-align: left; font-size: 13px; line-height: 1.5; margin: 12px 0; white-space: pre-wrap; }
.pv-photos { height: auto; max-height: 420px; padding: 0; }
.member-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.member-row { display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; cursor: pointer; }
.member-row:hover { border-color: var(--accent); }
.member-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-2); color: #eafff0; display: grid; place-items: center; font-weight: 700; overflow: hidden; flex: 0 0 auto; }
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.member-info b { font-size: 14px; }
.member-info span { font-size: 11px; color: var(--muted); }

.photo-card { position: relative; }
.pc-del { position: absolute; top: 6px; right: 6px; background: rgba(11,15,13,.85); border: 1px solid var(--danger); color: #ffd9d9; border-radius: 8px; padding: 3px 7px; font-size: 12px; cursor: pointer; }
.pc-user.link { color: var(--accent); cursor: pointer; text-decoration: underline; }

.caption-input { max-width: 200px; padding: 6px 8px; font-size: 12px; }
.comment-del { background: transparent; border: none; color: var(--danger); cursor: pointer; font-size: 11px; padding: 0 2px; }

.btn.emergency { background: #4a1414; border-color: var(--danger); color: #ffd9d9; font-weight: 700; }
.btn.emergency.holding { background: var(--danger); color: #fff; }
.dm-layout { display: flex; height: 100%; }
.dm-list-wrap { width: 220px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--bg-2); }
.dm-list { overflow-y: auto; flex: 1; }
.dm-item { padding: 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.dm-item.active { background: var(--bg-3); border-left: 3px solid var(--accent); }
.dm-item .n { font-size: 13px; }
.dm-item .p { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.auth-guide { text-align: center; margin-top: 12px; }
.auth-guide a, .pv-bio a { color: var(--accent); }
.perm-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.perm-card h3 { font-size: 14px; }
.small-help { font-size: 11px; color: var(--muted); padding: 4px 2px 0; line-height: 1.5; }

@media (max-width: 640px) {
  .channels { width: 110px; }
  .msg { max-width: 92%; }
  .dm-list-wrap { width: 130px; }
}
