:root {
  --bg: #101215;
  --panel: #181b20;
  --panel2: #20242b;
  --text: #f4f5f6;
  --muted: #9da4af;
  --border: #303640;
  --accent: #47c2a8;
  --danger: #e85d75;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(16, 18, 21, 0.95);
  border-bottom: 1px solid var(--border);
}

.title {
  flex: 1;
  font-size: 19px;
  font-weight: 700;
}

main {
  padding: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 260px) 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

input,
select,
textarea,
button {
  font: inherit;
}

.select,
.search,
input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

#airtimeDay {
  cursor: pointer;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.tile {
  min-height: 190px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.tile:active {
  transform: translateY(1px);
}

.tileImg {
  width: 100%;
  height: 128px;
  object-fit: cover;
  display: block;
  background: #090a0d;
}

.tileTitle {
  padding: 10px;
  font-weight: 650;
  line-height: 1.25;
}

.tileUmap {
  margin: 0 10px 10px;
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(71, 194, 168, 0.13);
  color: #bff4e8;
  border: 1px solid rgba(71, 194, 168, 0.32);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.detailHead {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.detailImage {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  background: #090a0d;
  border: 1px solid var(--border);
}

.detailTitle {
  font-size: 22px;
  line-height: 1.18;
  font-weight: 750;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 13px;
  margin-bottom: 12px;
}

.panelTitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.panelSummary {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0 0 8px;
  text-align: left;
  cursor: pointer;
  list-style: none;
}

.panelSummary .panelTitle {
  margin-bottom: 0;
}

.collapsiblePanel.isCollapsed > :not(.panelSummary) {
  display: none;
}

.arrowIcon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
}

.arrowIcon::before {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.collapsiblePanel:not(.isCollapsed) > .panelSummary .arrowIcon::before,
.message[open] > .messageSummary .arrowIcon::before {
  transform: rotate(45deg);
}

.textBlock {
  white-space: pre-wrap;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.messages {
  display: grid;
  gap: 8px;
}

.message {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  overflow: hidden;
}

.messageSummary {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.messageSummary::-webkit-details-marker {
  display: none;
}

.messageMeta {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messagePreview {
  grid-column: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message[open] .messagePreview {
  display: none;
}

.messageText {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-left: 26px;
  margin-top: 6px;
}

.umapCurrent {
  min-height: 36px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--panel2);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.umapCurrent.empty {
  color: var(--muted);
}

.form {
  display: grid;
  gap: 12px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #061512;
  font-weight: 750;
}

.secondary,
.ghost {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
}

.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(232, 93, 117, 0.5);
}

.icon {
  min-width: 38px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
}

.hidden {
  display: none !important;
}

.messageOverlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.55);
  min-height: 100vh;
  min-height: 100dvh;
}

.messageBox {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.45);
}

.messageBox.isSuccess {
  border-color: rgba(71, 194, 168, 0.7);
}

.messageBox.isError {
  border-color: rgba(232, 93, 117, 0.75);
}

.messageTitle {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 760;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.messageBox.isSuccess .messageTitle {
  color: #9bead9;
}

.messageBox.isError .messageTitle {
  color: #ff9aaa;
}

.messageBody {
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
  margin-bottom: 16px;
}

.messageBox.isLoading .messageTitle::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(157, 164, 175, 0.28);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

.messageBox.isLoading {
  border-color: rgba(71, 194, 168, 0.65);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.68);
}

.modalCard {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.modalTop {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.modalTitle {
  flex: 1;
  font-weight: 750;
  font-size: 18px;
}

.adminList {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.adminItem {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  cursor: pointer;
}

.adminItemMeta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.adminForm {
  display: grid;
  gap: 10px;
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
}

.check input {
  width: auto;
}

.check span {
  margin: 0;
}

.switchRow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.switchRow input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switchTrack {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.switchTrack::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}

.switchRow input:checked + .switchTrack {
  background: rgba(232, 93, 117, 0.22);
  border-color: rgba(232, 93, 117, 0.72);
}

.switchRow input:checked + .switchTrack::after {
  transform: translateX(20px);
  background: var(--danger);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .toolbar,
  .detailHead,
  .row {
    grid-template-columns: 1fr;
  }

  .detailImage {
    width: 100%;
    height: 180px;
  }
}
