:root {
  color-scheme: light dark;
  --brand: #72734e;
  --brand-hover: #646544;
  --brand-soft: rgba(114, 115, 78, 0.12);
  --background: #fafafa;
  --surface: #ffffff;
  --surface-muted: #f5f5f5;
  --text: #171717;
  --text-secondary: #525252;
  --text-muted: #a3a3a3;
  --border: #e5e5e5;
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;
  --desktop-background: #e5e7eb;
  font-family:
    Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--desktop-background);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--desktop-background);
  overscroll-behavior-x: none;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(114, 115, 78, 0.28);
  outline-offset: 2px;
}

button:not(:disabled):active {
  transform: scale(0.98);
}

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon,
.metric-icon,
.camera-empty-icon {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon {
  width: 20px;
  height: 20px;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 512px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: hidden;
  background: var(--background);
}

.app-main {
  min-height: 100vh;
  min-height: 100dvh;
}

.tab-panel {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.warning {
  position: sticky;
  top: 0;
  z-index: 60;
  padding:
    calc(9px + env(safe-area-inset-top))
    16px
    9px;
  color: #ffffff;
  background: var(--error);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding:
    calc(12px + env(safe-area-inset-top))
    20px
    12px;
}

.house-heading {
  min-width: 0;
}

.house-heading h1,
.top-bar h1 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.house-connection {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.house-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.house-status-dot.connected {
  background: var(--success);
}

.house-status-dot.disconnected {
  background: var(--error);
}

.icon-button,
.small-icon-button {
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  color: var(--text-secondary);
  background: transparent;
  transition:
    color 120ms ease,
    background 120ms ease,
    transform 120ms ease;
}

.icon-button {
  width: 40px;
  height: 40px;
}

.small-icon-button {
  width: 32px;
  height: 32px;
}

.small-icon-button .icon {
  width: 17px;
  height: 17px;
}

.icon-button:hover,
.small-icon-button:hover {
  background: var(--surface-muted);
}

.camera-section {
  padding: 0 16px;
}

.camera-stage {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 16px;
  color: #a3a3a3;
  background:
    radial-gradient(circle at 50% 48%, rgba(114, 115, 78, 0.18), transparent 38%),
    #171717;
}

.camera-label {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  color: #d4d4d4;
  background: rgba(0, 0, 0, 0.42);
  font-size: 0.7rem;
  font-weight: 650;
  backdrop-filter: blur(6px);
}

.camera-label .icon {
  width: 15px;
  height: 15px;
}

.camera-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px 18px;
  text-align: center;
}

.camera-empty-icon {
  width: 34px;
  height: 34px;
  color: #525252;
}

.camera-empty p {
  margin: 10px 0 3px;
  color: #a3a3a3;
  font-size: 0.85rem;
  font-weight: 600;
}

.camera-empty span {
  color: #525252;
  font-size: 0.68rem;
}

.collapse-button {
  display: flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  margin: 4px auto 0;
  padding: 2px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  background: transparent;
  font-size: 0.72rem;
  transition:
    color 120ms ease,
    transform 120ms ease;
}

.collapse-button:hover {
  color: var(--text-secondary);
}

.camera-section.collapsed .camera-stage {
  height: 44px;
  aspect-ratio: auto;
}

.camera-section.collapsed .camera-label {
  top: 50%;
  transform: translateY(-50%);
}

.camera-section.collapsed .camera-empty {
  display: none;
}

.home-section {
  margin-top: 4px;
  padding: 0 16px;
}

.quick-section {
  margin-top: 16px;
}

.section-title-row {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.section-title-row h2 {
  margin: 0;
  color: #404040;
  font-size: 0.875rem;
  font-weight: 800;
}

.environment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px 11px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.metric-icon {
  width: 17px;
  height: 17px;
  color: var(--text-muted);
}

.metric-card p {
  margin: 0;
  color: var(--text);
  line-height: 1;
}

.metric-card strong {
  font-size: 1.125rem;
  font-weight: 800;
}

.metric-card p span {
  margin-left: 1px;
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 500;
}

.metric-zones {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.metric-zones i {
  height: 3px;
  border-radius: 999px;
  background: #e5e5e5;
}

.metric-zones i:first-child {
  background: #bfdbfe;
}

.metric-zones i:nth-child(2) {
  background: #bbf7d0;
}

.metric-zones i:last-child {
  background: #fecaca;
}

.metric-state {
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-muted);
  font-size: 0.62rem;
  font-weight: 750;
}

.control-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-row {
  display: grid;
  min-height: 64px;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 0 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition:
    color 160ms ease,
    background 160ms ease,
    transform 120ms ease;
}

.control-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  color: var(--text-muted);
  background: var(--surface-muted);
}

.ptt-control-icon {
  position: relative;
  color: var(--brand);
  background: var(--brand-soft);
}

.control-copy {
  min-width: 0;
}

.control-copy h3 {
  margin: 0;
  color: #404040;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.35;
}

.control-copy strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-value {
  display: flex;
  gap: 5px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.control-value .icon {
  width: 16px;
  height: 16px;
  color: #d4d4d4;
}

.control-detail {
  grid-column: 2 / -1;
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.68rem;
  line-height: 1.45;
}

.status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.ready {
  background: var(--success);
}

.status-dot.busy {
  background: var(--warning);
}

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

.ptt-action-slot {
  display: grid;
  width: 88px;
}

.ptt-action {
  grid-area: 1 / 1;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 0.75rem;
  font-weight: 800;
  transition:
    opacity 120ms ease,
    color 120ms ease,
    background 120ms ease,
    transform 120ms ease;
}

.ptt-action .icon {
  width: 16px;
  height: 16px;
}

.start-action {
  display: inline-flex;
  color: #ffffff;
  background: var(--brand);
}

.start-action:not(:disabled):hover {
  background: var(--brand-hover);
}

.stop-action {
  display: none;
  color: #ffffff;
  background: var(--error);
}

.ptt-action:disabled {
  opacity: 0.4;
}

body[data-ptt-state="starting"] .start-action,
body[data-ptt-state="active"] .start-action,
body[data-ptt-state="stopping"] .start-action {
  display: none;
}

body[data-ptt-state="starting"] .stop-action,
body[data-ptt-state="active"] .stop-action,
body[data-ptt-state="stopping"] .stop-action {
  display: inline-flex;
}

body[data-ptt-state="starting"] .ptt-control-row {
  box-shadow:
    0 0 0 1px rgba(114, 115, 78, 0.22),
    0 1px 3px rgba(0, 0, 0, 0.06);
}

body[data-ptt-state="active"] .ptt-control-row {
  color: #ffffff;
  background: #72734e;
}

body[data-ptt-state="active"] .ptt-control-icon {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

body[data-ptt-state="active"] .ptt-control-icon::before,
body[data-ptt-state="active"] .ptt-control-icon::after {
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 16px;
  content: "";
  animation: ptt-pulse 1.8s ease-out infinite;
}

body[data-ptt-state="active"] .ptt-control-icon::after {
  animation-delay: 600ms;
}

body[data-ptt-state="active"] .control-copy h3,
body[data-ptt-state="active"] .control-copy strong,
body[data-ptt-state="active"] .control-detail {
  color: #ffffff;
}

body[data-ptt-state="active"] .status-dot {
  border-color: #72734e;
  background: #ffffff;
}

body[data-ptt-state="active"] .stop-action {
  color: #72734e;
  background: #ffffff;
}

body[data-ptt-state="stopping"] .ptt-control-row {
  opacity: 0.72;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: calc(52px + env(safe-area-inset-top));
  align-items: flex-end;
  justify-content: center;
  padding:
    env(safe-area-inset-top)
    16px
    14px;
  border-bottom: 1px solid var(--border);
  background: rgba(250, 250, 250, 0.94);
  backdrop-filter: blur(12px);
}

.top-bar h1 {
  font-size: 1rem;
  text-align: center;
}

.date-picker {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}

.date-picker button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 9px;
  color: var(--text-secondary);
  background: transparent;
}

.date-picker button:hover {
  background: var(--surface-muted);
}

.date-picker button:disabled {
  opacity: 0.3;
}

.date-picker div {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 110px;
  justify-content: center;
  color: var(--brand);
}

.date-picker strong {
  color: var(--text);
  font-size: 0.875rem;
}

.summary-content,
.my-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.summary-content {
  gap: 16px;
}

.summary-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.summary-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
}

.summary-icon.temperature {
  color: #ea580c;
  background: #ffedd5;
}

.summary-icon.humidity {
  color: #0284c7;
  background: #e0f2fe;
}

.summary-icon.noise {
  color: #9333ea;
  background: #f3e8ff;
}

.summary-icon.alert {
  color: #dc2626;
  background: #fee2e2;
}

.summary-card span {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.summary-card strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 800;
}

.summary-card p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.settings-card,
.connection-details {
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.settings-heading {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.settings-heading .icon {
  width: 17px;
  height: 17px;
}

.settings-heading h2 {
  margin: 0;
  color: #404040;
  font-size: 0.875rem;
  font-weight: 800;
}

.settings-row {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row span {
  color: var(--text-muted);
}

.settings-row strong {
  overflow: hidden;
  color: var(--text-secondary);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.empty-setting .icon {
  width: 28px;
  height: 28px;
}

.house-card-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px 10px;
}

.house-card-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  color: #8b8c62;
  background: var(--brand-soft);
}

.house-card-row strong,
.house-card-row span {
  display: block;
}

.house-card-row strong {
  color: var(--text);
  font-size: 0.92rem;
}

.house-card-row div > span {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.connected-badge {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--text-secondary);
  background: var(--surface-muted);
  font-size: 0.62rem;
  font-weight: 800;
}

.connected-badge.connected {
  color: #16a34a;
  background: #f0fdf4;
}

.connected-badge.disconnected {
  color: #dc2626;
  background: #fef2f2;
}

.house-pills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 14px 72px;
}

.house-pills span {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 10px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 0.66rem;
  font-weight: 700;
}

.house-pills .icon {
  width: 14px;
  height: 14px;
}

.connection-details summary {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 750;
  list-style: none;
}

.connection-details summary::-webkit-details-marker {
  display: none;
}

.connection-details summary::after {
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  content: "";
  transform: rotate(45deg) translateY(-2px);
  transition: transform 150ms ease;
}

.connection-details[open] summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.summary-help {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 500;
}

form {
  display: grid;
  gap: 9px;
  padding: 2px 16px 16px;
  border-top: 1px solid var(--border);
}

label {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  color: var(--text);
  background: var(--surface-muted);
  font-size: 1rem;
}

input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.connect-button {
  min-height: 48px;
  margin-top: 8px;
  border: 1px solid rgba(114, 115, 78, 0.28);
  border-radius: 12px;
  color: var(--brand);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 800;
}

.connect-button:hover {
  background: var(--brand-soft);
}

.connect-button:disabled {
  opacity: 0.42;
}

.privacy {
  margin: 0;
  padding: 2px 8px 0;
  color: var(--text-muted);
  font-size: 0.68rem;
  line-height: 1.5;
  text-align: center;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  display: flex;
  width: 100%;
  max-width: 512px;
  height: calc(56px + env(safe-area-inset-bottom));
  align-items: flex-start;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.nav-tab {
  display: flex;
  height: 56px;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  color: var(--text-muted);
  background: transparent;
  font-size: 0.72rem;
  transition:
    color 120ms ease,
    transform 120ms ease;
}

.nav-tab .icon {
  width: 20px;
  height: 20px;
}

.nav-tab span {
  font-weight: 550;
}

.nav-tab.active,
.nav-tab[aria-selected="true"] {
  color: var(--brand);
}

.nav-tab.active span,
.nav-tab[aria-selected="true"] span {
  font-weight: 750;
}

.ptt-live-indicator {
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 49;
  display: none;
  gap: 7px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  color: #ffffff;
  background: #72734e;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  font-size: 0.7rem;
  font-weight: 750;
  transform: translateX(-50%);
}

.ptt-live-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
  animation: live-dot 1.2s ease-in-out infinite;
}

body[data-ptt-state="active"] .ptt-live-indicator {
  display: flex;
}

@keyframes ptt-pulse {
  0% {
    opacity: 0.65;
    transform: scale(0.82);
  }

  80%,
  100% {
    opacity: 0;
    transform: scale(1.18);
  }
}

@keyframes live-dot {
  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0a0a0a;
    --surface: #171717;
    --surface-muted: #262626;
    --text: #fafafa;
    --text-secondary: #d4d4d4;
    --text-muted: #a3a3a3;
    --border: #262626;
    --brand: #d7d8bd;
    --brand-hover: #c7c8ad;
    --brand-soft: rgba(215, 216, 189, 0.12);
    --desktop-background: #000000;
  }

  .section-title-row h2,
  .control-copy h3,
  .settings-heading h2 {
    color: #e5e5e5;
  }

  .top-bar {
    background: rgba(10, 10, 10, 0.94);
  }

  .bottom-nav {
    background: rgba(10, 10, 10, 0.96);
  }

  .metric-card,
  .control-row,
  .summary-card,
  .settings-card,
  .connection-details {
    box-shadow: none;
  }

  .start-action {
    color: #313225;
  }

  .connected-badge.connected {
    color: #86efac;
    background: rgba(20, 83, 45, 0.42);
  }

  .connected-badge.disconnected {
    color: #fca5a5;
    background: rgba(127, 29, 29, 0.4);
  }

  .summary-icon.temperature {
    color: #fb923c;
    background: rgba(124, 45, 18, 0.55);
  }

  .summary-icon.humidity {
    color: #38bdf8;
    background: rgba(12, 74, 110, 0.55);
  }

  .summary-icon.noise {
    color: #c084fc;
    background: rgba(88, 28, 135, 0.55);
  }

  .summary-icon.alert {
    color: #f87171;
    background: rgba(127, 29, 29, 0.5);
  }
}

@media (max-width: 420px) {
  .home-header {
    padding-right: 16px;
    padding-left: 16px;
  }

  .camera-section,
  .home-section {
    padding-right: 12px;
    padding-left: 12px;
  }

  .summary-content,
  .my-content {
    padding-right: 12px;
    padding-left: 12px;
  }

  .camera-stage {
    aspect-ratio: 4 / 3;
  }

  .control-row {
    padding-right: 12px;
    padding-left: 12px;
  }

  .ptt-action-slot {
    width: 82px;
  }

  .ptt-action {
    padding-right: 9px;
    padding-left: 9px;
  }

  .summary-help {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
