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

:root {
  --blue-dark: #1a5276;
  --blue: #2980b9;
  --green: #27ae60;
  --green-light: #d5f5e3;
  --red: #e74c3c;
  --red-light: #fdecea;
  --orange: #e67e22;
  --gray: #95a5a6;
  --gray-light: #f4f6f7;
  --text: #2c3e50;
  --radius: 14px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-light);
  color: var(--text);
}

header {
  background: var(--blue-dark);
  color: white;
  text-align: center;
  padding: 1.4rem 1rem 1rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

header .subtitle {
  font-size: 0.9rem;
  opacity: 0.75;
  margin-top: 0.2rem;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

/* Banners */
.banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--green);
  color: white;
}

.banner.banner-present {
  background: var(--blue);
}

.banner.banner-geo {
  background: var(--orange);
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
  font-weight: 400;
}

.geo-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.geo-banner-text strong {
  font-size: 0.95rem;
}

.geo-banner-text span {
  font-size: 0.85rem;
  opacity: 0.9;
}

.geo-banner-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-geo-yes {
  background: white;
  color: var(--orange);
  font-weight: 700;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-geo-no {
  background: transparent;
  color: white;
  font-weight: 600;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.banner-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

/* My device card */
.my-card {
  background: white;
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border-left: 4px solid var(--blue);
}

.my-card-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.my-name {
  font-weight: 700;
  font-size: 1rem;
}

.my-status-text {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 0.1rem;
}

.btn-toggle {
  flex-shrink: 0;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-toggle.toggle-go-away {
  background: var(--red-light);
  color: var(--red);
}

.btn-toggle.toggle-go-present {
  background: var(--green-light);
  color: var(--green);
}

/* Neighbor list */
#neighbor-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.neighbor-card {
  background: white;
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.neighbor-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.status-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.present {
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-light);
}

.status-dot.away {
  background: var(--gray);
}

.neighbor-info {
  flex: 1;
}

.neighbor-name {
  font-weight: 600;
  font-size: 1rem;
}

.neighbor-status {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 0.15rem;
}

.neighbor-status.present {
  color: var(--green);
}

.neighbor-time {
  font-size: 0.75rem;
  color: #bdc3c7;
  margin-top: 0.1rem;
}

.tap-hint {
  font-size: 0.75rem;
  color: #bdc3c7;
  flex-shrink: 0;
}

/* Device setup link */
.device-setup-link {
  text-align: center;
  margin-top: 1.2rem;
  padding-bottom: 2rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--gray);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.5rem;
}

/* Modal (shared) */
#modal-overlay,
#setup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

#modal,
#setup-modal {
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem 1.5rem 2rem;
  width: 100%;
  max-width: 480px;
}

#modal h2,
#setup-modal h2 {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

#modal-current-status,
.setup-desc {
  font-size: 0.85rem;
  color: var(--gray);
  margin-bottom: 1.2rem;
}

#modal label,
#setup-modal label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  margin-top: 0.8rem;
  color: var(--text);
}

#pin-input,
#setup-pin {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1.4rem;
  letter-spacing: 0.3em;
  border: 2px solid #dce1e7;
  border-radius: 10px;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}

#pin-input:focus,
#setup-pin:focus {
  border-color: var(--blue);
}

#setup-select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid #dce1e7;
  border-radius: 10px;
  outline: none;
  background: white;
  color: var(--text);
}

.pin-error {
  color: var(--red);
  font-size: 0.82rem;
  margin-top: 0.4rem;
  text-align: center;
}

.modal-buttons {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}

.btn {
  flex: 1;
  padding: 0.85rem 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-width: 80px;
  transition: opacity 0.1s;
}

.btn:active {
  opacity: 0.8;
}

.btn-secondary {
  background: var(--gray-light);
  color: var(--text);
}

.btn-present {
  background: var(--green);
  color: white;
}

.btn-away {
  background: var(--red);
  color: white;
}
