* {
  box-sizing: border-box;
}

:root {
  --safeeyes-vh: 100vh;
  --safeeyes-shell-max-width: 480px;
  --safeeyes-root-bg: #eef6ff;
  --se-bg: #f7fbff;
  --se-surface: rgba(255, 255, 255, 0.88);
  --se-surface-strong: #ffffff;
  --se-line: #dceaff;
  --se-line-soft: #eaf2ff;
  --se-text: #102033;
  --se-muted: #6d7f95;
  --se-blue: #2f7df6;
  --se-blue-deep: #195dcc;
  --se-green: #10a878;
  --se-shadow: 0 12px 34px rgba(47, 125, 246, 0.12);
  --se-shadow-soft: 0 8px 22px rgba(32, 90, 160, 0.08);
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--safeeyes-root-bg);
  color: var(--se-text);
  font-family: "Pretendard", ui-sans-serif, system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: var(--safeeyes-vh);
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

#root {
  width: 100%;
  min-height: var(--safeeyes-vh);
  display: flex;
  justify-content: center;
}

.is-hidden {
  display: none !important;
}

.device-shell {
  width: 100%;
  max-width: var(--safeeyes-shell-max-width);
  height: var(--safeeyes-vh);
  min-height: var(--safeeyes-vh);
  background:
    radial-gradient(circle at 14% 0%, rgba(95, 166, 255, 0.22), transparent 34%),
    linear-gradient(180deg, #fbfdff 0%, var(--se-bg) 100%);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.safeeyes-header {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.9);
  padding: 6px 16px;
  border-bottom: 0.5px solid var(--se-line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.safeeyes-inline-logo {
  height: 28px;
  width: auto;
  display: block;
}

.safeeyes-header span {
  color: var(--se-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
}

.monitor-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.map-screen {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #eef6ff;
}

.kakao-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-status,
.map-locating {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  color: var(--se-muted);
  font-size: 14px;
}

.map-status.error {
  color: #b91c1c;
  padding: 24px;
  text-align: center;
}

.map-status.fallback {
  background: #ffffff;
}

.map-fallback-card {
  width: min(86vw, 360px);
  padding: 24px 22px;
  border: 1px solid #fecaca;
  border-radius: 18px;
  background: #fff5f5;
  box-shadow: 0 18px 42px rgba(185, 28, 28, 0.12);
  display: grid;
  gap: 10px;
}

.map-fallback-card strong {
  color: #991b1b;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.25;
}

.map-fallback-card span {
  color: #b91c1c;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.map-fallback-card b {
  margin-top: 6px;
  color: #111827;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
}

.map-fallback-card small {
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.map-locate-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--se-blue);
  box-shadow: 0 10px 26px rgba(20, 80, 150, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-locate-button.active {
  background: linear-gradient(145deg, #f9fcff, #e7f1ff);
  color: var(--se-blue-deep);
}

.map-locating {
  z-index: 10;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

.map-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #dbeafe;
  border-top-color: var(--se-blue);
  animation: mapSpin 0.8s linear infinite;
}

.kakao-building-label {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.monitor-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 84% 0%, rgba(47, 125, 246, 0.16), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
  color: var(--se-text);
  position: relative;
  overflow: hidden;
}

.monitor-screen.is-fire {
  background: linear-gradient(180deg, #7f1212 0%, #a91515 55%, #7f1212 100%);
  color: #ffffff;
}

.monitor-screen.is-fire::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: screen;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 200, 200, 0.7) 0%, transparent 40%),
    radial-gradient(circle at 70% 80%, rgba(255, 160, 160, 0.6) 0%, transparent 40%);
  animation: monitorSiren 1.6s ease-in-out infinite;
}

.monitor-top {
  padding: 18px 20px 10px;
  position: relative;
  z-index: 1;
}

.monitor-title-row,
.live-indicator,
.mini-sensors,
.bottom-bar,
.status-eyebrow,
.event-row {
  display: flex;
  align-items: center;
}

.monitor-title-row {
  justify-content: space-between;
  gap: 8px;
}

.building-name {
  min-width: 0;
  font-size: 42px;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: -0.05em;
  color: #0d1f36;
}

.live-indicator {
  gap: 5px;
  padding-top: 4px;
  flex-shrink: 0;
  color: var(--se-blue-deep);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  font-weight: 600;
}

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--se-green);
  position: relative;
}

.pulse::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  background: var(--se-green);
  opacity: 0.35;
  animation: monitorPing 1.4s ease-out infinite;
}

.section-pad {
  padding: 0 16px;
  position: relative;
  z-index: 1;
}

.clear-notice-wrap {
  position: fixed;
  left: 50%;
  top: 28px;
  z-index: 70;
  width: min(94vw, 760px);
  transform: translateX(-50%);
  padding: 0;
  pointer-events: none;
}

.clear-notice {
  min-height: 220px;
  padding: 38px 44px;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(236, 253, 245, 0.98) 0%, rgba(209, 250, 229, 0.98) 42%, rgba(52, 211, 153, 0.94) 100%);
  border: 2px solid rgba(16, 168, 120, 0.5);
  box-shadow:
    0 28px 58px rgba(6, 95, 70, 0.24),
    0 0 0 8px rgba(167, 243, 208, 0.38);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 28px;
  pointer-events: auto;
}

.clear-notice-copy {
  min-width: 0;
}

.clear-notice-title {
  color: #047857;
  font-size: clamp(38px, 5.5vw, 54px);
  font-weight: 1000;
  line-height: 1.08;
}

.clear-notice-title::before {
  content: "✓";
  display: inline-block;
  margin-right: 10px;
  color: #059669;
}

.clear-notice-message {
  margin-top: 18px;
  color: #111827;
  font-size: clamp(32px, 4.8vw, 46px);
  font-weight: 1000;
  line-height: 1.24;
  word-break: keep-all;
}

.clear-notice-button {
  min-width: 132px;
  min-height: 92px;
  padding: 0 18px;
  border: 0;
  border-radius: 18px;
  background: #065f46;
  color: #ffffff;
  font-size: 32px;
  font-weight: 1000;
  box-shadow: 0 14px 28px rgba(6, 95, 70, 0.28);
}

.status-card {
  border-radius: 18px;
  padding: 28px 24px;
  position: relative;
  box-shadow: var(--se-shadow);
}

.status-card.normal {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(241, 248, 255, 0.92) 100%);
  border: 0.5px solid var(--se-line);
}

.status-card.fire {
  background: rgba(0, 0, 0, 0.28);
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.status-eyebrow {
  gap: 8px;
  margin-bottom: 12px;
  color: var(--se-green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.status-card.fire .status-eyebrow {
  color: rgba(255, 255, 255, 0.85);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--se-green);
  flex-shrink: 0;
}

.status-card.fire .status-dot {
  width: 12px;
  height: 12px;
  background: #ffffff;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.18);
  animation: monitorFireDot 0.7s ease-in-out infinite;
}

.status-text {
  padding-right: 76px;
}

.status-card.fire .status-text {
  padding-right: 0;
}

.status-title {
  color: var(--se-green);
  font-size: clamp(28px, 9vw, 42px);
  font-weight: 800;
  line-height: 1;
}

.status-card.fire .status-title {
  color: #ffffff;
}

.status-subtitle {
  margin-top: 7px;
  color: #248a70;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.85;
}

.status-card.fire .status-subtitle {
  color: rgba(255, 255, 255, 0.88);
  font-size: 15px;
}

.shield-mark {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(92px, 25vw, 128px);
  height: clamp(92px, 25vw, 128px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  opacity: 1;
  pointer-events: none;
  contain: layout paint;
}

.shield-mark-svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform: translateZ(0);
}

.ack-button {
  margin-top: 14px;
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
}

.se-alarm-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.se-alarm-toggle.off {
  background: rgba(0, 0, 0, 0.24);
  color: rgba(255, 255, 255, 0.74);
}

.audio-permission-prompt {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 14, 11, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}

.audio-permission-card {
  width: min(320px, 88vw);
  border-radius: 20px;
  padding: 36px 28px 28px;
  background: #ffffff;
  color: #1b1a16;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
}

.audio-permission-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #fef2f2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.audio-permission-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 10px;
}

.audio-permission-text {
  color: #6b6960;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 24px;
}

.audio-permission-actions {
  display: flex;
  gap: 10px;
}

.audio-permission-actions button {
  flex: 1;
  height: 52px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
}

.audio-permission-secondary {
  border: 1.5px solid #e5e2d7;
  background: #ffffff;
  color: #6b6960;
}

.audio-permission-primary {
  border: 0;
  background: #dc2626;
  color: #ffffff;
}

.fire-alert-flash::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.86);
  animation: fireAlertFlash 1.35s linear 1;
}

.mini-sensors {
  gap: 7px;
  padding: 12px 16px 0;
  position: relative;
  z-index: 1;
}

.mini-sensor {
  flex: 1;
  min-width: 0;
  min-height: 70px;
  border-radius: 14px;
  padding: 11px 10px;
  text-align: center;
  background: var(--se-surface);
  border: 0.5px solid var(--se-line);
  box-shadow: var(--se-shadow-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.is-fire .mini-sensor {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.mini-icon {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #eef6ff, #ffffff);
  font-size: 19px;
  line-height: 1;
  margin-bottom: 5px;
  color: var(--se-blue);
  box-shadow: inset 0 0 0 1px #dceaff;
}

.is-fire .mini-icon {
  color: rgba(255, 255, 255, 0.85);
}

.mini-label {
  display: block;
  color: var(--se-muted);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.is-fire .mini-label {
  color: rgba(255, 255, 255, 0.64);
}

.mini-value {
  margin-top: 6px;
  display: block;
  color: var(--se-text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
}

.is-fire .mini-value {
  color: #ffffff;
}

.floor-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 10px;
}

.floor-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  background: var(--se-surface-strong);
  border: 0.5px solid var(--se-line);
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--se-shadow-soft);
}

.is-fire .floor-card {
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.floor-title {
  margin-bottom: 6px;
  color: var(--se-muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.is-fire .floor-title {
  color: rgba(255, 255, 255, 0.65);
}

.events-card {
  margin-top: 10px;
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 0.5px solid var(--se-line);
  box-shadow: 0 8px 22px rgba(32, 90, 160, 0.06);
}

.is-fire .events-card {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.16);
}

.event-row {
  justify-content: space-between;
  gap: 10px;
  color: var(--se-muted);
  font-size: 11.5px;
  font-weight: 600;
}

.is-fire .event-row {
  color: rgba(255, 255, 255, 0.7);
}

.bottom-bar {
  flex-shrink: 0;
  height: 72px;
  gap: 8px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.94);
  border-top: 0.5px solid var(--se-line-soft);
  box-shadow: 0 -10px 24px rgba(32, 90, 160, 0.06);
}

.bottom-bar.fire {
  background: rgba(90, 10, 10, 0.95);
  border-top-color: rgba(255, 255, 255, 0.12);
}

.bottom-button {
  flex: 1;
  height: 52px;
  border-radius: 14px;
  border: 0;
  background: linear-gradient(135deg, var(--se-blue) 0%, var(--se-blue-deep) 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(47, 125, 246, 0.22);
}

.bottom-bar.fire .bottom-button {
  background: rgba(255, 255, 255, 0.15);
  border: 0.5px solid rgba(255, 255, 255, 0.3);
}

.bottom-button.danger {
  background: #dc2626 !important;
  border: 0 !important;
  font-weight: 800;
}

html[data-client="app"],
html[data-client="app"] body {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

html[data-client="app"] #root {
  min-height: 100%;
  display: flex;
}

html[data-client="app"] .device-shell {
  max-width: none;
  height: auto;
  min-height: 100%;
  overflow: visible;
}

html[data-client="app"] .monitor-viewport {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  display: block;
  touch-action: pan-y;
}

html[data-client="app"] .monitor-screen {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
}

html[data-client="app"] .floor-section,
html[data-client="app"] .floor-card {
  flex: 0 0 auto;
  min-height: 0;
}

html[data-client="app"] .bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
}

@media (max-width: 480px) {
  .clear-notice-wrap {
    top: 12px;
    width: calc(100vw - 16px);
  }

  .clear-notice {
    min-height: 260px;
    padding: 34px 28px;
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .clear-notice-title {
    font-size: clamp(34px, 9vw, 44px);
  }

  .clear-notice-message {
    font-size: clamp(28px, 7.2vw, 38px);
  }

  .clear-notice-button {
    width: 100%;
    min-height: 82px;
    font-size: 28px;
  }
}

@media (min-width: 900px) {
  :root {
    --safeeyes-shell-max-width: 720px;
    --safeeyes-root-bg: #eef6ff;
  }

  .device-shell {
    border-left: 0.5px solid var(--se-line);
    border-right: 0.5px solid var(--se-line);
  }
}

@keyframes monitorPing {
  0% { transform: scale(0.6); opacity: 0.6; }
  80%, 100% { transform: scale(1.6); opacity: 0; }
}

@keyframes monitorFireDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.12); }
}

@keyframes monitorSiren {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

@keyframes fireAlertFlash {
  0%, 15%, 30%, 45%, 100% { opacity: 0; }
  7%, 22%, 37% { opacity: 1; }
}

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

/* Fire state must stay visually explicit even when light skin rules are cached
   or overridden by app WebView styles. */
.monitor-screen.is-fire {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 92, 92, 0.35), transparent 34%),
    linear-gradient(180deg, #8f1016 0%, #c51622 52%, #7a0c12 100%) !important;
  color: #ffffff !important;
}

.monitor-screen.is-fire .building-name {
  color: #ffffff !important;
  text-shadow: 0 2px 12px rgba(80, 0, 0, 0.38);
}

.monitor-screen.is-fire .status-card.fire {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08)),
    linear-gradient(135deg, #ef2331 0%, #b70f1a 100%) !important;
  border-color: rgba(255, 255, 255, 0.34) !important;
  box-shadow: 0 18px 34px rgba(94, 0, 0, 0.26) !important;
}

.monitor-screen.is-fire .status-card.fire .status-eyebrow,
.monitor-screen.is-fire .status-card.fire .status-title,
.monitor-screen.is-fire .status-card.fire .status-subtitle {
  color: #ffffff !important;
}

.monitor-screen.is-fire .ack-button {
  background: rgba(255, 255, 255, 0.96) !important;
  border-color: transparent !important;
  color: #b70f1a !important;
  box-shadow: 0 10px 22px rgba(80, 0, 0, 0.18);
}

.monitor-screen.is-fire .mini-sensor,
.monitor-screen.is-fire .floor-card {
  background: rgba(45, 0, 0, 0.42) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
}

.monitor-screen.is-fire .mini-icon {
  background: rgba(255, 255, 255, 0.16) !important;
  color: #ffffff !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2) !important;
}

.monitor-screen.is-fire .mini-label,
.monitor-screen.is-fire .mini-value {
  color: #ffffff !important;
}

.bottom-bar.fire {
  background: rgba(88, 8, 12, 0.98) !important;
  border-top-color: rgba(255, 255, 255, 0.16) !important;
}

.bottom-bar.fire .bottom-button:not(.danger) {
  background: #ffffff !important;
  border: 0 !important;
  color: #b70f1a !important;
  box-shadow: 0 10px 22px rgba(70, 0, 0, 0.18) !important;
}

.bottom-bar.fire .bottom-button.danger {
  background: #ef2331 !important;
  color: #ffffff !important;
  box-shadow: 0 10px 22px rgba(239, 35, 49, 0.28) !important;
}
