/* ==========================================================================
   KiwiSystems AI -- design system (v2, "futuristic AI" direction)
   Near-black surfaces with a cyan-to-violet accent gradient, glassmorphic
   panels, and a faint circuit/grid backdrop. Space Grotesk carries brand
   and heading moments (geometric, technical character); Inter carries
   body/UI text; the existing monospace stack still carries code.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0A0B14;
  --bg-2: #0D0F1C;
  --surface: rgba(23, 26, 43, 0.72);
  --surface-solid: #171A2B;
  --surface-alt: rgba(30, 34, 54, 0.6);
  --ink: #E9EAF6;
  --cream: #F4F5FC;
  --muted: #8B90AC;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);

  --kiwi-green: #33E0C7;
  --kiwi-green-dark: #1FB8A3;
  --kiwi-bright: #9B7BFF;
  --kiwi-bright-soft: rgba(155, 123, 255, 0.14);
  --accent-gradient: linear-gradient(135deg, #33E0C7 0%, #9B7BFF 100%);

  --amber: #F5A623;
  --amber-soft: rgba(245, 166, 35, 0.14);

  --error: #FF6B6B;
  --error-soft: rgba(255, 107, 107, 0.14);

  --radius-lg: 22px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --radius-pill: 999px;

  --shadow-panel: 0 24px 70px -20px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --glow-cyan: 0 0 24px rgba(51, 224, 199, 0.25);
  --glow-violet: 0 0 24px rgba(155, 123, 255, 0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(51, 224, 199, 0.10) 0%, transparent 40%),
    radial-gradient(circle at 88% 92%, rgba(155, 123, 255, 0.12) 0%, transparent 42%),
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: auto, auto, 42px 42px, 42px 42px;
  background-attachment: fixed;
}

a { color: var(--kiwi-green); }

/* ---- brand mark ---------------------------------------------------- */

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

.kiwi-mark { flex-shrink: 0; display: block; filter: drop-shadow(0 0 10px rgba(51, 224, 199, 0.35)); }

.brand-word {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* ---- page shell ------------------------------------------------------ */

.page-center {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.page-center::before {
  content: "";
  position: absolute;
  top: -180px;
  right: -160px;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--kiwi-bright) 0%, transparent 70%);
  opacity: 0.28;
  filter: blur(30px);
  pointer-events: none;
}

.page-center::after {
  content: "";
  position: absolute;
  bottom: -160px;
  left: -140px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--kiwi-green) 0%, transparent 70%);
  opacity: 0.16;
  filter: blur(30px);
  pointer-events: none;
}

.page-body {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 16px;
  position: relative;
}

/* ---- auth card --------------------------------------------------- */

.card {
  width: 420px;
  max-width: 100%;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  padding: 32px;
  box-shadow: var(--shadow-panel);
  position: relative;
}

@media (min-width: 900px) {
  .card { width: 460px; padding: 40px; }
  .card h2 { font-size: 24px; }
  .card input[type=text], .card input[type=password], .card input[type=email] { padding: 13px 16px; font-size: 15px; }
}

.card .brand-row { margin-bottom: 18px; }
.card h2 {
  margin: 0 0 4px 0;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 22px;
  color: var(--ink);
}
.card p { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 4px 0; }

label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  display: block;
  margin-bottom: 5px;
  margin-top: 14px;
}

input[type=text], input[type=password], input[type=email] {
  width: 100%;
  background: rgba(10, 11, 20, 0.6);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: #565C78; }
input:focus { border-color: var(--kiwi-green); box-shadow: var(--glow-cyan); }

button {
  font-family: inherit;
  cursor: pointer;
}

button.primary {
  background: var(--accent-gradient);
  color: #06070C;
  border: none;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  width: 100%;
  margin-top: 20px;
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}
button.primary:hover { filter: brightness(1.08); box-shadow: var(--glow-cyan); }

button.secondary {
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}
button.secondary:hover { background: var(--kiwi-bright-soft); border-color: var(--kiwi-bright); }

.error {
  color: var(--error);
  background: var(--error-soft);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin-top: 14px;
}
.error:empty { display: none; }

.switch-link { text-align: center; font-size: 13px; color: var(--muted); margin-top: 20px; }
.switch-link a { color: var(--kiwi-green); text-decoration: none; font-weight: 600; }
.switch-link a:hover { text-decoration: underline; }

/* ---- footer ------------------------------------------------------ */

footer.site-footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 22px 16px;
  position: relative;
}
footer.site-footer a { color: var(--muted); text-decoration: none; margin: 0 8px; }
footer.site-footer a:hover { color: var(--kiwi-green); text-decoration: underline; }

/* ---- cookie consent flyout ---------------------------------------- */

#cookie-consent {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(500px, calc(100vw - 32px));
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-panel);
  z-index: 1000;
  display: none;
}
#cookie-consent p {
  color: var(--ink);
  font-size: 12.5px;
  margin: 0 0 12px 0;
  line-height: 1.45;
}
#cookie-consent p a { color: var(--kiwi-green); font-weight: 600; }
#cookie-consent .actions { display: flex; gap: 8px; }
#cookie-consent button {
  flex: 1;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 12.5px;
  font-weight: 500;
}
#cookie-consent .accept { background: var(--accent-gradient); color: #06070C; font-weight: 700; }
#cookie-consent .decline { background: var(--surface-alt); color: var(--ink); border: 1px solid var(--line-strong); }
#cookie-consent .decline:hover { background: var(--kiwi-bright-soft); }

/* ---- code blocks inside chat messages ------------------------------- */

.msg-code {
  display: block;
  margin: 4px 0 0 0;
  padding: 12px 14px;
  background: #05060B;
  color: #B9F5E9;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, Menlo, Consolas, "SF Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
}
.msg.user .msg-code { background: rgba(0,0,0,0.3); color: var(--cream); }

/* ---- generated image bubble ---------------------------------------- */

.msg-image {
  display: block;
  margin: 4px 0 0 0;
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
}

/* ---- mode selector (segmented control) ------------------------------ */

.mode-selector {
  display: flex;
  gap: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 4px;
}
.mode-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.mode-btn.active { background: var(--accent-gradient); color: #06070C; }
.mode-btn:not(.active):hover { color: var(--ink); }
.mode-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mode-btn:disabled:hover { color: var(--muted); }

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Visible keyboard focus on every interactive element. Browsers already do
   this by default, but custom-styled inputs/buttons often accidentally
   suppress it -- this makes sure it's always present and consistent. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--kiwi-green);
  outline-offset: 2px;
}

/* Skip link: hidden until focused, lets keyboard/screen-reader users jump
   past the header straight to the main content on every page. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--kiwi-green);
  color: #06070C;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 2000;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
}

/* Screen-reader-only text: visually hidden, still announced by assistive tech. */
.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;
}

/* Respect the OS-level "reduce motion" preference: stop the typing-dots
   animation and decorative gradient blobs from moving for anyone who's
   asked their system to minimize motion. */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
