:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0d0f13;
  color: #f5f5f7;
  -webkit-font-smoothing: antialiased;
  --muted: #aeb1bc;
  --border: #292b32;
  --surface: #16181e;
  --accent: #ff5262;
  --positive: #64e5b1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  background: radial-gradient(ellipse at 68% 0, #26191e 0, #0d0f13 58%);
}

.hidden {
  display: none !important;
}

.app {
  width: min(100%, 28rem);
  margin-inline: auto;
  /* Telegram's fullscreen controls sit below the device's status bar. */
  padding:
    calc(
      1rem + max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px))
      + var(--tg-content-safe-area-inset-top, 0px)
    )
    max(1.25rem, env(safe-area-inset-right), var(--tg-content-safe-area-inset-right, 0px))
    max(1.25rem, env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px))
    max(1.25rem, env(safe-area-inset-left), var(--tg-content-safe-area-inset-left, 0px));
}

.brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin-bottom: .875rem;
  font-weight: 750;
  letter-spacing: -.025em;
}

.brand-mark {
  display: block;
  width: 2.125rem;
  height: 2.125rem;
  flex: none;
  object-fit: cover;
  border-radius: .65rem;
}

.recovery-panel {
  margin-top: .875rem;
}

.recovery-panel h2 {
  margin: 0;
  font-size: 1.15rem;
}

.recovery-panel p {
  color: var(--muted);
  line-height: 1.45;
  margin: .5rem 0 .85rem;
}

.help-footer {
  margin-top: .6rem;
  text-align: center;
}

.help-footer a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--muted);
  text-underline-offset: .2em;
}

.connection-state {
  display: none;
  margin-left: auto;
  color: #ffb673;
  font-size: .825rem;
  letter-spacing: normal;
}

.connection-state.offline {
  display: inline;
}

.flow-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .45rem;
  margin: 0 0 .9rem;
  padding: 0;
  list-style: none;
}

.flow-progress li {
  padding: .45rem .1rem .55rem;
  border-bottom: 2px solid #34343e;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
  text-align: center;
}

.flow-progress .active {
  border-color: var(--accent);
  color: #fff;
}

.flow-progress .done {
  border-color: var(--positive);
  color: var(--positive);
}

.outside-telegram .flow-progress, .outside-telegram #code-screen {
  display: none;
}

.telegram-entry p {
  color: var(--muted);
  line-height: 1.45;
}

.telegram-entry a {
  text-decoration: none;
}

.scan-icon {
  --line: linear-gradient(currentColor, currentColor);
  --corner: 38%;
  width: 1rem;
  height: 1rem;
  color: #ff7a85;
  background:
    var(--line) top left / var(--corner) 2px no-repeat,
    var(--line) top left / 2px var(--corner) no-repeat,
    var(--line) top right / var(--corner) 2px no-repeat,
    var(--line) top right / 2px var(--corner) no-repeat,
    var(--line) bottom left / var(--corner) 2px no-repeat,
    var(--line) bottom left / 2px var(--corner) no-repeat,
    var(--line) bottom right / var(--corner) 2px no-repeat,
    var(--line) bottom right / 2px var(--corner) no-repeat,
    var(--line) center / 70% 1px no-repeat;
}

.instructions {
  margin: 1.4rem 0 1rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.85rem, 7.4vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -.055em;
  line-height: 1.08;
  text-wrap: balance;
}

.instructions p, .operation-copy p, .complete-card > p {
  margin: .55rem 0 0;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.field-label {
  display: block;
  margin-bottom: .35rem;
  font-size: .85rem;
  font-weight: 700;
}

.code-control {
  display: flex;
  align-items: center;
  min-height: 3.1rem;
  padding: 0 .875rem;
  border: 1px solid #3a3d47;
  border-radius: .8rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 1.13rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.code-control:focus-within {
  border-color: #ff7a85;
  box-shadow: 0 0 0 2px #ff52622e;
}

.code-control input {
  width: 100%;
  min-width: 0;
  padding: .6rem .3rem;
  border: 0;
  background: transparent;
  color: #f5f5f7;
  outline: none;
  font: inherit;
}

.code-control input::placeholder {
  color: #9297a3;
}

.entry-actions, .proof-area {
  display: grid;
  gap: .55rem;
  margin-top: .65rem;
}

.primary-action, .secondary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  width: 100%;
  min-height: 3.1rem;
  padding: .7rem .85rem;
  border: 1px solid transparent;
  border-radius: .8rem;
  font: inherit;
  font-size: .94rem;
  font-weight: 780;
  text-align: center;
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.primary-action {
  border-color: #ff7280;
  background: var(--accent);
  color: #1a0e12;
  box-shadow: 0 .4rem 1.25rem #ff526227;
}

.secondary-action {
  border-color: #3b3e49;
  background: #1b1e26;
  color: #f5f5f7;
}

.primary-action:disabled, .secondary-action:disabled {
  opacity: .52;
  box-shadow: none;
  cursor: default;
}

:focus-visible,
.visually-hidden:focus-visible + .photo-picker {
  outline: 2px solid #f7c4cb;
  outline-offset: 3px;
}

.form-message {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.45;
}

.form-message:not(:empty) {
  margin-top: .55rem;
}

.error-message {
  color: #ffadb6;
}

.panel {
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  background: var(--surface);
}

.box-line, .session-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .55rem;
}

.box-line strong {
  display: block;
}

.demo-label {
  display: block;
  margin-top: .2rem;
  color: var(--muted);
  font-size: .75rem;
}

.door-pill {
  padding: .35rem .6rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  color: var(--muted);
  font-size: .75rem;
  text-align: center;
}

.door-pill.closed {
  background: #173125;
  color: #a6f1ce;
}

.door-pill.open {
  background: #3b242b;
  color: #ffb0bb;
}

.operation-copy, .complete-card {
  text-align: center;
}

.operation-copy {
  margin: 1.35rem 0 1rem;
}

.state-visual {
  display: grid;
  width: 3.75rem;
  aspect-ratio: 1;
  place-items: center;
  margin: 0 auto .85rem;
  border: 1px solid #623440;
  border-radius: 1rem;
  background: #39242e;
  color: #ff8d98;
  font-size: 1.8rem;
  font-weight: 750;
}

.state-visual.awaiting_photo, .state-visual.completed {
  border-color: #315e4d;
  background: #173125;
  color: var(--positive);
}

.state-visual.needs_admin {
  border-color: #5c4630;
  background: #36291e;
  color: #ffb673;
}

.session-footer {
  margin-top: 1rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

.photo-preview-wrap {
  display: grid;
  gap: .5rem;
}

.photo-preview-wrap img {
  display: block;
  width: 100%;
  max-height: 10rem;
  object-fit: contain;
  border-radius: .65rem;
  background: #0d0f13;
}

.proof-area:has(.photo-preview-wrap:not(.hidden)) .photo-picker {
  display: none;
}

.complete-card button {
  margin-top: 1.15rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

