/* Fonts and base styles */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url('/web/fonts/dm-sans.ttf') format('truetype');
}

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/web/fonts/manrope.ttf') format('truetype');
}

:root {
  --ink: #153c30;
  --green: #174b3b;
  --muted: #727c75;
  --line: #e2e7e1;
  --paper: #fbfcf8;
  --mint: #d9f1c7;
  --body: #333e35;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--body);
  font: 14px/1.55 'DM Sans', sans-serif;
}
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
a { color: inherit; text-decoration: none; }
svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #89b77c; outline-offset: 4px; }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
h1, h2 {
  margin: 0;
  color: var(--ink);
  font-family: 'Manrope', sans-serif;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -.7px;
}
h1 { font-size: 28px; }
h2 { font-size: 23px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.65; }

/* A quiet header and one consistent column for sign-in and setup. */
.topbar {
  height: 72px;
  padding: 0 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font: 750 25px 'Manrope', sans-serif;
  letter-spacing: -1.2px;
  color: var(--ink);
}
.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 29px;
  height: 31px;
  border-radius: 8px;
  background: var(--mint);
  color: #000;
}
.mark svg { width: 23px; height: 23px; fill: #000; stroke: none; }
.quiet, .text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 0;
  font-size: 13px;
}
.quiet { display: flex; align-items: center; gap: 10px; }
.quiet:hover, .text-button:hover { color: var(--green); }
.notice {
  position: fixed;
  inset: auto;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  height: max-content;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(472px, calc(100% - 40px));
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  box-shadow: 0 6px 24px #153c301a;
  animation: toast-in .18s ease-out;
}
.notice::before { content: 'i'; color: var(--green); font-weight: 600; }
.notice[data-tone="error"]::before { content: '!'; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.signin-page {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  max-width: 520px;
  min-height: calc(100dvh - 72px);
  margin: 0 auto;
  padding: 32px 24px;
}
.login-card { grid-row: 2; }
.wizard-layout { display: contents; }
.login-card {
  display: block;
  width: 100%;
  height: auto;
  overflow: clip;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.login-card > div { display: flow-root; }
.login-card[data-size-motion="ready"] { transition: height 1.1s cubic-bezier(.22, 1, .36, 1); }
#credentials-panel h1 { margin-bottom: 24px; }
.phone-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
#setup-panel:has(#enrollment:not([hidden])) { display: flex; flex-direction: column; }
#enrollment { display: flex; flex-direction: column; flex: 1; }
#pairing { display: flex; flex-direction: column; flex: 1; }
#pairing { margin-bottom: 0; }
.pairing-state { min-height: 356px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--ink); }
.pairing-state p { margin: 0; }
.pairing-state > p:first-of-type { font-size: 18px; }
#pairing .pair-visual { width: 100%; margin: 12px 0 24px; flex-shrink: 0; }
#pairing .pair-visual:has(.pair-qr[hidden]) { display: none; }
#pairing .pair-qr { margin: 0 auto; }
.pair-prompt { margin: 0 0 20px; font-size: 22px; font-weight: 500; line-height: 1.4; text-align: center; color: var(--ink); }
#pairing .pair-instruction { margin-top: 18px; }
#pairing .pair-manual { margin-top: 0; padding-top: 0; }
#pairing .pair-manual > summary { margin-bottom: 0; font-size: 13px; list-style: none; }
#pairing .pair-manual > summary svg { width: 22px; height: 22px; color: var(--ink); stroke-width: 2.5; transform: rotate(90deg); transition: transform .5s cubic-bezier(.22, 1, .36, 1); }
#pairing .pair-manual[open] > summary svg { transform: rotate(-90deg); }
#pairing .pair-manual > summary::-webkit-details-marker { display: none; }
#pairing .pair-manual[open] > summary { margin-bottom: 20px; }
.pair-instruction:empty { display: none; }
.back-arrow { width: 34px; height: 34px; padding: 6px; border: 0; border-radius: 8px; background: transparent; color: var(--green); }
.back-arrow:hover { background: #edf3e7; }
.back-arrow svg, .back-arrow:hover svg { transform: rotate(180deg); }
.session-loading { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
#auth-view[data-stage="restoring"] .wizard-layout { display: none; }
.auth-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: auth-spin .9s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* Forms use the same sizes and spacing throughout. */
label { display: block; margin: 0 0 7px; font-size: 13px; font-weight: 500; }
input {
  display: block;
  width: 100%;
  height: 46px;
  margin-bottom: 20px;
  padding: 0 13px;
  border: 1px solid #dce3db;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
input::placeholder { color: #99a199; }
input:focus { border-color: #709866; outline: 2px solid #e3eedc; }
input[readonly] { background: #f7f9f5; }
.primary, .secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 46px;
  padding: 11px 15px;
  border: 1px solid var(--green);
  border-radius: 7px;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s;
}
.primary:hover:not(:disabled) { background: #236148; }
.primary svg, .secondary svg { width: 17px; height: 17px; }
.secondary { margin-bottom: 10px; background: #fff; border-color: #dce3db; color: var(--green); }
.secondary:hover:not(:disabled) { background: #f4f7f0; }
.signin-divider { display: flex; align-items: center; gap: 16px; margin: 24px 0; color: var(--muted); font-size: 12px; }
.signin-divider::before, .signin-divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.social-signin { display: grid; gap: 10px; }
.android-download { width: min(100%, 520px); margin: 0 auto; padding: 20px 24px 28px; border-top: 1px solid var(--line); text-align: center; }
.android-download a { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); font-size: 14px; font-weight: 600; text-underline-offset: 4px; }
.android-download p { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.setup-download { width: 100%; margin: 16px 0; padding: 12px 0; border-top: 0; text-align: left; }
.social-button {
  display: grid;
  grid-template-columns: 20px 1fr 20px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 11px 15px;
  border: 1px solid #dce3db;
  border-radius: 7px;
  background: #fff;
  color: var(--body);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s;
}
.social-button:hover:not(:disabled) { background: #f4f7f0; }
.social-button svg { width: 18px; height: 18px; stroke: none; }
.mini-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #f0f5eb;
  color: #42694d;
}
.mini-icon svg { width: 18px; height: 18px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #87ad75; flex-shrink: 0; }
.factor-status { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.factor-status strong { display: block; font-size: 14px; font-weight: 550; }
.factor-status div > span { display: block; font-size: 12px; color: var(--muted); }
.factor-status > .status-dot { margin-left: auto; }
#permission-description { margin: 0 0 20px; }
.replace-phone-button { margin-top: 14px; }
.pairing { margin: 0 0 20px; }
.pair-qr { width: min(100%, 248px); margin: 0 auto 18px; }
.pair-qr svg { display: block; width: 100%; height: auto; stroke: none; shape-rendering: crispEdges; }
.pair-instruction { margin: 0 0 8px; font-size: 13px; text-align: center; color: var(--muted); }
.fineprint { margin: 0; font-size: 12px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.pair-manual { margin-top: 18px; font-size: 12px; color: var(--muted); }
.pair-manual summary { cursor: pointer; }
.pair-manual[open] summary { margin-bottom: 16px; }
.pair-manual input { margin-bottom: 12px; font-size: 13px; }
.section-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.timer { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#challenge-message { margin: 12px 0 20px; }
.challenge-actions { display: grid; gap: 10px; }
.challenge-actions .text-button { justify-self: center; }

/* Apps and dialogs keep the same restrained presentation. */
.apps-dashboard { max-width: 860px; margin: 0 auto; padding: 48px 24px 64px; }
.apps-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.primary.add-app-button { width: auto; min-width: 108px; gap: 18px; min-height: 42px; }
.add-app-button > span { font-size: 20px; line-height: 1; }
.dashboard-authenticator { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.authenticator-info { flex: 1; min-width: 0; }
.authenticator-info strong { font-weight: 550; overflow-wrap: anywhere; }
.badge { color: var(--muted); font-size: 12px; }
.connected-apps-heading { margin-bottom: 12px; }
.site-count { color: var(--muted); font-size: 12px; }
.connected-sites { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.connected-sites li { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 14px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 9px; }
.site-icon { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px; background: #edf3e7; color: var(--green); font-size: 16px; font-weight: 600; }
.site-info { min-width: 0; }
.connected-sites strong { display: block; font-size: 14px; font-weight: 550; overflow-wrap: anywhere; }
.connected-sites small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.apps-empty { padding: 48px 0; text-align: center; color: var(--muted); }
.apps-empty p { margin: 0; }
.app-dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--body); box-shadow: 0 20px 70px #153c3026; }
.app-dialog::backdrop { background: #153c304d; }
.app-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.app-dialog > .muted { margin: 16px 0 24px; }
#app-form { margin-top: 24px; }
.dialog-close { width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 24px; }
.optional-label { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
.phone-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.phone-dialog-actions .secondary { margin: 0; justify-content: center; }
.replacement-qr-dialog { width: min(470px, calc(100% - 32px)); }
.replacement-pairing { margin: 0; }

/* Key-toss loading scene: phone throws its key to the computer */
.key-toss {
  padding: 8px 0;
  margin: 0 0 24px;
  transition: opacity .25s;
}

.key-toss[data-mode="rest"] {
  opacity: .62;
}

.key-toss-art {
  display: block;
  width: 100%;
  height: auto;
  color: #366146;
  stroke-width: 1.7;
  overflow: visible;
}

.key-toss-art rect, .key-toss-art circle {
  fill: #fbfcf8;
}

.key-toss-art .kt-flight {
  stroke: none;
}

.key-toss-art .kt-arc {
  stroke: #a3bf96;
  stroke-width: 2.3;
  stroke-dasharray: .1 7.5;
}

.key-toss-art .kt-trail {
  stroke: #4d8a5e;
  stroke-width: 1.6;
  opacity: 0;
}

.key-toss-art .kt-phone {
  transform-origin: 44px 100px;
}

.key-toss-art .kt-phone-screen, .key-toss-art .kt-screen {
  fill: #eef5e6;
  stroke: none;
}

.key-toss-art .kt-laptop {
  transform-origin: 280px 60px;
}

.key-toss-art .kt-base, .key-toss-art .kt-lock-body {
  fill: #366146;
  stroke: none;
}

.key-toss-art .kt-shackle {
  transform-origin: 286px 54px;
}

.key-toss-art .kt-keyhole {
  stroke: #e5f0d9;
  stroke-width: 2;
}

.key-toss-art .kt-key {
  color: #255239;
  stroke-width: 2.1;
  transform: translate(44px, 60px);
}

.key-toss-art .kt-key circle {
  fill: #d9f1c7;
}

.key-toss-art .kt-success, .key-toss-art .kt-error {
  opacity: 0;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.key-toss-art .kt-success { transform-origin: 280px 57px; }
.key-toss-art .kt-error { transform-origin: 44px 60px; }
.key-toss-art .kt-success circle { fill: #32864b; stroke: none; }
.key-toss-art .kt-error circle { fill: #c63e3e; stroke: none; }

/* Keep sign-in content visible throughout the card's size transition. */
#dashboard-view:not([hidden]) {
  animation: screen-in .24s cubic-bezier(.2, .7, .3, 1);
}
.app-dialog[open] { animation: dialog-in .2s cubic-bezier(.2, .7, .3, 1); }
.app-dialog[open]::backdrop { animation: content-in .2s ease-out; }
.primary svg, .secondary svg { transition: transform .15s ease-out; }
.primary:hover:not(:disabled) svg, .secondary:hover:not(:disabled) svg { transform: translateX(2px); }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes content-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 540px) {
  .topbar { height: 64px; padding: 0 20px; }
  .brand { font-size: 23px; }
  .signin-page { min-height: calc(100dvh - 64px); padding: 24px 20px; }
  .apps-dashboard { padding: 32px 20px 48px; }
  .login-card { padding: 24px; }
  #pairing .pair-qr { max-width: 220px; }
  h1 { font-size: 26px; }
  h2 { font-size: 22px; }
  .dashboard-replace-phone-button { margin-left: 46px; }
  .app-dialog { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .primary:hover:not(:disabled) svg, .secondary:hover:not(:disabled) svg { transform: none; }
}
