@font-face {
  font-family: "Geist";
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/geist-sans@latest/latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Geist";
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/geist-sans@latest/latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Geist";
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/geist-sans@latest/latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Geist Mono";
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/geist-mono@latest/latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --border: #232326;
  --text: #f5f5f5;
  --muted: #8b8b8f;
  --accent: #ff8a3d;
  --danger: #f87171;
  --success: #4ade80;
  --radius-control: 6px;
  --radius-card: 10px;
  --font-sans: "Geist", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e4e4e7;
  --text: #18181b;
  --muted: #71717a;
  --accent: #ea580c;
  --danger: #dc2626;
  --success: #16a34a;
  color-scheme: light;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: rgb(255 138 61 / 0.18);
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.skip {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  text-decoration: none;
  transform: translateY(-120%);
}

.skip:focus {
  transform: none;
}

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

.theme-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  cursor: pointer;
}

.theme-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.theme-btn:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible,
.tabs button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: block;
  flex-shrink: 0;
}

.logo-lg {
  width: 56px;
  height: 56px;
  border-radius: 12px;
}

.wordmark {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
  line-height: 1;
}

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

.brand-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-product {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

.auth {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 24px 20px 32px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

.auth-aside {
  margin: 0 auto 32px;
  max-width: 400px;
  width: 100%;
}

.auth-aside-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-main {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 8px 20px 24px;
}

.tabs {
  display: flex;
  gap: 0;
  margin: 0 -8px 24px;
  border-bottom: 1px solid var(--border);
}

.tabs button {
  flex: 1;
  min-height: 44px;
  padding: 10px 8px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 14px;
  font-weight: 600;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 44px;
}

.icon-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
}

.icon-btn:hover {
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 10px 12px;
}

input,
select {
  height: 44px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(0.92);
}

[data-theme="light"] .btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.auth-form .btn-primary {
  width: 100%;
  margin-top: 4px;
}

.err {
  margin: 0;
  min-height: 1.2em;
  color: var(--danger);
  font-size: 14px;
}

.err:empty {
  display: none;
}

.banner {
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-control);
  color: var(--danger);
  font-size: 14px;
}

.app {
  min-height: 100dvh;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  padding-top: max(24px, env(safe-area-inset-top));
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.who {
  font-size: 14px;
  font-family: var(--font-mono);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-bar-end {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.msg {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  cursor: pointer;
  font-size: 14px;
}

.msg.unread {
  font-weight: 600;
}

.status {
  color: var(--muted);
  font-size: 14px;
  font-family: var(--font-mono);
}

@media (min-width: 880px) {
  .auth {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(360px, 440px);
    align-items: center;
    gap: 48px;
    padding: 48px 64px;
    padding-right: max(64px, env(safe-area-inset-right));
  }

  .theme-btn {
    position: absolute;
    top: max(24px, env(safe-area-inset-top));
    right: max(24px, env(safe-area-inset-right));
  }

  .auth-aside {
    margin: 0;
    max-width: 360px;
    justify-self: end;
    padding-right: 16px;
  }

  .auth-main {
    margin: 0;
    justify-self: start;
  }

  .wordmark {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .auth-form {
    animation: auth-in 160ms ease-out;
  }

  @keyframes auth-in {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}
