/* digatus AI Platform · Application Starter
   Tokens aligned with digatus-portal portal.css */

:root {
  --digatus-green-400: #6fce48;
  --digatus-green-500: #59bb2f;
  --digatus-green-600: #4a9e26;
  --digatus-grey: #464d55;

  --bg-primary: #040e1a;
  --bg-secondary: #082032;
  --bg-tertiary: #0c2b42;
  --bg-elevated: rgba(8, 32, 50, 0.6);
  --bg-card: rgba(8, 32, 50, 0.45);
  --bg-card-hover: rgba(8, 32, 50, 0.7);
  --bg-card-solid: #0a1c2b;
  --bg-input: rgba(4, 14, 26, 0.55);

  --border-primary: rgba(18, 54, 82, 0.55);
  --border-hover: rgba(89, 187, 47, 0.5);
  --border-subtle: rgba(18, 54, 82, 0.3);

  --text-primary: #e0e4e6;
  --text-secondary: rgba(224, 228, 230, 0.72);
  --text-tertiary: rgba(224, 228, 230, 0.5);
  --text-quaternary: rgba(224, 228, 230, 0.4);

  --accent: var(--digatus-green-500);
  --accent-hover: var(--digatus-green-400);
  --accent-subtle: rgba(89, 187, 47, 0.12);

  --glass-bg: rgba(4, 14, 26, 0.78);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.18), 0 12px 40px rgba(0, 0, 0, 0.22);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.28), 0 0 24px rgba(89, 187, 47, 0.08);
  --shadow-glow: 0 0 28px rgba(89, 187, 47, 0.18);

  --radius-sm: 0.5rem;
  --radius-md: 0.85rem;
  --radius-lg: 1.1rem;
  --radius-pill: 9999px;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --topbar-h: 4.25rem;
  color-scheme: dark;
}

html.light {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-elevated: rgba(255, 255, 255, 0.92);
  --bg-card: rgba(255, 255, 255, 0.78);
  --bg-card-hover: rgba(255, 255, 255, 0.96);
  --bg-card-solid: #ffffff;
  --bg-input: #ffffff;

  --border-primary: rgba(15, 23, 42, 0.1);
  --border-hover: rgba(89, 187, 47, 0.45);
  --border-subtle: rgba(15, 23, 42, 0.06);

  --text-primary: #0f172a;
  --text-secondary: rgba(15, 23, 42, 0.78);
  --text-tertiary: rgba(15, 23, 42, 0.58);
  --text-quaternary: rgba(15, 23, 42, 0.45);

  --accent: var(--digatus-green-600);
  --accent-hover: var(--digatus-green-500);
  --accent-subtle: rgba(89, 187, 47, 0.1);

  --glass-bg: rgba(255, 255, 255, 0.82);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.05), 0 12px 32px rgba(15, 23, 42, 0.06);
  --shadow-card-hover: 0 10px 28px rgba(15, 23, 42, 0.1), 0 0 20px rgba(89, 187, 47, 0.08);
  --shadow-glow: 0 0 24px rgba(89, 187, 47, 0.12);

  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-primary);
  background: var(--bg-primary);
  font-family: var(--font-sans);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  line-height: 1.5;
}

.bg-glow {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.bg-glow::before,
.bg-glow::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
}

.bg-glow::before {
  top: -10rem;
  right: -8rem;
  width: 26rem;
  height: 26rem;
  background: radial-gradient(circle, var(--accent-subtle) 0%, transparent 70%);
}

.bg-glow::after {
  bottom: -12rem;
  left: -10rem;
  width: 28rem;
  height: 28rem;
  background: radial-gradient(circle, rgba(18, 54, 82, 0.35) 0%, transparent 72%);
}

html.light .bg-glow::after {
  background: radial-gradient(circle, rgba(15, 23, 42, 0.05) 0%, transparent 70%);
}

/* —— Top bar —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--topbar-h);
  padding: 0.85rem max(1.25rem, calc((100vw - 1160px) / 2));
  border-bottom: 1px solid var(--border-primary);
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--text-primary);
  min-width: 0;
}

.brand-logo {
  height: 1.75rem;
  width: auto;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 1.35rem;
  background: var(--border-primary);
}

.brand-product {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(89, 187, 47, 0.28);
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.identity {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* —— Theme toggle (portal-like) —— */
.theme-toggle {
  position: relative;
  flex: 0 0 auto;
  width: 3.4rem;
  height: 1.95rem;
  padding: 0;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-primary);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--border-hover);
}

.theme-toggle-slider {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: var(--bg-card-solid);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  display: grid;
  place-items: center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html.light .theme-toggle-slider {
  transform: translateX(1.45rem);
}

.theme-toggle-icon {
  font-size: 0.72rem;
  line-height: 1;
  color: var(--text-tertiary);
}

.theme-toggle-icon-sun {
  display: none;
}

html.light .theme-toggle-icon-moon {
  display: none;
}

html.light .theme-toggle-icon-sun {
  display: inline;
}

/* —— Layout —— */
.shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 3.4rem 1.35rem 5rem;
}

.intro {
  max-width: 46rem;
  margin-bottom: 2.4rem;
  animation: fadeIn 0.35s ease-out both;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font: 700 0.7rem/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0.9rem 0 1rem;
  font-size: clamp(2.15rem, 5.2vw, 3.55rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
  font-weight: 700;
}

.intro p {
  margin: 0;
  max-width: 40rem;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.intro-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.35rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-primary);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
}

.pill .dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* —— Cards —— */
.card,
.request-card,
.response-card,
.notice {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.request-card:hover,
.response-card:hover,
.notice:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card-hover);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 1.25rem;
  align-items: start;
}

.request-card,
.response-card,
.notice {
  padding: 1.55rem 1.55rem 1.65rem;
}

.card-heading {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1.05rem;
  margin-bottom: 1.25rem;
}

.step {
  color: var(--accent);
  font: 800 0.75rem/1 var(--font-mono);
  padding-top: 0.35rem;
  letter-spacing: 0.04em;
}

.card-heading h2,
.notice h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.025em;
  font-weight: 650;
}

.card-heading p,
.notice p {
  margin: 0.35rem 0 0;
  color: var(--text-tertiary);
  font-size: 0.9rem;
  line-height: 1.45;
}

.notice {
  max-width: 34rem;
  text-align: left;
  animation: fadeIn 0.35s ease-out 0.05s both;
}

.notice-mark {
  width: 3.1rem;
  height: 3.1rem;
  margin-bottom: 1rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.55rem;
  color: #fff;
  background: linear-gradient(135deg, var(--digatus-green-400), var(--digatus-green-600));
  box-shadow: var(--shadow-glow);
}

.notice-hint {
  margin-top: 0.95rem !important;
  font-size: 0.82rem !important;
}

/* —— Form controls —— */
label {
  display: block;
  margin: 0 0 0.45rem;
  font: 600 0.72rem/1 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--border-primary);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.9rem;
  color: var(--text-primary);
  font: 0.95rem/1.55 var(--font-sans);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea::placeholder {
  color: var(--text-quaternary);
}

textarea:hover,
select:hover {
  border-color: var(--border-hover);
}

textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-tertiary) 50%),
    linear-gradient(135deg, var(--text-tertiary) 50%, transparent 50%);
  background-position:
    calc(100% - 1.05rem) calc(50% - 0.15rem),
    calc(100% - 0.7rem) calc(50% - 0.15rem);
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-top: 1.05rem;
}

.rag-panel {
  margin-top: 1.2rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(89, 187, 47, 0.22);
  background: linear-gradient(135deg, var(--accent-subtle), transparent 70%);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 1.4rem;
  border-radius: var(--radius-pill);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 0.12rem;
  left: 0.12rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle input:checked + .toggle-track {
  background: rgba(89, 187, 47, 0.28);
  border-color: rgba(89, 187, 47, 0.55);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(1.05rem);
  background: var(--accent);
}

.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.toggle-copy strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.toggle-copy em {
  font-style: normal;
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.scope-control {
  margin-top: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  margin-top: 1.4rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 1px solid transparent;
  border-radius: 0.85rem;
  padding: 0.78rem 1.1rem;
  text-decoration: none;
  cursor: pointer;
  font: 600 0.92rem/1 var(--font-sans);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.button:active {
  transform: translateY(1px);
}

.button.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--digatus-green-500), var(--digatus-green-600));
  box-shadow: 0 8px 22px rgba(89, 187, 47, 0.22);
}

.button.primary:hover {
  background: linear-gradient(135deg, var(--digatus-green-400), var(--digatus-green-500));
  box-shadow: var(--shadow-glow);
}

.button.ghost {
  color: var(--text-secondary);
  background: var(--bg-card);
  border-color: var(--border-primary);
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
}

.button.ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.status {
  color: var(--text-tertiary);
  font-size: 0.84rem;
}

/* —— Response —— */
.answer {
  white-space: pre-wrap;
  font-size: 0.98rem;
  line-height: 1.65;
  min-height: 8rem;
  color: var(--text-primary);
}

.answer.empty {
  color: var(--text-quaternary);
}

.response-card h3 {
  margin: 1.5rem 0 0.7rem;
  font: 700 0.72rem/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.sources {
  display: grid;
  gap: 0.6rem;
}

.source {
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  background: var(--bg-input);
}

.source strong {
  font-size: 0.84rem;
  color: var(--text-primary);
}

.source span {
  float: right;
  color: var(--text-quaternary);
  font: 500 0.7rem/1.4 var(--font-mono);
}

.source p {
  margin: 0.55rem 0 0;
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.45;
  clear: both;
}

.technical {
  margin-top: 1.35rem;
}

.technical summary {
  cursor: pointer;
  list-style: none;
  font: 650 0.78rem/1.4 var(--font-mono);
  letter-spacing: 0.03em;
  color: var(--accent);
}

.technical summary::-webkit-details-marker {
  display: none;
}

.technical summary span {
  color: var(--text-quaternary);
  font-weight: 450;
  margin-left: 0.4rem;
}

.technical pre {
  overflow: auto;
  max-height: 24rem;
  margin: 0.75rem 0 0;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  background: #071424;
  color: #cfe9d4;
  font: 0.72rem/1.55 var(--font-mono);
}

html.light .technical pre {
  background: #0b1a28;
  color: #d9f0df;
}

.hidden {
  display: none !important;
}

/* —— Footer —— */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem max(1.25rem, calc((100vw - 1160px) / 2)) 1.4rem;
  border-top: 1px solid var(--border-primary);
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.footer-sep {
  opacity: 0.5;
}

.mono,
.footer-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}

.footer-meta {
  color: var(--text-quaternary);
}

/* —— Motion / a11y —— */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

a:focus-visible,
button:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .identity {
    display: none;
  }

  .shell {
    padding-top: 2.2rem;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .brand-product {
    display: none;
  }
}

@media (max-width: 560px) {
  .brand-badge {
    display: none;
  }

  .request-card,
  .response-card,
  .notice {
    padding: 1.15rem;
  }

  footer {
    display: grid;
    gap: 0.35rem;
  }

  .button.primary {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
