﻿:root {
  color-scheme: dark;
  --bg: #0f1420;
  --panel: #172033;
  --panel-2: #1f2c45;
  --border: rgba(255,255,255,.09);
  --text: #edf2f8;
  --muted: #93a3bd;
  --blue: #4da3e8;
  --blue-deep: #145d90;
  --orange: #ff9130;
  --yellow: #ffd23d;
  --red: #ff6b6b;
  --green: #6bcb77;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: 'Roboto', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body { overflow: hidden; }

#map { position: fixed; inset: 0; z-index: 0; background: var(--bg); }
.maplibregl-canvas { outline: none; }

.maplibregl-ctrl-group {
  background: var(--panel);
  border: none;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.maplibregl-ctrl-group button {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.maplibregl-ctrl-group button:hover { background: var(--panel-2); }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib { display: none; }

.dot {
  position: relative;
  width: 20px;
  height: 20px;
  cursor: pointer;
}
.dot-core {
  display: block;
  width: 14px;
  height: 14px;
  margin: 3px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 0 12px 2px rgba(77,163,232,.75), 0 2px 6px rgba(0,0,0,.5);
  transition: transform .15s;
}
.dot.has-0 .dot-core {
  opacity: .55;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.dot:hover .dot-core { transform: scale(1.4); }
.dot.active .dot-core { transform: scale(1.45); }
.dot.active::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { transform: scale(.65); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}
.dot-n {
  position: absolute;
  top: -10px;
  right: -14px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  padding: 0 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.dot-tip {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  font-family: 'Roboto', sans-serif;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.dot-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--panel-2);
}
.dot:hover .dot-tip { opacity: 1; }

.sh {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: rgba(15,20,32,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}
.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .02em;
  flex-shrink: 0;
}
.sh-title { font-weight: 500; font-size: 17px; margin-right: auto; }

.chips {
  position: fixed;
  top: 76px;
  left: 12px;
  z-index: 900;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: calc(100vw - 24px);
}
.chip {
  background: rgba(23,32,51,.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .2s, color .2s;
}
.chip:hover { background: rgba(31,44,69,.95); }
.chip.active { background: var(--blue); color: #0c1826; font-weight: 500; border-color: transparent; }

#card {
  position: fixed;
  top: 84px;
  right: 16px;
  bottom: 16px;
  width: 380px;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid rgba(77,163,232,.45);
  box-shadow: 0 16px 48px rgba(0,0,0,.55), 0 0 26px rgba(77,163,232,.22);
  display: none;
  flex-direction: column;
  z-index: 950;
}
#card.open { display: flex; }
#card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 18px 12px;
}
.card-obj { color: var(--muted); font-size: 13px; }
.card-title { font-size: 19px; font-weight: 700; margin-top: 2px; }
#card-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color .2s;
  flex-shrink: 0;
}
#card-close:hover { color: var(--red); }
#card-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#card-list::-webkit-scrollbar { width: 6px; }
#card-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
.msg {
  background: rgba(255,255,255,.04);
  border-radius: 12px;
  padding: 12px 14px;
}
.msg-place {
  color: var(--yellow);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.msg-body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  margin-top: 6px;
  overflow-wrap: anywhere;
}
.msg-date { color: var(--muted); font-size: 12px; margin-top: 8px; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; font-size: 14px; }
#card-btn {
  margin: 14px 18px 18px;
  height: 46px;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  font-family: 'Roboto', sans-serif;
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  cursor: pointer;
  transition: filter .2s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { filter: grayscale(.5) brightness(.8); cursor: default; }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--text);
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  border-radius: 12px;
  padding: 11px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background .2s;
}
.btn-ghost:hover { background: rgba(255,255,255,.06); }

#modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#modal.open, #edit-modal.open { display: flex; }
.modal-back {
  position: absolute;
  inset: 0;
  background: rgba(6,10,16,.72);
}
.modal-card {
  position: relative;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 24px;
  width: min(480px, 100%);
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.modal-card h2 { font-size: 19px; margin-bottom: 4px; }
#modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.modal-card label { font-size: 13px; color: var(--muted); margin: 12px 0 6px; display: block; }
.modal-card input, .modal-card textarea, .modal-card select,
.filters input, .filters select,
.login-card input {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--text);
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
.modal-card input:focus, .modal-card textarea:focus, .modal-card select:focus,
.filters input:focus, .filters select:focus,
.login-card input:focus { border-color: var(--blue); }
.modal-card textarea { resize: vertical; min-height: 110px; }
.field-error { color: var(--red); font-size: 12px; min-height: 16px; margin-top: 4px; }
#f-count { color: var(--muted); font-size: 12px; text-align: right; margin-top: 4px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  color: var(--text);
  padding: 13px 22px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 12px 36px rgba(0,0,0,.5);
  opacity: 0;
  transition: opacity .25s, transform .25s;
  z-index: 3000;
  pointer-events: none;
  font-size: 14px;
  max-width: calc(100vw - 32px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

button:focus-visible, a:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

#splash {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: radial-gradient(ellipse at 50% 40%, #1a2540 0%, var(--bg) 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  transition: opacity .5s;
}
#splash.hidden { opacity: 0; pointer-events: none; }
.splash-card { text-align: center; max-width: 540px; margin: auto; }
.splash-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  margin: 0 auto 22px;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 26px rgba(77,163,232,.45);
}
.splash-card h1 { font-size: 30px; line-height: 1.25; font-weight: 700; margin-bottom: 14px; }
.splash-card p { color: var(--muted); font-size: 15px; line-height: 1.65; margin-bottom: 16px; }
.splash-card .splash-note {
  color: var(--blue);
  font-weight: 500;
  margin-bottom: 20px;
}
.splash-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 26px;
}
.cta-item {
  background: rgba(77,163,232,.1);
  border: 1px solid rgba(77,163,232,.35);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 12px;
}
.splash-card .btn-primary { padding: 14px 38px; font-size: 16px; }

@media (max-width: 640px) {
  .splash-card h1 { font-size: 22px; }
  .splash-card p { font-size: 14px; }
  .cta-item { font-size: 13px; padding: 9px 14px; }
}

input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }
.pw-mask { -webkit-text-security: disc; }

#login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid rgba(77,163,232,.35);
  padding: 32px 28px 28px;
  width: min(380px, 100%);
  box-shadow: 0 24px 64px rgba(0,0,0,.55), 0 0 26px rgba(77,163,232,.18);
  text-align: center;
}
.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px rgba(77,163,232,.35);
}
.login-card h1 { font-size: 21px; margin-bottom: 4px; }
.login-card .login-sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.login-card label { text-align: left; font-size: 13px; color: var(--muted); margin: 12px 0 6px; display: block; }
.login-card input { margin-bottom: 4px; }
.login-card .field-error { text-align: left; }
.login-card .btn-primary { width: 100%; margin-top: 14px; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 44px; }
.pass-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color .2s;
}
.pass-eye:hover { color: var(--text); }
.pass-eye.visible { color: var(--blue); }

.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
.admin-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.admin-top h1 { font-size: 22px; margin-right: auto; }
.admin-body { overflow: auto; max-height: calc(100vh - 220px); border-radius: 12px; border: 1px solid var(--border); }
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}
.filters input, .filters select { width: auto; }
select, input[type="date"] { color-scheme: dark; }
input, select, textarea { color: var(--text); background-color: rgba(255,255,255,.05); }
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--panel-2) inset;
  transition: background-color 9999s ease-in-out 0s;
}
input::placeholder { color: var(--muted); opacity: 1; }
select option {
  background: var(--panel);
  color: var(--text);
}
.modal-card select, .filters select { width: auto; }
#tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
#tbl thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  text-align: left;
  padding: 10px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid rgba(255,255,255,.12);
  white-space: nowrap;
  z-index: 1;
}
#tbl td {
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  vertical-align: top;
}
#tbl td.nowrap { white-space: nowrap; }
.mut { color: var(--muted); font-size: 12px; }
.badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.badge.published { background: rgba(107,203,119,.15); color: var(--green); }
.badge.hidden { background: rgba(255,255,255,.08); color: var(--muted); }
.btn-mini {
  background: rgba(255,255,255,.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  margin: 2px 2px 2px 0;
  transition: background .2s;
}
.btn-mini:hover { background: rgba(255,255,255,.12); }
.btn-mini.danger { color: var(--red); border-color: rgba(255,107,107,.3); }
.btn-mini.danger:hover { background: rgba(255,107,107,.12); }
#edit-modal { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; padding: 16px; }
#edit-modal .modal-card select { width: 100%; }
.actions { display: flex; flex-wrap: wrap; }

#campus-switch {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 940;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  background: rgba(23,32,51,.92);
  border: 1px solid rgba(77,163,232,.35);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0,0,0,.45), 0 0 18px rgba(77,163,232,.15);
}
.sw-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .2s, background .2s;
  white-space: nowrap;
}
.sw-btn:hover { color: var(--text); }
.sw-btn.active {
  background: var(--blue-deep);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 0 14px rgba(77,163,232,.4);
}
.sw-arrow { color: var(--blue); font-size: 15px; user-select: none; }

@media (max-width: 640px) {
  .sh { height: 56px; padding: 0 12px; gap: 10px; }
  .logo { width: 38px; height: 38px; border-radius: 10px; font-size: 9px; }
  .sh-title {
    font-size: 14px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .dot { width: 24px; height: 24px; -webkit-tap-highlight-color: transparent; }
  .dot-core { width: 15px; height: 15px; margin: 4px; }
  .dot::after { content: ''; position: absolute; inset: -14px; }
  .dot-n { min-width: 17px; height: 17px; font-size: 10px; top: -8px; right: -12px; }
  .dot-tip { display: none; }
  .dot:hover .dot-tip { opacity: 0; }
  .chip, .sw-btn, button { -webkit-tap-highlight-color: transparent; }

  #chips-wrap {
    position: fixed;
    top: 64px;
    left: 8px;
    right: 8px;
    z-index: 900;
    pointer-events: none;
  }
  #chips-wrap .chips { pointer-events: auto; }
  #chips-wrap::before,
  #chips-wrap::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s;
    z-index: 2;
    border-top: 3px solid var(--blue);
    border-right: 3px solid var(--blue);
    border-radius: 2px;
    filter: drop-shadow(0 0 6px rgba(77,163,232,.95)) drop-shadow(0 1px 3px rgba(0,0,0,.6));
  }
  #chips-wrap::before {
    left: 7px;
    transform: translateY(-50%) rotate(-135deg);
  }
  #chips-wrap::after {
    right: 7px;
    transform: translateY(-50%) rotate(45deg);
  }
  #chips-wrap.can-left::before { opacity: 1; }
  #chips-wrap.can-right::after {
    opacity: 1;
    animation: chipHint 1.6s ease-in-out infinite;
  }
  @keyframes chipHint {
    0%, 100% { opacity: 1; }
    50% { opacity: .25; }
  }

  .chips {
    position: static;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; padding: 7px 13px; font-size: 12px; }

  #campus-switch {
    left: 10px;
    right: 10px;
    bottom: 12px;
    transform: none;
    justify-content: center;
    padding: 6px;
  }
  .sw-btn { font-size: 12px; padding: 9px 10px; }
  .sw-arrow { font-size: 13px; }

  #card {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    height: 72vh;
    height: 72dvh;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    will-change: transform;
  }
  #card-head {
    position: relative;
    padding: 22px 14px 10px;
    touch-action: none;
    cursor: grab;
  }
  #card-head::before {
    content: '';
    position: absolute;
    top: 9px;
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,.25);
  }
  .card-title { font-size: 17px; padding-right: 20px; }
  #card-list { padding: 0 14px; }
  #card-btn { margin: 10px 14px calc(14px + env(safe-area-inset-bottom)); height: 46px; }

  #modal, #edit-modal {
    align-items: flex-end;
    padding: 0;
  }
  #modal .modal-card, #edit-modal .modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }

  .modal-card h2 { font-size: 17px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn-primary,
  .modal-actions .btn-ghost { width: 100%; padding: 13px 18px; font-size: 15px; }

  .admin-wrap { padding: 14px 10px; }
  .admin-top { margin-bottom: 2px; }
  .admin-top h1 { font-size: 18px; flex-basis: 100%; }
  .admin-top .btn-ghost { padding: 8px 12px; font-size: 12px; }
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 12px 0;
  }
  .filters input,
  .filters select { width: 100%; }
  .filters #flt-q { grid-column: 1 / -1; }
  .filters #flt-apply,
  .filters #flt-reset { width: 100%; padding: 10px 12px; }
  .admin-body {
    overflow-x: auto;
    max-height: none;
    -webkit-overflow-scrolling: touch;
  }
  #tbl { min-width: 840px; font-size: 12px; }
  #tbl thead th,
  #tbl td { padding: 8px; }
  .btn-mini { padding: 6px 9px; font-size: 12px; }

  #toast { bottom: 66px; font-size: 13px; }

  #login { padding: 16px; }
  .login-card { padding: 26px 20px 24px; }
}

@media (max-width: 640px) and (max-height: 640px) {
  .splash-logo { width: 56px; height: 56px; margin-bottom: 14px; }
  .splash-card h1 { font-size: 20px; margin-bottom: 10px; }
  .splash-card p { font-size: 13px; margin-bottom: 12px; }
  .splash-cta { margin-bottom: 18px; }
}
