:root {
  --bg: #0b0d0c;
  --bg-soft: #101411;
  --surface: rgba(20, 25, 22, 0.92);
  --surface-solid: #151a17;
  --line: rgba(244, 248, 245, 0.12);
  --line-strong: rgba(244, 248, 245, 0.22);
  --text: #f2f6f3;
  --muted: #9aa69e;
  --muted-2: #717d75;
  --accent: #62d68f;
  --accent-soft: rgba(98, 214, 143, 0.14);
  --danger: #ff7a7a;
  --warning: #e7c56a;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

svg {
  display: block;
}

.hidden {
  display: none !important;
}

#app,
.app {
  height: 100%;
}

.screen {
  position: relative;
  min-height: 100dvh;
  background: var(--bg);
}

.scroll-screen {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #071009;
  font-size: 0.97rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.primary:active:not(:disabled) {
  transform: scale(0.985);
  filter: brightness(0.94);
}

.primary.wide {
  width: 100%;
}

.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(8, 12, 9, 0.42);
  color: var(--text);
  cursor: pointer;
  position: relative;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.icon-btn.small {
  width: 38px;
  height: 38px;
}

.count-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #071009;
  font-size: 0.65rem;
  font-weight: 750;
}

/* Welcome */

.welcome {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 780px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 22px calc(18px + env(safe-area-inset-bottom));
}

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-gallery {
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.brand-name {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin: 2px 0 0;
  color: var(--muted-2);
  font-size: 0.72rem;
}

.welcome-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 38px 0 24px;
}

.welcome h1 {
  max-width: 560px;
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.1rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.welcome .lead {
  max-width: 480px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.role-grid {
  display: grid;
  gap: 12px;
  margin-top: 32px;
}

.role-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 20px;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 4px 13px;
  width: 100%;
  min-height: 84px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.role-card:active {
  transform: scale(0.993);
  border-color: var(--line-strong);
}

.role-card:first-child {
  border-color: rgba(98, 214, 143, 0.28);
  background: linear-gradient(135deg, rgba(98, 214, 143, 0.12), rgba(255, 255, 255, 0.02));
}

.role-icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--accent);
}

.role-card:nth-child(2) .role-icon {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
}

.role-title {
  grid-column: 2;
  grid-row: 1;
  display: block;
  font-size: 1rem;
  font-weight: 650;
}

.role-desc {
  grid-column: 2;
  grid-row: 2;
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.role-arrow {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--muted-2);
}

.data-mode-card {
  margin-top: 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 160ms ease, background 160ms ease;
}

.data-mode-card.active {
  border-color: rgba(98, 214, 143, 0.38);
  background: rgba(98, 214, 143, 0.08);
}

.data-mode-row {
  display: flex;
  align-items: center;
  gap: 11px;
}

.data-mode-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent);
}

.data-mode-copy {
  flex: 1;
  min-width: 0;
}

.data-mode-title {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 650;
}

.data-mode-desc {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.35;
}

.data-mode-note {
  margin: 9px 0 0;
  color: var(--muted-2);
  font-size: 0.67rem;
  line-height: 1.4;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.switch[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent);
}

.switch[aria-checked="true"] span {
  background: #071009;
  transform: translateX(18px);
}

.switch:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.mode-badge {
  padding: 3px 9px;
  border: 1px solid rgba(98, 214, 143, 0.26);
  border-radius: 999px;
  background: rgba(7, 11, 8, 0.62);
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 650;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.welcome-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 18px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.welcome-note .dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.welcome-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 18px;
  color: var(--muted-2);
  font-size: 0.7rem;
}

.install-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: left;
}

.install-hint button {
  margin-left: auto;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

/* Media screens (camera + controller live) */

.media-screen {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
}

.media {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.media.mirror {
  transform: scaleX(-1);
}

.media-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.62) 0%, rgba(0, 0, 0, 0) 22%),
    linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.24) 30%, rgba(0, 0, 0, 0) 52%);
}

.overlay-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 0;
}

.overlay-bottom {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  padding: 0 14px calc(16px + env(safe-area-inset-bottom));
}

.status-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 72vw;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 11, 8, 0.62);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--warning);
}

.status-pill[data-state="live"] .dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(98, 214, 143, 0.12);
}

.status-pill[data-state="error"] .dot {
  background: var(--danger);
}

.status-pill[data-state="connecting"] .dot {
  animation: pulse 1.2s ease-in-out infinite;
}

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

.pin-mini {
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(7, 11, 8, 0.62);
  color: var(--muted);
  font-size: 0.68rem;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.pin-mini strong {
  margin-left: 4px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.meta-line {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
}

/* Center panels */

.center-panel {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 35%, rgba(20, 35, 25, 0.42), rgba(0, 0, 0, 0.7));
}

.panel {
  width: min(100%, 360px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
}

.panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
}

.panel h2 {
  margin: 0;
  font-size: 1.24rem;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.panel p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.panel .primary {
  width: 100%;
  margin-top: 18px;
}

.panel .error {
  margin-top: 12px;
}

.error {
  color: var(--danger);
  font-size: 0.8rem;
  line-height: 1.45;
}

/* PIN card */

.pin-card {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 7;
  width: min(calc(100% - 36px), 330px);
  padding: 22px 20px 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  background: rgba(11, 15, 12, 0.84);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translate(-50%, -50%);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}

.pin-card .eyebrow {
  font-size: 0.66rem;
}

.pin-digits {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin: 13px 0 0;
  color: var(--text);
  font-size: clamp(2.5rem, 12vw, 3.7rem);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  line-height: 1;
}

.pin-digits span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.98em;
  height: 1.08em;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.pin-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

/* Dock / controls */

.dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.dock-btn,
.round-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 56px;
  height: 56px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(7, 11, 8, 0.56);
  color: var(--text);
  font-size: 0.62rem;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  cursor: pointer;
}

.dock-btn:active,
.round-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.dock-btn[aria-pressed="true"],
.round-btn[aria-pressed="true"] {
  border-color: rgba(98, 214, 143, 0.45);
  background: rgba(98, 214, 143, 0.16);
  color: var(--accent);
}

.dock-btn:disabled,
.round-btn:disabled {
  opacity: 0.3;
}

.zoom-panel {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 auto 10px;
  padding: 8px 14px;
  width: min(100%, 350px);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 11, 8, 0.56);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.zoom-label {
  flex: 0 0 38px;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.zoom-panel input[type="range"] {
  flex: 1;
  height: 26px;
  margin: 0;
  accent-color: var(--accent);
  background: transparent;
}

.wake-note {
  margin: 9px 0 0;
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.64rem;
  text-align: center;
}

/* Countdown + flash + grid */

.countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 112px;
  height: 112px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 3.4rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  transform: translate(-50%, -50%);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  background: #fff;
  opacity: 0;
}

.flash.fire {
  animation: flash 320ms ease-out;
}

@keyframes flash {
  0% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
  }
}

.grid-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.36;
  background-image:
    linear-gradient(to right, transparent calc(33.333% - 0.5px), rgba(255, 255, 255, 0.62) calc(33.333% - 0.5px), rgba(255, 255, 255, 0.62) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px), transparent calc(66.666% - 0.5px), rgba(255, 255, 255, 0.62) calc(66.666% - 0.5px), rgba(255, 255, 255, 0.62) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px)),
    linear-gradient(to bottom, transparent calc(33.333% - 0.5px), rgba(255, 255, 255, 0.62) calc(33.333% - 0.5px), rgba(255, 255, 255, 0.62) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px), transparent calc(66.666% - 0.5px), rgba(255, 255, 255, 0.62) calc(66.666% - 0.5px), rgba(255, 255, 255, 0.62) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px));
}

/* Controller connect */

.simple-top {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 0;
}

.simple-top .title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.connect-wrap {
  width: min(100%, 420px);
  margin: 0 auto;
  padding: 30px 24px calc(28px + env(safe-area-inset-bottom));
}

.connect-intro h1 {
  margin: 7px 0 0;
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.connect-intro p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.pin-input {
  display: block;
  width: 100%;
  height: 84px;
  margin: 26px 0 18px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: 2.65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.34em;
  text-align: center;
  caret-color: var(--accent);
}

.pin-input::placeholder {
  color: var(--muted-2);
  letter-spacing: 0.28em;
}

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

.key {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 500;
  cursor: pointer;
}

.key:active {
  background: rgba(255, 255, 255, 0.09);
}

.key.utility {
  color: var(--muted);
  font-size: 0.9rem;
}

.connect-wrap .primary {
  margin-top: 16px;
}

.hint {
  margin: 15px 0 0;
  color: var(--muted-2);
  font-size: 0.72rem;
  line-height: 1.5;
  text-align: center;
}

/* Controller live */

.controller-top .meta-line {
  margin-top: 5px;
}

.controller-options {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 11, 8, 0.56);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.segmented button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.shutter-row {
  display: grid;
  grid-template-columns: 1fr 104px 1fr;
  align-items: center;
  gap: 16px;
  margin: 0 auto;
  width: min(100%, 390px);
}

.shutter {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 82px;
  height: 82px;
  margin: 0 auto;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.shutter::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #f4f7f5;
  transition: transform 100ms ease, background 160ms ease;
}

.shutter:active::after {
  transform: scale(0.9);
}

.shutter[data-armed="true"]::after {
  background: var(--accent);
}

.shutter[disabled] {
  opacity: 0.55;
}

.round-btn {
  width: 54px;
  height: 54px;
  min-width: 0;
  margin: 0 auto;
  padding: 0;
  border-radius: 50%;
}

.small-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 13px;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.68rem;
  cursor: pointer;
}

.text-btn[aria-pressed="true"] {
  color: var(--accent);
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: calc(100% - 36px);
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 24, 20, 0.94);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Modal + gallery */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 760px);
  max-height: 86dvh;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: sheet-in 220ms ease-out;
}

@keyframes sheet-in {
  from {
    transform: translateY(18px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.sheet-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sheet-head-actions .text-btn {
  color: var(--accent);
}

.sheet-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.sheet-body {
  flex: 1;
  min-height: 0;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

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

.gallery-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080a09;
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-check {
  position: absolute;
  top: 7px;
  right: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.44);
  color: transparent;
  opacity: 0;
  transition: opacity 140ms ease, background 140ms ease, color 140ms ease;
}

.gallery-grid.selecting .gallery-check {
  opacity: 1;
}

.gallery-item.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.gallery-item.selected .gallery-check {
  border-color: var(--accent);
  background: var(--accent);
  color: #071009;
}

.gallery-source {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.56rem;
  font-weight: 600;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.gallery-selectbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface-solid);
}

.selectbar-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.selectbar-info .text-btn {
  color: var(--accent);
}

.selectbar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.selectbar-actions .secondary {
  min-height: 44px;
}

.secondary.danger {
  border-color: rgba(255, 122, 122, 0.3);
  color: var(--danger);
}

.gallery-empty {
  padding: 34px 16px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
  text-align: center;
}

.gallery-viewer {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  flex-direction: column;
  background: rgba(4, 6, 5, 0.97);
}

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

.viewer-meta {
  color: var(--muted);
  font-size: 0.72rem;
}

.viewer-stage {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px;
}

.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.viewer-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
}

/* Help */

.help-body {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.help-body h3 {
  margin: 18px 0 6px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 650;
}

.help-body h3:first-child {
  margin-top: 0;
}

.help-body p {
  margin: 0 0 8px;
}

.help-body ul {
  margin: 0;
  padding-left: 18px;
}

.help-body li {
  margin: 4px 0;
}

@media (min-width: 700px) {
  .role-grid {
    grid-template-columns: 1fr 1fr;
  }

  .role-card {
    min-height: 150px;
    grid-template-columns: 1fr 20px;
    grid-template-rows: auto auto auto;
    align-items: start;
  }

  .role-icon {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 8px;
  }

  .role-title {
    grid-column: 1;
    grid-row: 2;
  }

  .role-desc {
    grid-column: 1;
    grid-row: 3;
  }

  .role-arrow {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
  }

  .welcome-main {
    padding-top: 54px;
  }
}

@media (max-width: 380px) {
  .dock-btn {
    min-width: 50px;
    height: 52px;
    font-size: 0.58rem;
  }

  .overlay-top,
  .overlay-bottom {
    padding-left: 10px;
    padding-right: 10px;
  }

  .pin-digits {
    gap: 6px;
  }
}
