/* K2AI One Cloud — onboarding surface
   Brand tokens verified against knowledge2-ai.com rendered capture 2026-09-17.
   Typeface note: the marketing page resolves to the system sans stack; Inter is
   already imported by the brand bundle, and we deliberately apply it here. */

@import url("tokens.css");

* { box-sizing: border-box; }

/* Display-mode classes (flex/grid) must never resurrect [hidden] elements. */
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Split shell (sign-in / sign-up) ---------- */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.brand-pane {
  position: relative;
  background: var(--hero-grad);
  display: flex;
  flex-direction: column;
  padding: 2.5rem 3rem;
  overflow: hidden;
}

.brand-pane::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60rem 40rem at 110% -10%, rgba(30, 190, 199, 0.14), transparent 60%),
    radial-gradient(50rem 36rem at -20% 110%, rgba(6, 10, 24, 0.55), transparent 65%);
  pointer-events: none;
}

.brand-pane > * { position: relative; }

.brand-logo { display: inline-flex; align-items: center; }
.brand-logo img { height: 44px; width: auto; display: block; }

.brand-story {
  margin: auto 0;
  max-width: 30rem;
  padding: 3rem 0;
}

.brand-story h1 {
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
}

.brand-story .lede {
  color: rgba(241, 245, 249, 0.88);
  font-size: 1.02rem;
  margin: 0 0 1.75rem;
}

.story-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }

.story-points li { display: flex; gap: 0.8rem; align-items: flex-start; }

.story-points .pt-icon {
  flex: none;
  width: 2rem; height: 2rem;
  border-radius: var(--radius);
  background: rgba(6, 10, 24, 0.35);
  border: 1px solid rgba(241, 245, 249, 0.18);
  display: grid; place-items: center;
  color: var(--teal);
}
.story-points .pt-icon svg { width: 1.05rem; height: 1.05rem; }

.story-points strong { display: block; font-size: 0.95rem; font-weight: 600; }
.story-points span.pt-sub { display: block; font-size: 0.85rem; color: rgba(226, 232, 240, 0.75); }

.brand-foot {
  font-size: 0.78rem;
  color: rgba(226, 232, 240, 0.65);
  display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem;
}
.brand-foot a { color: rgba(226, 232, 240, 0.8); }

/* ---------- Auth pane ---------- */

.auth-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth-sub { margin: 0 0 1.5rem; color: var(--text-muted); font-size: 0.92rem; }

/* SSO buttons — vendor dark-theme conventions */
.sso-stack { display: grid; gap: 0.75rem; }

.sso-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.75rem;
  width: 100%; min-height: 46px;
  border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.sso-btn:hover { text-decoration: none; }
.sso-btn svg { width: 1.15rem; height: 1.15rem; flex: none; }

.sso-google { background: #131314; border: 1px solid #8e918f; color: #e3e3e3; }
.sso-google:hover { background: #1d1d1e; }

.sso-microsoft { background: #2f2f2f; border: 1px solid #454545; color: #ffffff; }
.sso-microsoft:hover { background: #3a3a3a; }

.divider {
  display: flex; align-items: center; gap: 0.9rem;
  margin: 1.4rem 0;
  color: var(--text-muted); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border-strong);
}

/* Email fallback disclosure */
details.email-auth summary {
  list-style: none;
  cursor: pointer;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.92rem; font-weight: 500;
  padding: 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 120ms ease, color 120ms ease;
}
details.email-auth summary::-webkit-details-marker { display: none; }
details.email-auth summary:hover { border-color: var(--teal); color: var(--text); }
details.email-auth[open] summary { display: none; }

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 0.4rem;
}
.field .hint { font-size: 0.8rem; color: var(--text-muted); margin: 0.35rem 0 0; }
.field .hint a { font-weight: 500; }

.input, input[type="email"], input[type="password"], input[type="text"], input[type="url"], .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 0.65rem 0.8rem;
  min-height: 44px;
}
.input::placeholder, input::placeholder { color: #64748b; }
.field select:focus,
.input:focus, input:focus {
  outline: 2px solid var(--teal);
  outline-offset: 0;
  border-color: transparent;
}

.input-group { position: relative; display: flex; }
.input-group input { padding-right: 5.4rem; }
.input-affix {
  position: absolute; right: 0.4rem; top: 50%; transform: translateY(-50%);
  display: flex; gap: 0.25rem;
}
.icon-btn {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  padding: 0.35rem 0.5rem; border-radius: 4px;
  min-height: 32px;
}
.icon-btn:hover { color: var(--teal); background: var(--teal-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 46px; width: 100%;
  border: none; border-radius: var(--radius);
  font: inherit; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background-color 120ms ease, filter 120ms ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-gradient { background: var(--cta-grad); color: #fff; }
.btn-gradient:hover { filter: brightness(1.1); }
.btn-secondary {
  background: transparent; color: var(--text-soft);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { border-color: var(--teal); color: var(--text); }
.btn-row { display: grid; gap: 0.75rem; margin-top: 1.25rem; }
@media (min-width: 480px) {
  .btn-row.split { grid-template-columns: 1fr 1fr; }
}

.auth-switch {
  margin: 1.5rem 0 0; padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center; font-size: 0.9rem; color: var(--text-muted);
}
.auth-switch a { font-weight: 600; }

.fine-print {
  margin: 1.1rem 0 0;
  font-size: 0.78rem; color: var(--text-muted);
  text-align: center;
}

.alert {
  display: flex; gap: 0.6rem; align-items: flex-start;
  background: var(--red-soft);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius);
  color: #fecaca;
  font-size: 0.88rem;
  padding: 0.75rem 0.9rem;
  margin: 0 0 1.25rem;
}
.alert svg { flex: none; width: 1.05rem; height: 1.05rem; margin-top: 0.1rem; color: var(--red); }
.alert a { color: #fff; font-weight: 600; }

/* ---------- Onboarding flow (stepper pages) ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 10, 24, 0.85);
}
.topbar img { height: 34px; width: auto; display: block; }
.topbar .whoami { font-size: 0.85rem; color: var(--text-muted); }

.flow-main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.stepper {
  list-style: none; margin: 0 0 2.25rem; padding: 0;
  display: flex;
  counter-reset: step;
}
.stepper li {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  position: relative;
  text-align: center;
  font-size: 0.8rem; font-weight: 500;
  color: var(--text-muted);
}
.stepper li::before {
  counter-increment: step;
  content: counter(step);
  display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 700; font-size: 0.9rem;
  z-index: 1;
}
.stepper li:not(:first-child)::after {
  content: "";
  position: absolute;
  top: 1.05rem; right: 50%;
  width: 100%; height: 2px;
  background: var(--border-strong);
  transform: translateX(-1.05rem);
  z-index: 0;
}
.stepper li.done { color: var(--text-soft); }
.stepper li.done::before {
  content: "\2713";
  background: var(--teal);
  border-color: var(--teal);
  color: #06121a;
}
.stepper li.done + li::after,
.stepper li.active + li.done::after { background: var(--teal); }
.stepper li.active { color: var(--text); }
.stepper li.active::before {
  background: var(--blue);
  border-color: var(--blue-light);
  color: #fff;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.22);
}

@media (max-width: 560px) {
  .stepper li span { display: none; }
  .stepper li.active span { display: block; }
}

.flow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.flow-card h2 { margin: 0 0 0.4rem; font-size: 1.3rem; font-weight: 700; }
.flow-card .flow-sub { margin: 0 0 1.5rem; color: var(--text-muted); font-size: 0.92rem; }

.why-key {
  display: flex; gap: 0.75rem;
  background: var(--teal-soft);
  border: 1px solid rgba(30, 190, 199, 0.3);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.87rem; color: var(--text-soft);
}
.why-key svg { flex: none; width: 1.15rem; height: 1.15rem; color: var(--teal); margin-top: 0.1rem; }
.why-key strong { color: var(--text); }
.why-key p { margin: 0.15rem 0 0; }

/* Connect step: ChatGPT subscription sign-in (device-code flow) */
.connect-signin { display: grid; gap: 0.6rem; }
.connect-signin .btn svg { width: 1.15rem; height: 1.15rem; flex: none; }
.connect-signin > .hint { font-size: 0.82rem; color: var(--text-muted); margin: 0; text-align: center; }

.device-flow {
  display: grid; gap: 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-top: 0.4rem;
}
.device-step { margin: 0; font-size: 0.9rem; color: var(--text-soft); }
.device-code-row {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
}
.device-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.6rem; font-weight: 700; letter-spacing: 0.18em;
  color: var(--text);
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  user-select: all;
}
.device-status {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  margin: 0; font-size: 0.88rem; color: var(--text-muted);
}
.device-status.is-done { color: var(--teal); font-weight: 600; }

details.optional-group summary svg { width: 1rem; height: 1rem; flex: none; }

details.optional-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1.25rem;
}
details.optional-group summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.8rem 1rem;
  font-size: 0.9rem; font-weight: 600; color: var(--text-soft);
}
details.optional-group summary::-webkit-details-marker { display: none; }
details.optional-group summary .chev { transition: transform 150ms ease; color: var(--text-muted); }
details.optional-group[open] summary .chev { transform: rotate(180deg); }
details.optional-group summary .opt-tag {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.6rem;
  margin-left: auto;
}
details.optional-group .group-body { padding: 0.25rem 1rem 1.1rem; }
details.optional-group .group-note { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 1rem; }

/* Provisioning wait state */
.provision-list { list-style: none; margin: 1.5rem 0; padding: 0; display: grid; gap: 0.9rem; }
.provision-list li {
  display: flex; align-items: center; gap: 0.8rem;
  font-size: 0.92rem; color: var(--text-muted);
}
.provision-list li .p-icon {
  flex: none; width: 1.6rem; height: 1.6rem;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--border-strong);
  font-size: 0.8rem;
}
.provision-list li.p-done { color: var(--text-soft); }
.provision-list li.p-done .p-icon { background: var(--teal); border-color: var(--teal); color: #06121a; }
.provision-list li.p-now { color: var(--text); }
.provision-list li.p-now .p-icon { border-color: var(--blue-light); }

.spinner {
  width: 1rem; height: 1rem;
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-top-color: var(--blue-light);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.5s; }
}

.wait-note svg { flex: none; width: 1.1rem; height: 1.1rem; margin-top: 0.1rem; color: var(--teal); }

.wait-note {
  display: flex; gap: 0.6rem; align-items: flex-start;
  font-size: 0.85rem; color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}

/* ---------- Status / error pages ---------- */

.status-main {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}
.status-center {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem 1.25rem;
}
.status-card {
  width: 100%; max-width: 28rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.status-icon {
  width: 3.25rem; height: 3.25rem;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  display: grid; place-items: center;
}
.status-icon svg { width: 1.6rem; height: 1.6rem; }
.status-icon.is-error { background: var(--red-soft); color: var(--red); border: 1px solid rgba(248,113,113,0.3); }
.status-icon.is-warn { background: rgba(251,191,36,0.1); color: var(--amber); border: 1px solid rgba(251,191,36,0.3); }
.status-icon.is-info { background: var(--teal-soft); color: var(--teal); border: 1px solid rgba(30,190,199,0.3); }
.status-card h1 { font-size: 1.3rem; font-weight: 700; margin: 0 0 0.6rem; letter-spacing: -0.01em; }
.status-card .status-msg { color: var(--text-muted); font-size: 0.93rem; margin: 0 0 0.5rem; }
.status-card .status-detail {
  text-align: left;
  font-size: 0.85rem; color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin: 1.1rem 0 0;
}
.status-card .status-detail ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.status-card .status-detail li { margin: 0.2rem 0; }
.status-foot {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.78rem; color: var(--text-muted);
}

/* ---------- Responsive: Z Fold cover (~344px) through unfolded ---------- */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .brand-pane { padding: 1.5rem 1.25rem 1.75rem; }
  .brand-story { margin: 0; padding: 1.5rem 0 0.25rem; max-width: none; }
  .brand-story h1 { font-size: 1.35rem; }
  .brand-story .lede { font-size: 0.95rem; margin-bottom: 1rem; }
  .story-points { display: none; }           /* keep the pitch tight on phones */
  .brand-foot { display: none; }
  .auth-pane { padding: 1.75rem 1rem 3rem; align-items: stretch; }
  .auth-card { max-width: none; padding: 1.5rem 1.25rem; }
  .flow-card { padding: 1.5rem 1.25rem; }
  .brand-logo img { height: 36px; }
}

@media (min-width: 901px) and (max-width: 1120px) {
  .brand-pane { padding: 2rem; }
}

/* ---------- Account settings page ---------- */

.account-main { padding: 2rem 1rem 4rem; }
.account-card { max-width: 44rem; width: 100%; }
.acct-back { margin-bottom: 0.75rem; font-size: 0.88rem; }
.acct-section { border-top: 1px solid var(--border); margin-top: 1.75rem; padding-top: 1.5rem; }
.acct-section h3 { margin: 0 0 0.75rem; font-size: 1.02rem; font-weight: 600; }
.acct-subhead { margin: 1.1rem 0 0.5rem; font-size: 0.86rem; font-weight: 600; color: var(--text-soft); }
.acct-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 560px) { .acct-two { grid-template-columns: 1fr; } }
.acct-list { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
            border: 1px solid var(--border); border-radius: var(--radius);
            background: var(--surface); padding: 0.65rem 0.85rem; }
/* The text block must keep its width against the flex minimum, or a long
   user-agent string collapses into a one-character-wide column. */
.acct-row > div:first-child { flex: 1 1 auto; min-width: 0; }
.acct-row.acct-current { border-color: rgba(30, 190, 199, 0.45); }
.acct-strong { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.acct-muted { color: var(--text-muted); font-size: 0.83rem; overflow-wrap: anywhere; }
.acct-profile-row { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1.1rem; }
.acct-avatar { flex: none; width: 3rem; height: 3rem; border-radius: 50%; overflow: hidden;
               display: grid; place-items: center; background: var(--surface-2);
               border: 1px solid var(--border-strong); color: var(--teal);
               font-weight: 700; font-size: 1rem; letter-spacing: 0.04em; }
.acct-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.acct-details { margin-top: 0.9rem; }
.acct-details summary { cursor: pointer; color: var(--teal); font-weight: 500; font-size: 0.92rem; }
.acct-details form { margin-top: 1rem; }
.btn-row-tight { margin-top: 0.5rem; grid-template-columns: max-content; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.8rem; flex: none; width: auto; min-height: 34px; }
.acct-status { min-height: 1.2em; }
.acct-status.error { color: var(--red); }
.acct-activity { max-height: 22rem; overflow-y: auto; }
.acct-danger { border-top-color: rgba(248, 113, 113, 0.35); }
.acct-danger h3 { color: var(--red); }
.btn-danger { background: var(--red-soft); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.5); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.2); }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; }

/* Connected provider account badges (account settings, ChatGPT accounts). */
.acct-badge { display: inline-block; padding: .2rem .6rem; border: 1px solid var(--ok, #2c8a4b); border-radius: 1rem; color: var(--ok, #2c8a4b); font-size: .78rem; font-weight: 600; }
.acct-ai-list { margin-bottom: .6rem; }
.acct-provider-name { margin: 1rem 0 .35rem; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); }
.acct-provider-name:first-child { margin-top: .2rem; }
.acct-row-actions { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
