* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #0f0f14;
  color: #e8e8ee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  user-select: none;
}

.topbar {
  padding: env(safe-area-inset-top, 12px) 14px 10px;
  background: #16161d;
  border-bottom: 1px solid #24242e;
}

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

.ip-row label {
  font-size: 12px;
  color: #8a8a99;
  white-space: nowrap;
}

.ip-row input {
  flex: 1;
  background: #0f0f14;
  border: 1px solid #2c2c38;
  color: #e8e8ee;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.ip-row input:focus {
  outline: none;
  border-color: #7c5cff;
}

.ip-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3a3a46;
  flex-shrink: 0;
}
.ip-status.ok { background: #2dd4bf; }
.ip-status.err { background: #f87171; }

.icon-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #1e1e28;
  border: 1px solid #2c2c38;
  font-size: 15px;
  line-height: 1;
}

.icon-btn.active {
  background: #7c5cff33;
  border-color: #7c5cff;
}

.tabs {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding: 10px 12px;
  background: #16161d;
  border-bottom: 1px solid #24242e;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 20px;
  background: #1e1e28;
  color: #a8a8b8;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}

.tab.active {
  background: #7c5cff22;
  color: #b5a3ff;
  border-color: #7c5cff;
}

.tab-add {
  color: #7c5cff;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px;
}

.btn {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #1a1a23;
  border: 1px solid #2c2c38;
  border-radius: 16px;
  color: #e8e8ee;
  transition: transform 0.08s ease, background 0.08s ease;
}

.btn .emoji { font-size: 30px; line-height: 1; }
.btn .name { font-size: 12px; font-weight: 600; text-align: center; padding: 0 4px; }

.btn:active,
.btn.pressed {
  transform: scale(0.93);
  background: #7c5cff33;
  border-color: #7c5cff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  transform: translateX(-50%) translateY(20px);
  background: #24242e;
  color: #e8e8ee;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error { background: #7f1d1d; }

.btn-add {
  border-style: dashed;
  color: #8a8a99;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal-overlay:not([hidden]) {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 320px;
  background: #16161d;
  border: 1px solid #2c2c38;
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.modal label {
  font-size: 12px;
  color: #8a8a99;
}

.modal input {
  background: #0f0f14;
  border: 1px solid #2c2c38;
  color: #e8e8ee;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
}

.modal input:focus {
  outline: none;
  border-color: #7c5cff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.modal-actions button {
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}

.btn-primary { background: #7c5cff; color: #fff; }
.btn-ghost { background: #1e1e28; color: #a8a8b8; border-color: #2c2c38; }
.btn-danger { background: transparent; color: #f87171; border-color: #7f1d1d; margin-right: auto; }
