:root {
  color-scheme: light;
  --background: #f8fafc;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;
  --muted: #64748b;
  --muted-surface: #f1f5f9;
  --border: #e2e8f0;
  --input: #cbd5e1;
  --primary: #0f172a;
  --primary-foreground: #ffffff;
  --accent: #eef2ff;
  --accent-foreground: #312e81;
  --destructive: #b91c1c;
  --ring: rgba(15, 23, 42, 0.16);
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  appearance: none;
}

h1,
h2,
h3,
p,
pre {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
}

h3 {
  font-size: 14px;
  line-height: 1.25;
}

.shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(12px);
}

.brand,
.header-actions,
.account,
.button-row,
.staging-header,
.inline-heading {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 0;
}

.brand p,
.section-heading p,
.summary-card small,
.staging-header p,
.pair-code span,
.pair-code small,
#analysisMeta,
#accountMeta {
  color: var(--muted);
}

.brand-logo {
  display: block;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: #020617;
  object-fit: cover;
  object-position: center 38%;
}

.header-actions {
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.account {
  align-items: flex-end;
  flex-direction: column;
  min-width: 0;
}

.account strong,
.account span {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.auth-card,
.panel,
.summary-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow);
}

.auth-card {
  display: grid;
  gap: 18px;
  max-width: 420px;
  margin: 0 auto;
  padding: 22px;
}

.landing-page {
  display: grid;
  gap: 20px;
}

.landing-hero {
  position: relative;
  display: grid;
  min-height: min(560px, calc(100vh - 160px));
  align-items: end;
  overflow: hidden;
  border: 1px solid #dbe4ea;
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.74)),
    linear-gradient(110deg, #0f172a 0%, #0e7490 62%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
}

.hero-copy {
  position: relative;
  z-index: 1;
  display: grid;
  max-width: 760px;
  gap: 20px;
  padding: clamp(28px, 7vw, 72px);
}

.hero-copy h2 {
  max-width: 720px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 640px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 17px;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.landing-hero .button.primary {
  border-color: #5eead4;
  background: #5eead4;
  color: #0f172a;
}

.landing-hero .button.secondary {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.product-preview {
  position: absolute;
  top: 34px;
  right: 28px;
  width: min(620px, 56vw);
  min-height: 400px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.96);
  color: var(--foreground);
  box-shadow: 0 30px 90px rgba(2, 6, 23, 0.34);
  transform: rotate(1.5deg);
}

.preview-toolbar {
  display: flex;
  height: 42px;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.preview-toolbar span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cbd5e1;
}

.preview-toolbar span:first-child {
  background: #14b8a6;
}

.preview-toolbar strong {
  margin-left: 8px;
  font-size: 12px;
}

.preview-body {
  display: grid;
  grid-template-columns: 0.8fr 1fr;
  gap: 14px;
  padding: 16px;
}

.preview-capture,
.preview-analysis {
  display: grid;
  gap: 12px;
}

.preview-screen {
  display: grid;
  min-height: 184px;
  align-content: start;
  gap: 12px;
  padding: 18px;
  border-radius: 10px;
  background: #101827;
}

.code-line {
  height: 10px;
  border-radius: 999px;
  background: #64748b;
}

.code-line.long {
  width: 92%;
}

.code-line.medium {
  width: 72%;
}

.code-line.short {
  width: 48%;
}

.accent-line {
  background: #5eead4;
}

.preview-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 12px;
}

.preview-controls span,
.preview-analysis p,
.preview-analysis small {
  color: var(--muted);
}

.preview-analysis {
  align-content: start;
  min-height: 268px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--muted-surface);
}

.preview-analysis h3 {
  font-size: 18px;
}

.preview-analysis p {
  line-height: 1.55;
}

.analysis-lines {
  display: grid;
  gap: 9px;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
}

.analysis-lines span {
  height: 9px;
  border-radius: 999px;
  background: #cbd5e1;
}

.analysis-lines span:nth-child(2) {
  width: 84%;
}

.analysis-lines span:nth-child(3) {
  width: 62%;
}

.landing-strip,
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.landing-strip article,
.pricing-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.landing-strip span,
.pricing-card p,
.pricing-section .section-heading p {
  color: var(--muted);
  line-height: 1.5;
}

.pricing-section,
.feature-section,
.how-section {
  display: grid;
  gap: 14px;
  padding: 26px 0 4px;
}

.pricing-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pricing-card {
  min-height: 228px;
  align-content: space-between;
  padding: 22px;
}

.pricing-card.featured {
  border-color: #99f6e4;
  background: linear-gradient(180deg, #f0fdfa, #ffffff);
}

.pricing-card strong {
  font-size: 22px;
}

.feature-list,
.how-grid {
  display: grid;
  gap: 14px;
}

.feature-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feature-list article,
.how-grid article {
  display: grid;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.feature-list article {
  align-content: start;
}

.feature-list p,
.how-grid p {
  color: var(--muted);
  line-height: 1.55;
}

.how-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.how-grid article > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius);
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.overview-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.summary-card {
  display: grid;
  min-height: 116px;
  align-content: space-between;
  gap: 10px;
  padding: 16px;
}

.summary-card strong {
  font-size: 15px;
  line-height: 1.35;
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-stack {
  display: grid;
  gap: 14px;
}

.downloads-panel {
  margin-top: 14px;
}

.download-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.download-card {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted-surface);
}

.download-card div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.download-card strong {
  font-size: 14px;
  line-height: 1.3;
}

.download-card small {
  color: var(--muted);
  line-height: 1.45;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.capture-panel {
  min-height: 620px;
}

.section-heading {
  display: grid;
  gap: 4px;
}

.inline-heading {
  justify-content: space-between;
  gap: 14px;
}

.button-row {
  flex-wrap: wrap;
  gap: 8px;
}

.button-group {
  display: inline-flex;
  width: fit-content;
  align-items: stretch;
}

.button-group .button {
  border-radius: 0;
}

.button-group .button:first-child {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}

.button-group .button:last-child {
  margin-left: -1px;
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.agent-key-actions {
  margin-top: 2px;
}

.compact-actions {
  align-items: center;
}

.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.button:hover:not(:disabled) {
  border-color: var(--input);
  background: var(--muted-surface);
}

.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--ring);
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.button.primary:hover:not(:disabled) {
  background: #1e293b;
}

.button.secondary {
  background: var(--muted-surface);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
}

.button.danger {
  color: var(--destructive);
}

.button:disabled {
  cursor: not-allowed;
  border-color: var(--border);
  background: var(--muted-surface);
  color: var(--muted);
  opacity: 1;
}

.auth-form,
.staged-list {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--foreground);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 17px,
    calc(100% - 12px) 17px;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  padding-right: 34px;
}

textarea {
  min-height: 148px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

.staging-header {
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.staged-list {
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
}

.staged-list > p {
  display: grid;
  min-height: 112px;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--muted-surface);
  color: var(--muted);
}

.staged-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 12px;
}

.staged-item img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: calc(var(--radius) - 2px);
  background: #020617;
  object-fit: cover;
}

.staged-item strong {
  font-size: 13px;
}

.pair-code {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-foreground);
}

.pair-code strong {
  font-size: 32px;
  letter-spacing: 0.12em;
}

.agent-key-box strong {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  letter-spacing: 0;
  line-height: 1.5;
}

.pair-code small {
  color: var(--accent-foreground);
}

.result-panel pre {
  min-height: 420px;
  max-height: min(720px, 70vh);
}

pre {
  min-height: 180px;
  overflow: auto;
  border-radius: var(--radius);
  background: var(--muted-surface);
  padding: 14px;
  color: var(--foreground);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(440px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

#toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .overview-grid,
  .landing-strip,
  .pricing-grid,
  .feature-list,
  .how-grid,
  .download-grid {
    grid-template-columns: 1fr;
  }

  .landing-hero {
    align-items: start;
    gap: 22px;
    padding-bottom: 24px;
  }

  .product-preview {
    position: relative;
    top: auto;
    right: auto;
    width: calc(100% - 32px);
    min-height: 0;
    margin: 0 16px;
    transform: none;
  }

  .capture-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-header {
    position: static;
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
  }

  .header-actions {
    align-items: stretch;
    justify-content: flex-start;
  }

  .account {
    align-items: flex-start;
  }

  .workspace {
    padding: 14px;
  }

  .landing-hero {
    min-height: auto;
    border-radius: 12px;
  }

  .hero-copy {
    padding: 20px;
  }

  .hero-copy h2 {
    font-size: 30px;
    line-height: 1.04;
  }

  .hero-copy p {
    font-size: 15px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions .button {
    width: 100%;
  }

  .preview-body {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .preview-screen {
    min-height: 92px;
    gap: 9px;
    padding: 12px;
  }

  .preview-toolbar {
    height: 36px;
  }

  .preview-controls {
    padding: 10px;
  }

  .preview-analysis {
    display: none;
  }

  .inline-heading,
  .staging-header {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row {
    width: 100%;
  }

  .button-row .button {
    flex: 1 1 auto;
  }

  .download-card {
    align-items: stretch;
    flex-direction: column;
  }
}
