/* KvantHome auth / session chrome. Kept separate from the compiled app CSS so
   the original visual language stays untouched after the app is loaded. */

.kh-auth {
  --kh-bg: #f5efe1;
  --kh-paper: #fcfaf5;
  --kh-surface: #eee5d4;
  --kh-beige: #e5d3af;
  --kh-wine: #790d16;
  --kh-wine-deep: #5d0911;
  --kh-ink: #302d29;
  --kh-muted: #767169;
  --kh-line: #ded6c7;
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  overflow: auto;
  padding: clamp(18px, 4vw, 56px);
  color: var(--kh-ink);
  background:
    radial-gradient(900px 620px at 8% 6%, rgba(229, 211, 175, .68), transparent 62%),
    radial-gradient(780px 560px at 92% 94%, rgba(174, 196, 212, .5), transparent 64%),
    var(--kh-bg);
  font-family: "Manrope Variable", "Segoe UI", sans-serif;
}
.kh-auth::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: linear-gradient(rgba(48, 45, 41, .055) 1px, transparent 1px), linear-gradient(90deg, rgba(48, 45, 41, .055) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
}
.kh-auth.is-visible { display: block; }
.kh-auth-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  min-height: min(720px, calc(100vh - clamp(36px, 8vw, 112px)));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, .92fr);
  overflow: hidden;
  border: 1px solid rgba(48, 45, 41, .12);
  border-radius: 30px;
  background: var(--kh-paper);
  box-shadow: 0 40px 100px -30px rgba(48, 45, 41, .45), 0 2px 0 rgba(255, 255, 255, .6) inset;
  animation: kh-rise .55s cubic-bezier(.2, .7, .25, 1) both;
}
@keyframes kh-rise { from { opacity: 0; transform: translateY(14px) scale(.992); } to { opacity: 1; transform: none; } }

.kh-auth-brand {
  position: relative;
  overflow: hidden;
  padding: clamp(32px, 4.2vw, 62px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  color: #fff7ea;
  background:
    radial-gradient(560px 460px at 78% 8%, rgba(255, 232, 197, .2), transparent 62%),
    radial-gradient(520px 500px at 6% 96%, rgba(31, 8, 10, .55), transparent 62%),
    linear-gradient(145deg, #8c1620 0%, var(--kh-wine) 52%, var(--kh-wine-deep) 100%);
}
.kh-auth-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .16;
  background-image: radial-gradient(rgba(255, 247, 234, .8) .7px, transparent .7px);
  background-size: 17px 17px;
  mask-image: linear-gradient(140deg, #000, transparent 68%);
}
.kh-auth-mark {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  font-size: 15px;
}
.kh-mark-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #f0c987;
  box-shadow: 0 0 0 5px rgba(240, 201, 135, .18), 0 0 26px rgba(240, 201, 135, .9);
}
.kh-auth-copy { position: relative; z-index: 2; max-width: 520px; }
.kh-eyebrow {
  margin: 0 0 18px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(255, 247, 234, .72);
}
.kh-auth-copy h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: clamp(38px, 4.7vw, 64px);
  line-height: 1.02;
  letter-spacing: -.035em;
  color: #fff9ee;
}
.kh-auth-copy h1 em { color: #f0c987; font-style: italic; }
.kh-lead {
  max-width: 440px;
  margin: 24px 0 0;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(255, 247, 234, .78);
}
.kh-auth-stats {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 247, 234, .2);
}
.kh-auth-stats div { display: flex; flex-direction: column; gap: 6px; }
.kh-auth-stats strong { font-size: 18px; font-weight: 700; color: #fff9ee; }
.kh-auth-stats span { font-size: 10px; line-height: 1.45; color: rgba(255, 247, 234, .62); }
.kh-auth-orbit {
  position: absolute;
  border: 1px solid rgba(240, 201, 135, .24);
  border-radius: 50%;
  pointer-events: none;
}
.kh-orbit-a { width: 430px; height: 430px; right: -210px; top: -160px; }
.kh-orbit-b { width: 640px; height: 640px; right: -300px; top: -250px; opacity: .55; }

.kh-auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(30px, 4vw, 54px);
  background: linear-gradient(180deg, #fcfaf5, #f8f2e7);
}
.kh-auth-panel-head { margin-bottom: 24px; }
.kh-auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 16px;
  padding: 6px 10px;
  border: 1px solid var(--kh-line);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--kh-muted);
  background: rgba(255, 255, 255, .55);
}
.kh-auth-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #5f7d54; box-shadow: 0 0 0 3px rgba(95, 125, 84, .14); }
.kh-auth-panel h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 500;
  letter-spacing: -.025em;
}
.kh-auth-panel-head p { margin: 10px 0 0; color: var(--kh-muted); font-size: 13px; line-height: 1.55; }
.kh-auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  border: 1px solid var(--kh-line);
  border-radius: 12px;
  background: var(--kh-surface);
}
.kh-auth-tabs button {
  border: 0;
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--kh-muted);
  background: transparent;
  cursor: pointer;
  transition: background .2s var(--kh-ease, ease), color .2s ease, box-shadow .2s ease;
}
.kh-auth-tabs button.is-active { color: var(--kh-ink); background: var(--kh-paper); box-shadow: 0 3px 10px rgba(48, 45, 41, .08); }
.kh-auth-tabs button:disabled { cursor: default; opacity: .7; }
#kh-auth-form { display: flex; flex-direction: column; gap: 14px; }
.kh-field { display: flex; flex-direction: column; gap: 7px; }
.kh-field > span { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--kh-muted); }
.kh-field input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--kh-line);
  border-radius: 11px;
  padding: 13px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--kh-ink);
  background: rgba(255, 255, 255, .72);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.kh-field input::placeholder { color: #a9a294; }
.kh-field input:focus { border-color: var(--kh-wine); background: #fff; box-shadow: 0 0 0 4px rgba(121, 13, 22, .1); }
.kh-field input:disabled { opacity: .65; }
.kh-auth-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(121, 13, 22, .18);
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.45;
  color: #8b1820;
  background: rgba(121, 13, 22, .055);
}
.kh-submit, .kh-demo {
  width: 100%;
  border-radius: 11px;
  padding: 14px 18px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.kh-submit { border: 1px solid var(--kh-wine); color: #fff7ea; background: var(--kh-wine); box-shadow: 0 12px 24px -12px rgba(121, 13, 22, .65); }
.kh-submit:hover:not(:disabled) { background: #8b1520; transform: translateY(-1px); }
.kh-submit:active:not(:disabled) { transform: translateY(0); }
.kh-demo { border: 1px solid var(--kh-line); color: var(--kh-ink); background: rgba(255, 255, 255, .62); }
.kh-demo:hover:not(:disabled) { border-color: #bdb19d; background: #fff; transform: translateY(-1px); }
.kh-submit:disabled, .kh-demo:disabled { cursor: wait; opacity: .65; transform: none; }
.kh-auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: #a9a294; font-size: 10px; text-transform: uppercase; letter-spacing: .14em; }
.kh-auth-divider::before, .kh-auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--kh-line); }
.kh-auth-foot { margin: 18px 0 0; font-size: 10.5px; line-height: 1.6; color: var(--kh-muted); }
.kh-auth-legal { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--kh-line); font-size: 9.5px; line-height: 1.55; color: #9a9385; }

.kh-auth-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 12px;
  color: var(--kh-muted);
}
.kh-auth-loading[hidden] { display: none; }
.kh-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(121, 13, 22, .18);
  border-top-color: var(--kh-wine);
  border-radius: 50%;
  animation: kh-spin .8s linear infinite;
}
@keyframes kh-spin { to { transform: rotate(360deg); } }

.kh-fatal {
  position: absolute;
  z-index: 6;
  inset: 50% auto auto 50%;
  width: min(420px, calc(100% - 36px));
  transform: translate(-50%, -50%);
  padding: 26px;
  border: 1px solid var(--kh-line);
  border-radius: 18px;
  background: var(--kh-paper);
  box-shadow: 0 24px 60px -24px rgba(48, 45, 41, .35);
  text-align: center;
}
.kh-fatal h2 { margin: 0 0 8px; font-family: Georgia, serif; font-weight: 500; }
.kh-fatal p { margin: 0 0 16px; color: var(--kh-muted); font-size: 13px; line-height: 1.5; }
.kh-fatal button { border: 1px solid var(--kh-wine); border-radius: 9px; padding: 10px 16px; font: inherit; font-size: 12px; font-weight: 700; color: #fff; background: var(--kh-wine); cursor: pointer; }

/* Compact account / connection chip, bottom right, above app content. */
.kh-session {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 36px);
  padding: 8px 9px 8px 12px;
  border: 1px solid rgba(48, 45, 41, .16);
  border-radius: 999px;
  color: #302d29;
  background: rgba(252, 250, 245, .9);
  box-shadow: 0 10px 28px -14px rgba(48, 45, 41, .5);
  backdrop-filter: blur(10px);
  font-family: "Manrope Variable", "Segoe UI", sans-serif;
  font-size: 10.5px;
}
.kh-session-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #b08a55; }
.kh-session-dot.is-online { background: #5f7d54; box-shadow: 0 0 0 3px rgba(95, 125, 84, .14); }
.kh-session-dot.is-offline { background: #b05555; box-shadow: 0 0 0 3px rgba(176, 85, 85, .13); }
.kh-session-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.kh-session-mode { color: #8d8578; text-transform: uppercase; letter-spacing: .09em; font-size: 8.5px; }
.kh-session-exit {
  border: 0;
  border-left: 1px solid rgba(48, 45, 41, .13);
  margin-left: 2px;
  padding: 2px 7px;
  color: #8b1820;
  background: transparent;
  font: inherit;
  font-size: 9.5px;
  font-weight: 700;
  cursor: pointer;
}
.kh-session-exit:hover { text-decoration: underline; }

.kh-toast {
  position: fixed;
  left: 50%;
  bottom: 68px;
  z-index: 9500;
  max-width: min(520px, calc(100vw - 36px));
  transform: translate(-50%, 14px);
  opacity: 0;
  pointer-events: none;
  padding: 11px 15px;
  border: 1px solid rgba(48, 45, 41, .16);
  border-radius: 10px;
  color: #302d29;
  background: rgba(252, 250, 245, .96);
  box-shadow: 0 18px 44px -18px rgba(48, 45, 41, .55);
  font-family: "Manrope Variable", "Segoe UI", sans-serif;
  font-size: 11.5px;
  line-height: 1.45;
  transition: opacity .22s ease, transform .22s ease;
}
.kh-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.kh-toast[data-type="error"] { border-color: rgba(121, 13, 22, .3); color: #7e121a; background: #fff7f4; }

@media (max-width: 860px) {
  .kh-auth { padding: 14px; }
  .kh-auth-shell { grid-template-columns: 1fr; min-height: 0; border-radius: 22px; }
  .kh-auth-brand { min-height: 250px; padding: 28px; gap: 22px; }
  .kh-auth-copy h1 { font-size: clamp(32px, 8vw, 46px); }
  .kh-auth-stats { display: none; }
  .kh-auth-panel { padding: 28px; }
  .kh-session { right: 12px; bottom: 12px; }
}
@media (max-width: 420px) {
  .kh-auth-brand { min-height: 210px; }
  .kh-lead { display: none; }
  .kh-auth-panel { padding: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .kh-auth-shell, .kh-spinner { animation: none; }
}
