:root {
  color-scheme: dark;
  --black: #000000;
  --lens-white: #f5f7f7;
  --graphite: #171b1d;
  --graphite-light: #2b3134;
  --prism: #52d6df;
  --amber: #f2b84b;
  --muted: #9ca6aa;
  --safe-top: max(20px, env(safe-area-inset-top));
  --safe-bottom: max(24px, env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  background: var(--black);
  color: var(--lens-white);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--black);
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

.shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: var(--safe-top) 20px var(--safe-bottom);
}

.topbar,
.device-line,
.section-heading,
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  min-height: 52px;
  border-bottom: 1px solid var(--graphite-light);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--lens-white);
  font-size: 15px;
  font-weight: 620;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-lens {
  width: 17px;
  height: 17px;
  border: 2px solid var(--prism);
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--black);
  background: var(--lens-white);
}

.text-button,
.pair-button,
.dialog-close {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.text-button {
  min-height: 44px;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
}

.device-line {
  min-height: 112px;
}

.device-name {
  margin: 0 0 7px;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 520;
  letter-spacing: -0.035em;
}

.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.signal {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.connection.online .signal {
  background: var(--prism);
  box-shadow: 0 0 0 4px rgb(82 214 223 / 12%);
}

.pair-button {
  min-height: 44px;
  padding: 0 2px;
  color: var(--prism);
  font-weight: 620;
}

.viewfinder {
  position: relative;
  padding: clamp(30px, 8vw, 54px) clamp(22px, 7vw, 46px);
  margin: 4px 0 22px;
}

.corner {
  position: absolute;
  width: 35px;
  height: 35px;
  border-color: var(--graphite-light);
  border-style: solid;
}

.corner-nw { inset: 0 auto auto 0; border-width: 1px 0 0 1px; }
.corner-ne { inset: 0 0 auto auto; border-width: 1px 1px 0 0; }
.corner-sw { inset: auto auto 0 0; border-width: 0 0 1px 1px; }
.corner-se { inset: auto 0 0 auto; border-width: 0 1px 1px 0; }

h1,
h2,
p {
  max-width: 38rem;
}

h1 {
  margin: 0 0 24px;
  font-size: clamp(32px, 9vw, 54px);
  font-weight: 430;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.viewfinder label,
dialog label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 14px;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--graphite-light);
  border-radius: 0;
  background: var(--graphite);
  color: var(--lens-white);
  caret-color: var(--prism);
}

textarea {
  min-height: 126px;
  padding: 17px;
  resize: vertical;
  font-size: 20px;
  line-height: 1.35;
}

textarea::placeholder,
input::placeholder {
  color: #687176;
}

.composer-actions {
  margin-top: 14px;
}

#character-count {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.primary-button {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 2px;
  background: var(--lens-white);
  color: var(--black);
  font-weight: 680;
  cursor: pointer;
}

.primary-button:disabled {
  background: var(--graphite-light);
  color: var(--muted);
  cursor: not-allowed;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--graphite-light);
  border-bottom: 1px solid var(--graphite-light);
}

.quick-actions button {
  min-height: 105px;
  padding: 18px 12px;
  border: 0;
  border-right: 1px solid var(--graphite-light);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.quick-actions button:last-child {
  border-right: 0;
}

.quick-actions span,
.quick-actions small {
  display: block;
}

.quick-actions span {
  margin-bottom: 7px;
  font-size: 15px;
  font-weight: 620;
}

.quick-actions small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.activity {
  padding-top: 32px;
}

.section-heading h2,
dialog h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 560;
  letter-spacing: -0.025em;
}

.activity ol {
  padding: 0;
  margin: 16px 0 0;
  list-style: none;
  border-top: 1px solid var(--graphite-light);
}

.activity li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--graphite-light);
}

.activity li span {
  font-size: 15px;
}

.activity li time,
.activity li small {
  color: var(--muted);
  font-size: 12px;
}

.activity li small {
  grid-column: 1 / -1;
}

.activity .empty-state {
  display: block;
  color: var(--muted);
}

dialog {
  width: min(calc(100% - 32px), 480px);
  padding: 0;
  border: 1px solid var(--graphite-light);
  border-radius: 2px;
  background: var(--black);
  color: var(--lens-white);
}

dialog::backdrop {
  background: rgb(0 0 0 / 78%);
  backdrop-filter: blur(6px);
}

dialog form {
  position: relative;
  padding: 30px;
}

dialog p {
  margin: 12px 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

dialog input {
  height: 50px;
  padding: 0 14px;
  margin-bottom: 16px;
}

dialog .primary-button {
  width: 100%;
}

.dialog-close {
  position: absolute;
  top: 13px;
  right: 14px;
  width: 44px;
  height: 44px;
  color: var(--muted);
  font-size: 28px;
}

.form-error {
  min-height: 21px;
  margin: 0 0 10px;
  color: var(--amber);
}

#pairing-credential {
  min-height: 100px;
  margin-bottom: 14px;
  font-size: 14px;
  word-break: break-all;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 10;
  max-width: 440px;
  padding: 14px 16px;
  margin: auto;
  background: var(--lens-white);
  color: var(--black);
  font-size: 14px;
  font-weight: 620;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 140ms ease-out, transform 140ms ease-out;
}

@media (max-width: 480px) {
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .quick-actions button {
    min-height: 74px;
    border-right: 0;
    border-bottom: 1px solid var(--graphite-light);
  }

  .quick-actions button:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}


.tools {
  margin-bottom: 22px;
  border-top: 1px solid var(--graphite-light);
}

.tools details {
  border-bottom: 1px solid var(--graphite-light);
  padding: 4px 0;
}

.tools summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  font-size: 17px;
  cursor: pointer;
}

.tools details[open] {
  padding-bottom: 18px;
}

.tools label {
  display: block;
  margin: 12px 0 7px;
  color: var(--muted);
  font-size: 14px;
}

.tools input,
.tools select,
.tools textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--graphite-light);
  border-radius: 0;
  background: var(--graphite);
  color: var(--lens-white);
  font: inherit;
  font-size: 18px;
}

.tools textarea {
  min-height: 110px;
}

.tools .primary-button {
  margin-top: 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.chips button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--graphite-light);
  background: var(--graphite);
  color: var(--lens-white);
  font: inherit;
  cursor: pointer;
}

.chips button.selected {
  border-color: var(--prism);
  color: var(--prism);
}

.results {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.results button {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--graphite-light);
  border-top-width: 0;
  background: var(--graphite);
  color: var(--lens-white);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.results li:first-child button {
  border-top-width: 1px;
}

.hint {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.code-box {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--graphite-light);
  background: var(--graphite);
}

.code-box a {
  color: var(--prism);
}

.user-code {
  margin: 6px 0 0;
  font-size: 30px;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}
