:root {
  color-scheme: dark;
  --ink: #eef2f8;
  --muted: #8f9db3;
  --line: #202b40;
  --surface: #0f1626;
  --soft: #101a2b;
  --accent: #60b8f4;
  --accent-dark: #408fe5;
  --accent-light: rgba(96, 184, 244, .14);
  --violet: #885cf6;
  --warning: #8b5b12;
  --danger: #ff9aaa;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0, rgba(51, 113, 184, .38), transparent 34rem),
    radial-gradient(circle at 92% 32%, rgba(112, 64, 204, .22), transparent 30rem),
    #090d18;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }

.site-shell { min-height: 100vh; display: flex; flex-direction: column; }
.header, .footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}
.header {
  position: relative;
  min-height: 80px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 16px;
}
.header-account {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.header-account > .button { min-height: 48px; }
.header-account[hidden] { display: none !important; }
.mobile-account { display: none; }
.mobile-account[hidden] { display: none !important; }
.nav-guest {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
}
.nav-guest[hidden] { display: none !important; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 760; font-size: 21px; letter-spacing: -.03em; }
.brand-logo { width: 43px; height: 43px; object-fit: contain; }
.brand-small { font-size: 18px; }
.brand-small .brand-logo { width: 36px; height: 36px; }
.nav { display: flex; align-items: center; gap: 24px; color: #a6b2c4; font-size: 14px; font-weight: 600; }
.nav > a:not(.button):hover, .footer a:hover { color: var(--accent); }
.menu-button {
  display: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--ink);
  justify-self: start;
}

.button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  font-weight: 700;
  transition: .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button-primary {
  color: #07111f;
  background: linear-gradient(135deg, #69c7f4, #8a64f5);
  border-color: rgba(132, 116, 243, .7);
  box-shadow: 0 10px 30px rgba(82, 132, 241, .2);
}
.button-primary:hover { background: linear-gradient(135deg, #83d5fa, #9b7afa); }
.button-ghost { color: #dce6f5; background: rgba(15, 22, 38, .72); border-color: #33415d; }
.button-wide { width: 100%; }
.account-link {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 7px;
  border: 1px solid #33415d;
  border-radius: 12px;
  background: rgba(15, 22, 38, .72);
  transition: .18s ease;
}
.account-link:hover { border-color: #526888; background: #111b2e; transform: translateY(-1px); }
.account-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #07111f;
  background: linear-gradient(135deg, #69c7f4, #8a64f5);
  font-size: 14px;
  font-weight: 850;
}
.account-copy { min-width: 0; display: grid; gap: 2px; }
.account-copy span { color: var(--muted); font-size: 10px; font-weight: 700; }
.account-copy strong {
  max-width: 210px;
  overflow: hidden;
  color: #e7eef9;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main { flex: 1; }
.hero {
  width: min(1180px, calc(100% - 40px));
  margin: 74px auto 96px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr);
  align-items: center;
  gap: 68px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: #7dcdf6;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #8b67f6; box-shadow: 0 0 0 5px rgba(111, 112, 244, .14); }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; max-width: 760px; font-size: clamp(44px, 6vw, 76px); line-height: .99; letter-spacing: -.065em; }
.hero-copy > p { max-width: 650px; margin: 28px 0; color: var(--muted); font-size: 19px; line-height: 1.65; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-note { margin-top: 18px; color: var(--muted); font-size: 13px; }

.answer-card {
  padding: 26px;
  border: 1px solid #293650;
  border-radius: 24px;
  background: rgba(14, 21, 36, .9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  transform: rotate(1.2deg);
}
.answer-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.answer-status { display: inline-flex; align-items: center; gap: 9px; color: #b8dcfa; font-size: 12px; font-weight: 800; }
.assistant-avatar { width: 34px; height: 34px; object-fit: contain; }
.answer-time { color: var(--muted); font-size: 12px; }
.bubble { max-width: 88%; margin: 10px 0; padding: 14px 16px; border-radius: 16px; line-height: 1.5; font-size: 14px; }
.bubble-user { margin-left: auto; color: white; background: linear-gradient(135deg, #347fc4, #7554cf); border-bottom-right-radius: 5px; }
.bubble-ai { color: #c9d4e5; background: #101a2b; border: 1px solid #222f47; border-bottom-left-radius: 5px; }

.section { width: min(1180px, calc(100% - 40px)); margin: 0 auto 110px; }
.section-heading { max-width: 680px; margin-bottom: 36px; }
.section h2 { margin: 0 0 14px; font-size: clamp(31px, 4vw, 48px); letter-spacing: -.045em; }
.section-heading p { color: var(--muted); font-size: 17px; line-height: 1.6; }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.feature {
  min-width: 0;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(14, 21, 36, .8);
  box-shadow: 0 16px 50px rgba(0, 0, 0, .14);
}
.feature-number { color: var(--accent); font: 800 12px/1 monospace; }
.feature h3 { margin: 32px 0 10px; font-size: 20px; }
.feature p { margin: 0; color: var(--muted); line-height: 1.55; }
.cta-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: clamp(28px, 5vw, 52px);
  border: 1px solid #2d3c58;
  border-radius: 24px;
  background:
    radial-gradient(circle at 100% 0, rgba(122, 77, 222, .26), transparent 45%),
    #0e1728;
}
.cta-section h2 { max-width: 760px; margin-bottom: 0; }
.cta-section .button { flex: 0 0 auto; }

.auth-layout {
  width: min(1040px, calc(100% - 40px));
  margin: 44px auto 80px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 54px;
  align-items: center;
}
.auth-message h1 { font-size: clamp(38px, 5vw, 62px); }
.auth-message p { max-width: 500px; color: var(--muted); font-size: 17px; line-height: 1.65; }
.trust-list { display: grid; gap: 13px; margin-top: 28px; color: #b5c1d3; font-size: 14px; }
.trust-list span::before { content: "✓"; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 10px; border-radius: 50%; color: var(--accent); background: var(--accent-light); font-weight: 900; }
.auth-card {
  min-width: 0;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card h2 { margin: 0 0 8px; font-size: 27px; letter-spacing: -.035em; }
.auth-card > p { margin: 0 0 26px; color: var(--muted); line-height: 1.5; }
.field { display: grid; gap: 8px; margin: 18px 0; }
.field label { font-size: 13px; font-weight: 750; }
.field input {
  min-width: 0;
  width: 100%;
  height: 49px;
  padding: 0 14px;
  border: 1px solid #33415d;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: #0b1220;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 107, 80, .12); }
.code-input { text-align: center; font: 700 25px/1 monospace; letter-spacing: .28em; }
.form-error { min-height: 20px; margin: 12px 0; color: var(--danger); font-size: 13px; line-height: 1.45; }
.form-footnote { margin-top: 18px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.form-footnote a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.switch-auth { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: 14px; }
.switch-auth a { color: var(--accent); font-weight: 750; }

.app-page { width: min(1180px, calc(100% - 40px)); margin: 38px auto 90px; }
.app-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.app-top h1 { font-size: clamp(34px, 5vw, 54px); }
.app-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; }
.panel { min-width: 0; padding: 26px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.empty-state { min-height: 300px; display: grid; place-items: center; text-align: center; }
.empty-state div { max-width: 430px; }
.empty-state h2 { margin-bottom: 10px; }
.empty-state p, .panel p { color: var(--muted); line-height: 1.55; }
.metric { padding: 16px 0; border-bottom: 1px solid var(--line); }
.metric:last-child { border: 0; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 6px; font-size: 17px; font-weight: 750; }
.loading { min-height: 55vh; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.project-form { display: grid; grid-template-columns: minmax(220px, .45fr) minmax(0, 1fr); gap: 18px 28px; align-items: end; }
.project-form h2, .project-card h2, .project-section-head h2 { margin: 0; }
.project-form p { margin: 7px 0 0; }
.project-fields { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(220px, 1fr) auto; gap: 10px; }
.project-fields input {
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #33415d;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: #0b1220;
}
.project-fields input:focus { border-color: var(--accent); }
.project-form .form-error { grid-column: 2; margin: 0; }
.project-section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 34px 0 15px; }
.project-section-head span { color: var(--muted); font-size: 13px; }
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.loading-projects { grid-column: 1 / -1; color: var(--muted); text-align: center; }
.project-card { display: flex; flex-direction: column; gap: 18px; }
.project-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.project-card-top > div { min-width: 0; }
.project-card h2 { overflow: hidden; font-size: 20px; text-overflow: ellipsis; white-space: nowrap; }
.project-card a { display: block; margin-top: 6px; overflow: hidden; color: #78c7ff; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.project-badge { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; color: #acd9ff; background: #122a40; font-size: 11px; font-weight: 800; }
.project-badge.ready_for_review { color: #86e6ba; background: #123426; }
.project-badge.attention { color: #ff9aaa; background: #351720; }
.project-badge.downloading, .project-badge.analyzing { color: #d9c4ff; background: #2c2048; }
.project-progress { height: 7px; overflow: hidden; border-radius: 999px; background: #202a3d; }
.project-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #69c7f4, #8a64f5); }
.project-progress-copy { margin: -11px 0 0 !important; font-size: 12px; }
.project-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.project-metrics div { padding: 12px; border-radius: 10px; background: #101a2b; }
.project-metrics strong, .project-metrics span { display: block; }
.project-metrics strong { font-size: 20px; }
.project-metrics span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.project-card-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: auto; color: var(--muted); font-size: 12px; }
.project-card-foot .project-open { margin: 0; color: #8ed8ff; font-weight: 800; text-decoration: none; }

.workspace-back { display: inline-block; margin-bottom: 22px; color: #8ed8ff; text-decoration: none; }
.workspace-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.workspace-head h1 { margin: 5px 0 7px; font-size: clamp(32px, 5vw, 54px); }
.workspace-head a { color: #78c7ff; text-decoration: none; }
.version-picker { display: grid; gap: 7px; min-width: min(360px, 100%); color: var(--muted); font-size: 12px; font-weight: 800; }
.version-picker select { min-height: 45px; padding: 0 38px 0 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #101a2b; font: inherit; }
.workspace-layout { display: grid; grid-template-columns: 245px minmax(0, 1fr); gap: 15px; align-items: start; }
.workspace-stages { display: grid; gap: 7px; padding: 12px; }
.workspace-stages button { min-height: 47px; padding: 0 13px; border: 1px solid transparent; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; font: inherit; font-weight: 700; text-align: left; }
.workspace-stages button:hover, .workspace-stages button.active { border-color: #355e89; color: var(--text); background: #132036; }
.workspace-stages button:disabled { opacity: .45; cursor: default; }
.workspace-content { min-height: 530px; }
.workspace-content > p { max-width: 760px; }
.workspace-title { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.workspace-title h2 { margin: 5px 0 0; font-size: 27px; }
.workspace-pill { flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; color: #93ddff; background: #122a40; font-size: 11px; font-weight: 800; }
.workspace-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 22px 0; }
.workspace-metrics div { min-width: 0; padding: 13px; border-radius: 11px; background: #101a2b; }
.workspace-metrics strong, .workspace-metrics span { display: block; overflow-wrap: anywhere; }
.workspace-metrics strong { font-size: 19px; }
.workspace-metrics span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.workspace-list { display: grid; gap: 8px; margin-top: 22px; }
.workspace-list article { min-width: 0; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: #0d1626; }
.workspace-list article strong, .workspace-list article span, .workspace-list article small { display: block; overflow-wrap: anywhere; }
.workspace-list article span { margin-top: 5px; color: #7fcaf7; font-size: 11px; }
.workspace-list article small { margin-top: 7px; color: var(--muted); line-height: 1.45; }
.workspace-chat-list { display: flex; gap: 8px; margin: 18px 0; overflow-x: auto; }
.workspace-chat-list button { flex: 0 0 auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #101a2b; cursor: pointer; }
.workspace-chat-list button span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.workspace-messages { display: grid; gap: 10px; min-height: 220px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #0b1423; }
.workspace-messages article { width: min(82%, 680px); padding: 12px 14px; border-radius: 12px; background: #151f31; }
.workspace-messages article.user { justify-self: end; background: #17304b; }
.workspace-messages article p { margin: 6px 0 0; white-space: pre-wrap; }
.workspace-chat-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; margin-top: 12px; }
.workspace-chat-form textarea { min-height: 52px; max-height: 180px; padding: 13px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #0b1423; font: inherit; }

.legal { width: min(820px, calc(100% - 40px)); margin: 52px auto 90px; padding: 40px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.legal h1 { font-size: clamp(34px, 5vw, 54px); }
.legal h2 { margin-top: 36px; font-size: 22px; }
.legal p, .legal li { color: #a6b2c4; line-height: 1.65; }
.draft-note { padding: 14px 16px; border: 1px solid #69542d; border-radius: 10px; color: #e8bd78; background: #2a2112; font-size: 13px; }

.footer { display: flex; justify-content: space-between; gap: 30px; padding: 34px 0 42px; border-top: 1px solid var(--line); }
.footer p { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 18px; color: var(--muted); font-size: 13px; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(380px, calc(100% - 40px));
  padding: 13px 16px;
  border-radius: 11px;
  color: white;
  background: #17233a;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: .2s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (min-width: 821px) {
  .nav-site {
    justify-content: flex-end;
  }
  body.is-authenticated .nav-site {
    justify-content: center;
  }
}

@media (max-width: 820px) {
  .header {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .header > .brand {
    grid-column: 1;
    grid-row: 1;
  }
  .menu-button {
    display: block;
    grid-column: 2;
    grid-row: 1;
  }
  .header-account { display: none !important; }
  .nav-site {
    display: none;
    position: absolute;
    z-index: 10;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: min(340px, calc(100vw - 28px));
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .nav-site.open { display: grid; gap: 10px; }
  .mobile-account {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }
  .mobile-account .account-link { width: 100%; }
  .mobile-account .account-copy strong { max-width: 170px; }
  .mobile-account [data-auth-logout] {
    min-height: 46px;
    padding: 0 13px;
    font-size: 13px;
  }
  .nav-site .nav-guest {
    display: grid;
    gap: 10px;
    margin: 4px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }
  .nav-site .nav-guest .button { width: 100%; }
  .hero, .auth-layout { grid-template-columns: 1fr; }
  .hero { margin-top: 42px; gap: 42px; }
  .answer-card { transform: none; }
  .feature-grid, .app-grid { grid-template-columns: 1fr; }
  .project-form { grid-template-columns: 1fr; }
  .project-fields { grid-template-columns: 1fr; }
  .project-form .form-error { grid-column: 1; }
  .workspace-head { align-items: stretch; flex-direction: column; }
  .workspace-layout { grid-template-columns: 1fr; }
  .workspace-stages { display: flex; overflow-x: auto; }
  .workspace-stages button { flex: 0 0 185px; }
  .cta-section { align-items: flex-start; flex-direction: column; }
  .auth-message { text-align: center; }
  .trust-list { justify-content: center; text-align: left; }
}

@media (max-width: 560px) {
  .header, .footer, .hero, .section, .auth-layout, .app-page, .legal { width: min(100% - 28px, 1180px); }
  .header {
    min-height: 68px;
  }
  .hero { margin-bottom: 74px; }
  h1 { font-size: 43px; }
  .hero-copy > p { font-size: 17px; }
  .feature-grid { gap: 12px; }
  .auth-card, .legal { padding: 23px; }
  .auth-layout { margin-top: 28px; }
  .app-top, .footer { align-items: flex-start; flex-direction: column; }
  .project-grid { grid-template-columns: 1fr; }
  .workspace-content { padding: 18px; }
  .workspace-title { display: block; }
  .workspace-pill { display: inline-block; margin-top: 12px; }
  .workspace-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-chat-form { grid-template-columns: 1fr; }
  .workspace-messages article { width: 94%; }
  .footer-links { justify-content: flex-start; }
}
