:root {
  --bg: #f5f6f7;
  --ink: #1a1d21;
  --muted: #5e676f;
  --line: #cfd4d9;
  --err: #8a3030;
  --ok: #1f7a44;
  --paper: #ffffff;
}

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

html {
  color-scheme: light;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 24px;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.top {
  margin: 0;
  padding: 24px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
}

main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 10vh 0 48px;
  overflow-wrap: break-word;
}

h1 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.2;
}

h2 {
  margin: 28px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lead {
  margin: 0 0 36px;
  color: var(--muted);
}

.lead strong {
  color: var(--ink);
  font-weight: 600;
}

.err {
  margin: -18px 0 28px;
  color: var(--err);
  overflow-wrap: anywhere;
}

.quiet {
  color: var(--muted);
}

form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 24px;
  min-width: 0;
}

label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}

input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  font: inherit;
}

input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  box-shadow: 0 0 0 1000px var(--bg) inset;
}

textarea {
  width: 100%;
  min-height: 88px;
  margin: 0;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  background: var(--paper);
}

button {
  align-self: flex-start;
  height: 44px;
  margin: 4px 0 0;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: none;
  color: var(--paper);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

a {
  color: var(--ink);
  text-underline-offset: 0.2em;
}

@media (min-width: 641px) {
  body {
    padding-left: 10vw;
    padding-right: 10vw;
  }

  .top {
    padding-top: 36px;
  }

  main {
    max-width: 400px;
    padding-top: 14vh;
    padding-bottom: 80px;
  }

  h1 {
    font-size: 34px;
  }
}

.btn.solid,
.btn.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  margin: 0;
  padding: 0 22px;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn.solid {
  border: 0;
  background: var(--ink);
  color: var(--paper);
}

.btn.ghost {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.btn.solid:active,
button:not(.back):active {
  background: #000000;
  opacity: 0.92;
  transition: none;
}

.btn.ghost:active {
  background: #e6eaee;
  opacity: 0.92;
  transition: none;
}

@media (prefers-reduced-motion: no-preference) {
  .btn.solid,
  .btn.ghost,
  button:not(.back) {
    transition: background 0.2s ease, border-color 0.2s ease;
  }

  .btn.solid:hover,
  .btn.ghost:hover,
  button:not(.back):hover {
    border-color: #e6eaee;
  }
}

/* Submit spinner: swap the label for a spinning ring while a POST is in flight. */
.btn-spin {
  display: none;
}

.btn.is-loading {
  pointer-events: none;
}

.btn.is-loading .btn-label {
  display: none;
}

.btn.is-loading .btn-spin {
  display: block;
  animation: btn-spin 0.6s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* Toast: fixed bottom-right. Errors red, confirmations green. */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 13px 14px 13px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 10px 30px rgba(26, 29, 33, 0.22);
  font-size: 15px;
  line-height: 1.35;
  animation: toast-in 0.26s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.toast--err {
  background: #c62828;
  box-shadow: 0 10px 30px rgba(198, 40, 40, 0.28);
}

.toast--ok {
  background: var(--ok);
  box-shadow: 0 10px 30px rgba(31, 122, 68, 0.26);
}

.toast.is-leaving {
  animation: toast-out 0.22s ease forwards;
}

.toast-msg {
  flex: 1 1 auto;
  min-width: 0;
}

.toast-x {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  opacity: 0.7;
  cursor: pointer;
}

.toast-x:active {
  opacity: 1;
}

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

@keyframes toast-out {
  to { opacity: 0; transform: translateY(14px); }
}

/* Small round ghost button (e.g. close a session). */
.iconbtn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.iconbtn:hover {
  border-color: var(--err);
  color: var(--err);
}

.iconbtn:active {
  background: #f3eded;
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

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

.talk {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #f7f8f9;
}

.talk-bar {
  flex: 0 0 auto;
  padding: 14px 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.talk-bar h1 {
  margin: 0;
  font-size: 18px;
}

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 14px 8px;
}

.thread .empty {
  margin: auto;
}

.bubble {
  align-self: flex-start;
  max-width: min(78%, 520px);
  padding: 8px 10px 6px;
  border-bottom: 0;
  border-radius: 16px 16px 16px 4px;
  background: var(--paper);
}

.bubble.mine {
  align-self: flex-end;
  border-radius: 16px 16px 4px 16px;
  background: var(--ink);
  color: var(--paper);
}

.bubble .who {
  margin: 0 0 2px;
  color: #3d6f8f;
  font-size: 13px;
  font-weight: 600;
}

.bubble .text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.bubble.mine time {
  color: #c5c8cc;
}

.composer {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
  padding: 10px 12px 12px;
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  border: 0;
  border-radius: 22px;
  background: #eef0f2;
  resize: none;
}

button.send {
  display: grid;
  place-items: center;
  align-self: flex-end;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
}

.talk .err {
  margin: 0;
  padding: 8px 14px 0;
}

body.desk {
  padding: 0;
  background: #e7eaed;
}

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 20px 16px;
  background: #f5f6f7;
  border-bottom: 1px solid var(--line);
}

.side-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.side-user {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
}

.menu a,
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: var(--ink);
  font-size: inherit;
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
  text-decoration: none;
}

.menu svg {
  flex: 0 0 auto;
  color: var(--muted);
}

.side-mark {
  display: block;
  width: 120px;
  height: auto;
  margin: 8px 12px 0;
  color: var(--ink);
}

.menu a[aria-current="page"],
.menu button[aria-current="page"] {
  border-left-color: var(--ink);
  background: var(--paper);
  font-weight: 600;
}

.menu a[aria-current="page"] svg,
.menu button[aria-current="page"] svg {
  color: var(--ink);
}

.menu button:active {
  background: var(--paper);
  opacity: 1;
}

.nest {
  display: flex;
  flex-direction: column;
  margin: 0 0 6px 12px;
}

.nest a,
.nest button {
  padding: 6px 12px;
  color: var(--muted);
  font-size: 15px;
}

.side form {
  margin-top: auto;
}

main.pane {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: auto;
  max-width: none;
  margin: 0;
  padding: 28px 22px 64px;
  background: var(--paper);
}

main.pane > * {
  width: 100%;
  max-width: 640px;
}

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

.view-head {
  margin: 0 0 18px;
}

.view-head h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Profile */
.stat {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.stat-num {
  color: var(--ink);
  font-size: 64px;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.85;
}

.stat-word {
  color: var(--muted);
  font-size: 15px;
}

.block {
  margin-top: 26px;
}

.sessions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.session {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7f8f9;
}

.session.is-current {
  border-color: var(--ink);
  background: var(--paper);
}

.session-main {
  flex: 1 1 auto;
  min-width: 0;
}

.session-device {
  margin: 0 0 3px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.session-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.session-del {
  display: contents;
}

/* Chat fills the pane. */
body.show-chat .shell {
  height: 100dvh;
  overflow: hidden;
}

body.show-chat main.pane {
  flex: 1;
  align-self: stretch;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

body.show-chat main.pane > .view[data-view="chat"] {
  display: flex;
  flex: 1;
  flex-direction: column;
  max-width: none;
  min-height: 0;
}

body.show-chat main.pane > .view[data-view="chat"] > .talk {
  max-width: none;
  flex: 1;
  min-height: 0;
}

@media (min-width: 641px) {
  main.pane {
    padding: 48px 56px 88px;
  }

  .stat-num {
    font-size: 84px;
  }
}

@media (min-width: 860px) {
  .shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    align-items: stretch;
  }

  .side {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px 16px 22px;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }

  .side-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 0 12px;
  }

  main.pane {
    min-height: 100vh;
    padding: 56px 64px 96px;
  }
}

body.gate {
  min-height: 100vh;
  margin: 0;
  padding: 28px 24px 72px;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  color-scheme: light;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body.gate * {
  -webkit-tap-highlight-color: transparent;
}

body.gate *::selection {
  background: transparent;
  color: inherit;
}

body.gate *::-moz-selection {
  background: transparent;
  color: inherit;
}

body.gate button:focus,
body.gate button:focus-visible,
body.gate a:focus,
body.gate a:focus-visible {
  outline: none;
  outline-offset: 0;
}

body.gate main {
  width: min(920px, 100%);
  max-width: none;
  margin: 0 auto;
  padding: 0;
}

.hen-frame {
  height: min(36vh, 300px);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.hen-hero {
  display: block;
  width: auto;
  height: calc(min(36vh, 300px) * 1.7);
  max-width: none;
  max-height: none;
  margin: 0;
  object-fit: cover;
  object-position: center top;
  background: transparent;
}

.gate-rule {
  height: 1px;
  margin: 0 0 24px;
  border: 0;
  background: var(--line);
}

.gate-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.gate-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.gate-head h1 {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
}

.gate-head p {
  display: grid;
  flex: 0 1 280px;
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
  text-align: right;
}

.gate-head h1 > span,
.gate-head p > span {
  grid-area: 1 / 1;
  transition: opacity 0.28s ease;
}

.copy-open {
  opacity: 0;
  pointer-events: none;
}

body.is-open .copy-home {
  opacity: 0;
  pointer-events: none;
}

body.is-open .copy-open {
  opacity: 1;
  pointer-events: auto;
}

.gate-actions,
.gate-fold {
  display: grid;
  transition: grid-template-rows 0.42s cubic-bezier(0.4, 0, 0.2, 1);
}

.gate-actions { grid-template-rows: 1fr; }
.gate-fold { grid-template-rows: 0fr; }
body.is-open .gate-actions { grid-template-rows: 0fr; }
body.is-open .gate-fold { grid-template-rows: 1fr; }

.gate-actions > .clip,
.gate-fold > .clip {
  min-height: 0;
  overflow: hidden;
}

.gate-actions > .clip {
  opacity: 1;
  transition: opacity 0.2s ease 0.14s;
}

body.is-open .gate-actions > .clip {
  opacity: 0;
  transition: opacity 0.16s ease;
}

.gate-fold > .clip {
  opacity: 0;
  transition: opacity 0.16s ease;
}

body.is-open .gate-fold > .clip {
  opacity: 1;
  transition: opacity 0.24s ease 0.16s;
}

.gate-row,
.gate-fold form {
  display: flex;
  gap: 16px;
}

.gate-row { flex-direction: row; }
.gate-fold form { flex-direction: column; padding-top: 2px; }

.gate-actions .btn {
  flex: 1 1 auto;
  width: auto;
  min-height: 52px;
}

.back {
  display: grid;
  place-items: center;
  flex: 0 0 0px;
  width: 0;
  height: 44px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  line-height: 0;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: flex-basis 0.42s cubic-bezier(0.4, 0, 0.2, 1), width 0.42s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.16s ease;
}

.back svg {
  display: block;
}

body.is-open .back {
  flex-basis: 44px;
  width: 44px;
  opacity: 1;
  pointer-events: auto;
  transition: flex-basis 0.42s cubic-bezier(0.4, 0, 0.2, 1), width 0.42s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.24s ease 0.1s;
}

.token-field {
  position: relative;
  width: 100%;
}

.token-field svg {
  position: absolute;
  left: 16px;
  top: 50%;
  color: var(--muted);
  transform: translateY(-50%);
}

.token-field input {
  height: 52px;
  padding: 0 18px 0 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  -webkit-user-select: text;
  user-select: text;
}

.token-field input::placeholder {
  color: var(--muted);
}

body.gate .token-field input::selection {
  background: #1a1d21;
  color: #ffffff;
}

body.gate .token-field input::-moz-selection {
  background: #1a1d21;
  color: #ffffff;
}

.token-field input:focus {
  border-color: var(--ink);
}

body.gate .err {
  margin: 0 0 14px;
  color: var(--err);
}

/* Captcha screen: just the image, the field and the button, centred. */
body.cap {
  margin: 0;
  min-height: 100vh;
  display: flex;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  color-scheme: light;
  -webkit-tap-highlight-color: transparent;
}

.cap-screen {
  margin: auto;
  padding: 0;
  width: 100%;
  max-width: 320px;
}

.cap-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.cap-img {
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(26, 29, 33, 0.16);
}

.cap-input {
  width: 100%;
  min-height: 52px;
  height: 52px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3em;
}

.cap-input::placeholder {
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.02em;
}

.cap-input:focus {
  outline: none;
  border-color: var(--ink);
}

.cap-form .btn.solid {
  width: 100%;
}

.cap-link {
  height: auto;
  margin: 0;
  padding: 4px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
}

.cap-link:active {
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  .gate-actions,
  .gate-fold,
  .back,
  .gate-actions > .clip,
  .gate-fold > .clip,
  .gate-head h1 > span,
  .gate-head p > span {
    transition: none;
  }
}

@media (max-width: 720px), (max-height: 700px) {
  body.gate {
    padding-top: 10px;
    padding-bottom: 16px;
  }

  body.gate .gate-panel {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .gate-rule {
    margin-bottom: 12px;
  }

  .gate-head {
    margin-bottom: 12px;
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  body.gate {
    padding-left: 16px;
    padding-right: 16px;
  }

  .gate-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .gate-title {
    flex-basis: 100%;
    max-width: 100%;
  }

  .gate-head h1 {
    font-size: clamp(18px, 5vw, 26px);
    letter-spacing: 0;
    line-height: 1.12;
  }

  .gate-head p {
    flex-basis: 100%;
    max-width: 100%;
    margin-left: 0;
    text-align: left;
  }

  .gate-row,
  .gate-fold form {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .gate-row {
    flex-direction: column;
  }

  .gate-actions .btn,
  .gate-fold .btn,
  .token-field,
  .token-field input {
    flex: 0 0 auto;
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

@media (max-width: 720px) and (max-height: 700px) {
  body.gate {
    padding-top: 8px;
    padding-bottom: 12px;
  }

  .gate-rule {
    margin-bottom: 8px;
  }

  .gate-head {
    gap: 6px;
    margin-bottom: 8px;
  }

  .gate-head h1 {
    font-size: clamp(16px, 4.6vw, 22px);
  }

  .gate-head p {
    font-size: 13px;
    line-height: 1.3;
  }
}

