@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&display=swap');

:root {
  --primary: #b63bff;
  --bg: #0a0612;
  --panel: #150d20;
  --text: #eee;
  --muted: #888;
  --ok: #3dd68c;
  --danger: #f66;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 88px;
  -webkit-tap-highlight-color: transparent;
}

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-box {
  background: var(--panel);
  border: 2px solid var(--primary);
  border-radius: 8px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 0 20px rgba(182,59,255,0.3);
}

.login-box h1 { font-size: 22px; margin-bottom: 20px; text-align: center; color: var(--primary); }

input, select, textarea {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #1a1028;
  color: var(--text);
  font-size: 16px;
}

input[type="color"] { padding: 4px; height: 44px; cursor: pointer; }
input[type="range"] { padding: 0; }
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0; min-width: 20px; min-height: 20px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

button.secondary { background: #333; }
button.danger { background: #5c1a1a; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: 1px solid #444;
  font-size: 24px;
  line-height: 1;
}

#health-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid #333;
  position: sticky;
  top: 0;
  z-index: 100;
}

.pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: #333;
}
.pill.ok { background: #1a5c2e; }
.pill.bad { background: #5c1a1a; }

header {
  padding: 12px 16px;
  border-bottom: 1px solid #333;
}
header h1 { font-size: 18px; color: var(--primary); }

.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.tab {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid #333;
  color: var(--muted);
  border-radius: 6px;
  white-space: nowrap;
  font-size: 14px;
}
.tab.active { border-color: var(--primary); color: var(--primary); background: rgba(182,59,255,0.15); }

.tab-panel { display: none; padding: 16px; max-width: 960px; margin: 0 auto; }
.tab-panel.active { display: block; }

.section {
  background: var(--panel);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.section h2 { font-size: 16px; color: var(--primary); margin-bottom: 12px; }
.section h3 { font-size: 14px; color: var(--muted); margin: 12px 0 8px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
label { font-size: 14px; color: var(--muted); display: block; margin-bottom: 4px; }

.toggle { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; min-height: 44px; }
.toggle label { margin: 0; color: var(--text); }

#sticky-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 2px solid var(--primary);
  z-index: 200;
}

#sticky-bar button { flex: 1; font-size: 13px; padding: 8px 10px; }
#btn-shortcuts { flex: 0 0 44px; }

.coord-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.coord-table th, .coord-table td { border: 1px solid #333; padding: 8px; text-align: left; vertical-align: top; }
.coord-table code { color: var(--primary); word-break: break-all; }

.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  border: 1px solid #333;
  border-radius: 8px;
  padding: 12px;
  background: #120a1c;
}
.card-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.card-head code { color: var(--primary); font-size: 15px; }

.theme-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.theme-chip {
  min-height: 48px;
  border: 2px solid #333;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  text-transform: capitalize;
}
.theme-chip.active { border-color: var(--primary); box-shadow: 0 0 12px rgba(182,59,255,0.4); }
.theme-chip[data-preset="purple"] { background: linear-gradient(135deg,#b63bff,#7c3aed); }
.theme-chip[data-preset="blue"] { background: linear-gradient(135deg,#3b82f6,#1d4ed8); }
.theme-chip[data-preset="green"] { background: linear-gradient(135deg,#22c55e,#15803d); }
.theme-chip[data-preset="red"] { background: linear-gradient(135deg,#ef4444,#b91c1c); }
.theme-chip[data-preset="pink"] { background: linear-gradient(135deg,#ec4899,#be185d); }
.theme-chip[data-preset="silver"] { background: linear-gradient(135deg,#9ca3af,#4b5563); }
.theme-chip[data-preset="rainbow"] { background: linear-gradient(90deg,red,orange,yellow,green,blue,violet); }

.alert-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.alert-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #333;
  border-radius: 6px;
}
.alert-row .sound-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.alert-row .sound-cell input[type="file"] { max-width: 140px; font-size: 12px; }

.live-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 320px;
}
.live-chat-log {
  flex: 1;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 8px;
  background: #0d0814;
}
.live-chat-msg {
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.live-chat-msg:hover, .live-chat-msg.selected {
  border-color: var(--primary);
  background: rgba(182,59,255,0.1);
}
.live-chat-msg .user { font-weight: 700; }
.live-chat-msg .text { color: #ccc; word-break: break-word; }

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-replies button { font-size: 13px; }

.reward-card .handler-toggles { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }

.activity-log-list {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid #333;
  border-radius: 8px;
  background: #0d0814;
}
.activity-row {
  padding: 12px;
  border-bottom: 1px solid #2a2035;
}
.activity-row:last-child { border-bottom: none; }
.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}
.activity-body { word-break: break-word; line-height: 1.35; }
.activity-input { margin-top: 6px; font-style: italic; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
.modal-backdrop.hidden { display: none !important; }

.modal {
  background: var(--panel);
  border: 2px solid var(--primary);
  border-radius: 12px 12px 8px 8px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-sm { max-width: 400px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #333;
}
.modal-header h3 { font-size: 16px; color: var(--primary); }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #333;
}
.modal-footer button { flex: 1; min-width: 120px; }

.trigger-field { margin-bottom: 10px; }
.trigger-field .row { align-items: flex-end; }

.shortcut-list p { margin-bottom: 10px; color: var(--muted); }
kbd {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #222;
  color: var(--text);
  font-family: inherit;
  margin-right: 4px;
}

.status-ok { color: var(--ok); }
.status-err { color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

.wizard { max-width: 500px; margin: 0 auto; }
.wizard .step { display: none; }
.wizard .step.active { display: block; }

.hidden { display: none !important; }

@media (min-width: 600px) {
  .alert-grid { grid-template-columns: 1fr 1fr; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 12px; }
  header h1 { font-size: 20px; }
  .tab-panel { padding: 24px; }
}

@media (min-width: 900px) {
  .tabs { flex-wrap: wrap; }
  #sticky-bar { padding: 12px 24px; }
  #sticky-bar button { font-size: 15px; }
}
