/* ============================================================
   まごとも (magotomo) — Global Stylesheet
   White-based, clean, modern (Stripe / Apple aesthetic)
   ============================================================ */

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --bg:           #f8fafc;
  --white:        #ffffff;
  --blue:         #2563eb;
  --blue-dark:    #1d4ed8;
  --blue-light:   #eff6ff;
  --green:        #059669;
  --green-light:  #ecfdf5;
  --red:          #dc2626;
  --red-light:    #fef2f2;
  --orange:       #ea580c;
  --orange-light: #fff7ed;
  --t1:           #0f172a;
  --t2:           #475569;
  --t3:           #94a3b8;
  --border:       #e2e8f0;
  --shadow-sm:    0 1px 3px rgba(0, 0, 0, .06);
  --shadow:       0 4px 12px rgba(0, 0, 0, .08);
  --shadow-lg:    0 12px 30px rgba(0, 0, 0, .1);
  --r:            12px;
}

/* ── Reset / Base ────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans JP', 'Inter', -apple-system, BlinkMacSystemFont,
               'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--t1);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  background: var(--blue);
  color: var(--white);
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  border: none;
  border-radius: var(--r);
  padding: 14px 20px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background .2s, transform .2s, box-shadow .2s;
}

.btn-primary:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(37, 99, 235, .35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  border: 1.5px solid var(--blue);
  border-radius: var(--r);
  padding: 14px 20px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background .2s, color .2s, transform .2s;
}

.btn-secondary:hover {
  background: var(--blue-light);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--t2);
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  transition: color .2s, border-color .2s, background .2s;
}

.btn-ghost:hover {
  color: var(--t1);
  border-color: var(--t2);
  background: var(--bg);
}

/* ── Form Inputs ─────────────────────────────────────────── */
.inp {
  display: block;
  width: 100%;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 13px 16px;
  color: var(--t1);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.inp::placeholder {
  color: var(--t3);
}

.inp:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.lbl {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.form-group {
  margin-bottom: 16px;
}

select.inp {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

textarea.inp {
  resize: vertical;
  min-height: 100px;
}

/* ── Navigation Bar ──────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 200;
  background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.nav-logo {
  font-size: 20px;
  font-weight: 900;
  color: var(--t1);
  cursor: pointer;
  text-decoration: none;
  letter-spacing: -.3px;
}

.nav-logo span.accent {
  color: var(--blue);
}

/* ── Page Helpers ────────────────────────────────────────── */
.page {
  padding-top: 64px;
  min-height: 100vh;
}

.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px);
  padding: 24px;
}

.pt-nav {
  padding-top: 72px;
}

.pb-nav {
  padding-bottom: 76px;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.badge-green {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid rgba(5, 150, 105, .3);
}

.badge-blue {
  background: var(--blue-light);
  color: var(--blue);
  border: 1px solid rgba(37, 99, 235, .3);
}

.badge-red {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid rgba(220, 38, 38, .3);
}

.badge-orange {
  background: var(--orange-light);
  color: var(--orange);
  border: 1px solid rgba(234, 88, 12, .3);
}

/* ── Toast Notification ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transition: transform .35s ease;
  z-index: 9999;
  white-space: nowrap;
  pointer-events: none;
}

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

.toast.success {
  background: var(--green-light);
  color: var(--green);
  border-color: rgba(5, 150, 105, .3);
}

.toast.error {
  background: var(--red-light);
  color: var(--red);
  border-color: rgba(220, 38, 38, .3);
}

/* ── Mobile Bottom Navigation ────────────────────────────── */
.mob-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mob-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  cursor: pointer;
  color: var(--t3);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  background: transparent;
  transition: color .2s;
  text-decoration: none;
}

.mob-nav-item.active,
.mob-nav-item:hover {
  color: var(--blue);
}

.mob-nav-item svg {
  width: 22px;
  height: 22px;
}

/* ── Section ─────────────────────────────────────────────── */
.section {
  padding: 80px 24px;
}

@media (max-width: 640px) {
  .section {
    padding: 48px 16px;
  }
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes pulse-ring {
  0%   { transform: scale(.8);  opacity: .6; }
  100% { transform: scale(2.2); opacity: 0;  }
}

@keyframes heartbeat {
  0%,  100% { transform: scale(1);    }
  15%        { transform: scale(1.1);  }
  30%        { transform: scale(1);    }
  45%        { transform: scale(1.07); }
  70%        { transform: scale(1);    }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0);    }
}

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

@keyframes wave {
  0%,  100% { height: 3px;  }
  50%        { height: 20px; }
}

/* ── Sound Wave Bars ─────────────────────────────────────── */
.wave-bar {
  width: 3px;
  background: var(--blue);
  border-radius: 2px;
  margin: 0 1px;
  animation: wave 1.2s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0s;   }
.wave-bar:nth-child(2) { animation-delay: .1s;  }
.wave-bar:nth-child(3) { animation-delay: .2s;  }
.wave-bar:nth-child(4) { animation-delay: .3s;  }
.wave-bar:nth-child(5) { animation-delay: .4s;  }
.wave-bar:nth-child(6) { animation-delay: .3s;  }
.wave-bar:nth-child(7) { animation-delay: .2s;  }
.wave-bar:nth-child(8) { animation-delay: .1s;  }

/* ── Floor Plan SVG ──────────────────────────────────────── */
.room-svg {
  fill: var(--white);
  stroke: #e2e8f0;
  stroke-width: 1.5;
  transition: all .6s ease;
  cursor: pointer;
}

.room-svg.active {
  fill: #eff6ff;
  stroke: #2563eb;
  stroke-width: 2;
}

.room-svg.sleeping {
  fill: #ecfdf5;
  stroke: #059669;
  stroke-width: 2;
}

.room-svg.alert {
  fill: #fef2f2;
  stroke: #dc2626;
  stroke-width: 2;
}

.person-dot {
  fill: #2563eb;
  filter: drop-shadow(0 0 6px rgba(37, 99, 235, .5));
}

.breath-ring {
  fill: none;
  stroke: #2563eb;
  stroke-width: 1.5;
  animation: pulse-ring 2.5s ease-out infinite;
}

.breath-ring:nth-child(2) { animation-delay: .8s;  }
.breath-ring:nth-child(3) { animation-delay: 1.6s; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, .2);
}
