/* ============================================================
   まごとも Wi-Fi Setup — Mobile browser · light cards
   ============================================================ */

html {
  background-color: #f8f9fa;
}

body.wifi-setup-page {
  background-color: #f8f9fa !important;
  background-image: radial-gradient(circle, #e2e8f0 1px, transparent 1px) !important;
  background-size: 24px 24px !important;
  color: #1f2937;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scroll-padding-top: calc(64px + 12px);
  scroll-padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  padding-bottom: calc(128px + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
}

body.wifi-setup-page .mg-nav {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  backdrop-filter: none;
}

body.wifi-setup-page #mg-footer-root {
  display: none;
}

.ws-shell {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(64px + 16px) 16px 24px;
  box-sizing: border-box;
  width: 100%;
}

.ws-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ws-eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #00b464;
}

.ws-title {
  margin: 0 0 8px;
  font-size: clamp(1.25rem, 5vw, 1.5rem);
  font-weight: 900;
  line-height: 1.3;
  color: #1f2937;
}

.ws-lead {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.7;
  color: #1f2937;
}

.ws-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  color: #1f2937;
}

.ws-card-body {
  padding: 16px;
}

.ws-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
}

.ws-card-head-title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: #1f2937;
}

.ws-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  color: #1f2937;
}

.ws-notice-icon {
  flex-shrink: 0;
  font-size: 18px;
}

.ws-detect-row {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #f8f9fa;
  border: 1px dashed #e2e8f0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.ws-detect-row.visible {
  display: flex;
}

.ws-detect-spinner {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 2px solid #e2e8f0;
  border-top-color: #00b464;
  border-radius: 50%;
  animation: wsSpin 0.8s linear infinite;
}

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

.ws-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ws-form.hidden {
  display: none;
}

.ws-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ws-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1f2937;
}

.ws-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 500;
  color: #1f2937;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  outline: none;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ws-input:focus {
  border-color: #00b464;
  box-shadow: 0 0 0 3px rgba(0, 180, 100, 0.12);
}

.ws-input::placeholder {
  color: #9ca3af;
}

.ws-hint {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
  color: #1f2937;
}

.ws-connected-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(0, 180, 100, 0.06);
  border: 1px solid rgba(0, 180, 100, 0.25);
  border-radius: 16px;
}

.ws-connected-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.ws-connected-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #00b464;
}

.ws-connected-ssid {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 800;
  color: #1f2937;
  word-break: break-all;
}

.ws-live-pill {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: #00b464;
  color: #ffffff;
}

.ws-pair-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-bottom: 8px;
  background: #f8f9fa;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.ws-pair-item:last-child {
  margin-bottom: 0;
}

.ws-pair-ssid {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-pair-meta {
  font-size: 11px;
  font-weight: 500;
  color: #1f2937;
  margin-top: 2px;
}

.ws-btn-remove {
  flex-shrink: 0;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  color: #1f2937;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

.ws-btn-remove:disabled {
  opacity: 0.45;
}

.ws-btn-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  color: #00b464;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  width: 100%;
}

.ws-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ws-step {
  display: flex;
  gap: 14px;
}

.ws-step-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 32px;
}

.ws-step-num {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #00b464;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.ws-step-line {
  flex: 1;
  width: 2px;
  min-height: 16px;
  margin: 4px 0;
  background: #e2e8f0;
}

.ws-step:last-child .ws-step-line {
  display: none;
}

.ws-step-body {
  flex: 1;
  min-width: 0;
  padding: 2px 0 18px;
}

.ws-step-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 800;
  color: #1f2937;
}

.ws-step-desc {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  color: #1f2937;
}

.ws-store-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ws-store-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
  text-decoration: none;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.ws-shimmer {
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: wsShimmer 1.4s infinite;
}

@keyframes wsShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.ws-pair-action-desc {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  color: #1f2937;
}

.ws-btn-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 800;
  font-family: inherit;
  color: #ffffff;
  background: #00b464;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
}

.ws-btn-inline:disabled {
  opacity: 0.55;
}

.ws-status-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(0, 180, 100, 0.06);
  border: 1px solid rgba(0, 180, 100, 0.25);
  border-radius: 12px;
}

.ws-status-badge-label {
  font-size: 13px;
  font-weight: 800;
  color: #00b464;
}

.ws-status-badge-sub {
  font-size: 12px;
  font-weight: 500;
  color: #1f2937;
  margin-top: 2px;
}

.ws-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  z-index: 190;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid #e2e8f0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ws-bottom-inner {
  max-width: 520px;
  margin: 0 auto;
}

.ws-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 800;
  font-family: inherit;
  color: #ffffff;
  background: #00b464;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
  box-sizing: border-box;
  transition: background 0.15s, transform 0.1s;
}

.ws-btn-primary:active {
  transform: scale(0.98);
  background: #009955;
}

.ws-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.ws-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  color: #1f2937;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
}

body.wifi-setup-page .mg-mob-nav {
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.04);
}

body.wifi-setup-page .mg-mob-nav-item {
  color: #1f2937;
  min-height: 52px;
  touch-action: manipulation;
}

body.wifi-setup-page .mg-mob-nav-item.active {
  color: #00b464;
}

.ws-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  background: rgba(31, 41, 55, 0.25);
}

.ws-backdrop.open {
  display: block;
}

.ws-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 301;
  display: none;
  max-height: 88vh;
  overflow-y: auto;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid #e2e8f0;
}

.ws-sheet.open {
  display: block;
  animation: wsSlideUp 0.28s ease-out;
}

@keyframes wsSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.ws-sheet-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 2px;
  background: #e2e8f0;
}

.ws-sheet-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  color: #1f2937;
}

.ws-sheet-desc {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  line-height: 1.6;
  color: #1f2937;
}

.ws-store-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.ws-store-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 88px;
  padding: 14px 10px;
  border-radius: 14px;
  text-decoration: none;
  font-family: inherit;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #1f2937;
}

.ws-store-btn-label {
  font-size: 13px;
  font-weight: 800;
}

.ws-store-btn-sub {
  font-size: 11px;
  font-weight: 500;
}

#ws-connected-view,
#ws-setup-view {
  display: none;
}

#ws-connected-view.visible,
#ws-setup-view.visible {
  display: block;
}

.ws-bottom-bar.hidden {
  display: none;
}

.ws-signal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid #f1f5f9;
  font-size: 13px;
  font-weight: 500;
  color: #1f2937;
  flex-wrap: wrap;
}

.ws-signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.ws-signal-bar {
  width: 4px;
  border-radius: 1px 1px 0 0;
  background: #00b464;
}

.ws-signal-bar.off {
  background: #e2e8f0;
}
