:root {
  --green: #2e7d32;
  --green-deep: #1b5e20;
  --green-soft: #4caf50;
  --ink: #142018;
  --muted: #5a6b5f;
  --white: #ffffff;
  --danger: #c62828;
  --accent: #0f6a4d;
  --bg0: #eef5ef;
  --bg1: #f7fbf7;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font-display: "Outfit", "Manrope", sans-serif;
  --font-body: "Manrope", "Outfit", sans-serif;
}

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

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.4;
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(76, 175, 80, 0.22), transparent 55%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 100%);
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  width: min(480px, 100%);
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: calc(var(--safe-top) + 1rem) 1.25rem calc(var(--safe-bottom) + 1.25rem);
}

.view[hidden] {
  display: none !important;
}

/* —— Login —— */
.view--login {
  justify-content: center;
  gap: 2.5rem;
}

.login-brand {
  text-align: center;
}

.mark {
  display: inline-block;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--green-soft), var(--green-deep));
  box-shadow: 0 10px 28px rgba(27, 94, 32, 0.28);
}

.login-brand__name {
  margin: 0.9rem 0 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
}

.login-form {
  display: grid;
  gap: 0.85rem;
}

.field input {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(46, 125, 50, 0.18);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
}

.field input:focus {
  outline: 2px solid rgba(46, 125, 50, 0.4);
  border-color: var(--green);
}

.field--password {
  position: relative;
  display: block;
}

.field--password input {
  padding-right: 3.25rem;
}

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgba(27, 94, 32, 0.72);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.pw-toggle:focus-visible {
  outline: 2px solid rgba(46, 125, 50, 0.45);
  outline-offset: 1px;
}

.pw-toggle[aria-pressed="true"] {
  color: var(--green-deep);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0.85rem 1.2rem;
  border-radius: 16px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--block {
  width: 100%;
}

.btn--primary {
  background: linear-gradient(135deg, var(--green-soft), var(--green-deep));
  color: #fff;
}

.btn--danger {
  background: #fff;
  border-color: rgba(198, 40, 40, 0.35);
  color: var(--danger);
}

.btn--accent {
  background: var(--accent);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  border-color: rgba(46, 125, 50, 0.22);
  color: var(--green-deep);
}

.btn--round {
  width: 7.5rem;
  height: 7.5rem;
  min-height: 0;
  border-radius: 999px;
  font-size: 1rem;
}

.status {
  margin: 0;
  text-align: center;
  font-size: 0.92rem;
  color: var(--danger);
}

.status[hidden] {
  display: none;
}

/* —— Home —— */
.view--home {
  padding-bottom: calc(var(--safe-bottom) + 1rem);
}

.home-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.home-line {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.home-status {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.home-status.is-ok {
  color: var(--green-deep);
}

.home-status.is-warn {
  color: #9a6700;
}

.home-status.is-ring {
  color: var(--danger);
  font-weight: 700;
  animation: pulse 1.1s ease-in-out infinite;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.home-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.idle {
  text-align: center;
  padding: 1rem;
}

.idle-dot {
  width: 14px;
  height: 14px;
  margin: 0 auto 1rem;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.55;
}

.idle-dot.is-ok {
  background: var(--green-soft);
  opacity: 1;
  box-shadow: 0 0 0 6px rgba(76, 175, 80, 0.2);
}

.idle-dot.is-ring {
  background: var(--danger);
  opacity: 1;
  animation: pulse 1.1s ease-in-out infinite;
}

.idle-label {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--ink);
}

.video-stage {
  position: relative;
  flex: 1;
  min-height: 200px;
  border-radius: 18px;
  overflow: hidden;
  background: #0d1610;
  margin-bottom: 0.75rem;
}

.video-stage[hidden] {
  display: none !important;
}

.video-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(13, 22, 16, 0.45);
  font-weight: 600;
  padding: 1rem;
  text-align: center;
}

.video-overlay[hidden] {
  display: none;
}

.dock {
  padding-top: 0.5rem;
}

.dock[hidden] {
  display: none !important;
}

.dock__ring,
.dock__call {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

.dock__ring[hidden],
.dock__call[hidden] {
  display: none !important;
}

.dock__call {
  flex-direction: column;
}

/* —— Settings —— */
.settings-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.settings-top h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
}

.linkish {
  border: 0;
  background: transparent;
  color: var(--green-deep);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0;
  min-height: 44px;
}

.settings-body {
  display: grid;
  gap: 1rem;
}

.settings-row {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid rgba(46, 125, 50, 0.12);
  color: var(--muted);
}

.settings-row strong {
  color: var(--ink);
  font-weight: 700;
}

.settings-hint {
  margin: 0.75rem 0 1rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

#remote-audio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

@media (min-width: 640px) {
  body {
    overflow: auto;
  }

  .shell {
    min-height: 100dvh;
    box-shadow: 0 0 0 1px rgba(46, 125, 50, 0.08);
  }
}
