@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist/Geist-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist/Geist-Italic.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: italic;
  font-display: block;
}

html, body, button, input, textarea, select { font-family: "Geist", ui-sans-serif, system-ui, sans-serif; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: #f4f0e8;
}

body:has(.login:not([hidden]))::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: -30vh 0;
  background:
    radial-gradient(circle at 75% 25%, #f8c9a4 0, transparent 34%),
    radial-gradient(circle at 20% 72%, #c8ddc2 0, transparent 36%),
    #f4f0e8;
}

body:has(.login:not([hidden])) > main {
  position: relative;
  z-index: 1;
}

.login {
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
}

html[data-theme="dark"] .login { background: transparent; }

.preferences .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;
}

.mark {
  overflow: hidden;
  border: 1px solid rgba(31, 42, 68, 0.14);
  background: #fff;
  box-shadow: 0 8px 22px rgba(31, 42, 68, 0.08);
}

.mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preferences {
  gap: .55rem;
}

.language-picker,
.theme-footer {
  position: relative;
  width: 2.35rem;
  height: 2.35rem;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.preference-current {
  width: 2.35rem;
  height: 2.35rem;
  display: inline-grid;
  place-items: center;
  padding: 2px 0;
  border: 1px solid rgba(31, 42, 68, 0.16);
  border-radius: 999px;
  background: #fff;
  color: #596273;
  box-shadow: 0 10px 28px rgba(31, 42, 68, 0.08);
  cursor: pointer;
  font-size: 1rem;
  touch-action: manipulation;
}

.preference-current:hover,
.preference-current:focus-visible {
  background: #f4f7fc;
  color: #24221e;
  outline: none;
}

.preference-menu,
.theme-footer .theme-picker {
  position: absolute;
  right: 0;
  bottom: calc(100% + .55rem);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transform: translateY(.35rem) scale(.98);
  transform-origin: bottom right;
  transition: opacity 170ms ease, transform 210ms ease;
}

.language-picker.open .preference-menu,
.theme-footer.open .theme-picker {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.preference-menu {
  min-width: 11.5rem;
  display: grid;
  gap: .18rem;
  padding: .35rem;
  border: 1px solid rgba(31, 42, 68, 0.14);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(31, 42, 68, 0.18);
}

.preference-menu button {
  min-height: 2.1rem;
  display: flex;
  align-items: center;
  gap: .52rem;
  padding: 0 .58rem;
  border: 0;
  border-radius: .65rem;
  background: transparent;
  color: #24221e;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 800;
  text-align: left;
}

.preference-menu button:hover,
.preference-menu button:focus-visible {
  background: rgba(31, 42, 68, 0.07);
  outline: none;
}

.preference-menu button.active {
  background: rgba(29, 155, 240, 0.13);
  color: #126aaf;
}

.theme-footer .theme-picker {
  width: max-content;
  height: 2.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: .18rem;
  border: 1px solid rgba(31, 42, 68, 0.12);
  border-radius: 999px;
  background: #e8ebf0;
  box-shadow: inset 0 1px 2px rgba(31, 42, 68, 0.08);
  box-sizing: border-box;
  overflow: visible;
  touch-action: manipulation;
}

.theme-footer .theme-picker button {
  min-width: 5rem;
  height: 2.05rem;
  padding: 0 .68rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .32rem;
  background: transparent;
  color: #596273;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 800;
  line-height: 1;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
  flex: 0 0 5rem;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.theme-footer .theme-picker button.active {
  background: #fff;
  color: #172033;
  box-shadow: 0 2px 8px rgba(31, 42, 68, 0.14);
}

html[data-theme="dark"] body,
html[data-theme="dark"] body:has(.login:not([hidden]))::before {
  background:
    radial-gradient(circle at 75% 25%, #6a4130 0, transparent 36%),
    radial-gradient(circle at 20% 72%, #324a35 0, transparent 38%),
    #191815;
}

html[data-theme="dark"] .preference-current,
html[data-theme="dark"] .preference-menu {
  border-color: rgba(255, 255, 255, 0.22);
  background: #141826;
  color: #fff;
  box-shadow: none;
}

html[data-theme="dark"] .theme-footer .theme-picker {
  border-color: rgba(255,255,255,.22);
  background: rgba(20,24,38,.96);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.25);
}

html[data-theme="dark"] .theme-footer .theme-picker button { color: rgba(255,255,255,.7); }
html[data-theme="dark"] .theme-footer .theme-picker button.active {
  background: #fff;
  color: #172033;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
}

html[data-theme="dark"] #theme-toggle,
html[data-theme="dark"] #theme-toggle .fa-solid {
  color: #fff;
  opacity: 1;
  visibility: visible;
}

html[data-theme="dark"] .preference-menu button {
  color: #fff;
}

html[data-theme="dark"] .preference-menu button:hover,
html[data-theme="dark"] .preference-menu button:focus-visible {
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 800px) {
  .preferences { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); }
}

/* The login canvas intentionally continues below the visual viewport so Safari's
   collapsing browser chrome and overscroll never reveal a hard background edge. */
html:has(.login:not([hidden])),
body:has(.login:not([hidden])) {
  min-height: 125vh;
  min-height: 125dvh;
  background:
    radial-gradient(circle at 75% 20%, #f8c9a4 0, transparent 34%),
    radial-gradient(circle at 20% 67%, #c8ddc2 0, transparent 36%),
    #f4f0e8;
}

body:has(.login:not([hidden]))::before { display: none; }

.login {
  min-height: 125vh;
  min-height: 125dvh;
  align-items: start;
  padding-top: clamp(90px, 12dvh, 150px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.3rem;
}

.brand-lockup strong {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  color: #292721;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 48px;
  text-transform: uppercase;
}

.brand-lockup + h1 { margin-top: 0; }

.theme-footer .theme-picker {
  bottom: 0;
  transform: translateX(.4rem) scale(.94);
  transition: opacity 180ms ease, transform 220ms ease;
}

.theme-footer.expanded { z-index: 50; }

.theme-footer.expanded .theme-picker {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.theme-footer .preference-current {
  transition: opacity 180ms ease, transform 220ms ease;
}

.theme-footer.expanded .preference-current {
  opacity: 0;
  pointer-events: none;
  transform: translateX(.35rem) scale(.92);
}

html[data-theme="dark"] .brand-lockup strong { color: #eee9df; }

html[data-theme="dark"] .login form > button {
  background: #f4f0e8;
  color: #191815;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .28), 0 10px 26px rgba(0, 0, 0, .24);
}

.login form > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .62rem;
  transition: background 160ms ease, color 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.login-submit-icon {
  width: 1em;
  flex: 0 0 1em;
  color: currentColor;
}

.login form > button[data-login-submit-state="sending"] .login-submit-icon {
  animation: loginSubmitSpin .8s linear infinite;
}

.login form > button:disabled {
  cursor: not-allowed;
  background: #d7d1c6;
  color: #656057;
  opacity: 1;
  box-shadow: none;
}

.login form > button[data-login-submit-state="success"]:disabled {
  background: #dce9dc;
  color: #245c35;
}

html[data-theme="dark"] .login form > button:disabled {
  background: #5b584f;
  color: #d8d3c9;
  box-shadow: none;
}

html[data-theme="dark"] .login form > button[data-login-submit-state="success"]:disabled {
  background: #d8eadc;
  color: #174d2a;
}

@keyframes loginSubmitSpin { to { transform: rotate(360deg); } }

.login .status { text-align: center; }

html[data-theme="dark"] .login .status { color: #c9c4bb; }

html[data-theme="dark"]:has(.login:not([hidden])),
html[data-theme="dark"] body:has(.login:not([hidden])) {
  background:
    radial-gradient(circle at 75% 20%, #6a4130 0, transparent 36%),
    radial-gradient(circle at 20% 67%, #324a35 0, transparent 38%),
    #191815;
}

@media (max-width: 560px) {
  .login form > button {
    width: 100%;
    flex: 0 0 100%;
  }
}

/* One crisp, shared preference control group in the top-right on every page. */
body > .preferences {
  position: fixed;
  top: 10px;
  right: 14px;
  bottom: auto;
  z-index: 80;
  display: flex !important;
}

.preference-current {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #c8c4bb;
  border-radius: 50%;
  background: #fff;
  box-shadow: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.preference-current:hover,
.preference-current:focus-visible {
  border-color: #827d73;
  background: #f7f5f0;
  transform: translateY(-1px);
  box-shadow: none;
}

.preferences .preference-menu {
  top: calc(100% + .55rem);
  bottom: auto;
  transform-origin: top right;
}

html[data-theme="dark"] .preference-current {
  border-color: #555149;
  background: #24221e;
  color: #f2ede4;
  box-shadow: none;
}

html[data-theme="dark"] .preference-current:hover,
html[data-theme="dark"] .preference-current:focus-visible {
  border-color: #8a8479;
  background: #302e29;
}

.workspace header .actions { margin-right: 0; }
body:has(.workspace:not([hidden])) > .preferences { right: 86px; }
.preview-footer { display: none !important; }

@media (max-width: 800px) {
  body > .preferences { top: 10px; right: 10px; bottom: auto; }
  body:has(.workspace:not([hidden])) > .preferences { right: 82px; }
  .workspace header .actions { margin-right: 0; }
}
