:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-strong: #eceef2;
  --surface: rgba(255, 255, 255, 0.8);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --surface-muted: rgba(246, 247, 249, 0.92);
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(10, 132, 255, 0.22);
  --text: #101214;
  --muted: #68707d;
  --accent: #0a84ff;
  --accent-strong: #0066d8;
  --accent-soft: rgba(10, 132, 255, 0.1);
  --success: #2fa36b;
  --danger: #d94f44;
  --shadow: 0 18px 44px rgba(17, 24, 39, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(circle at top left, rgba(10, 132, 255, 0.12), transparent 30%),
    radial-gradient(circle at top right, rgba(92, 200, 250, 0.14), transparent 28%),
    linear-gradient(180deg, #f8f9fb 0%, #f2f4f7 48%, #eceff3 100%);
  color: var(--text);
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(18px);
}

body::before {
  top: 72px;
  left: -30px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(10, 132, 255, 0.12);
}

body::after {
  top: 260px;
  right: -42px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  border: 0;
  appearance: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100% - 16px, 460px);
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) 0 calc(106px + var(--safe-bottom));
}

main,
.workspace,
.dashboard-strip,
.catalog-grid,
.history-grid,
.stack,
.tool-form,
.preview-stage,
.catalog-column,
.history-grid > div {
  display: grid;
  gap: 14px;
}

.topbar,
.hero-copy,
.status-banner,
.summary-card,
.overview-card,
.panel,
.tool-card,
.history-card,
.preview-stage,
.intent-stage,
.workspace-nav,
.toast {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.topbar,
.hero-copy,
.panel,
.preview-stage,
.intent-stage {
  border-radius: var(--radius-xl);
}

.summary-card,
.overview-card,
.tool-card,
.history-card,
.status-banner {
  border-radius: var(--radius-md);
}

.topbar {
  position: sticky;
  top: calc(8px + var(--safe-top));
  z-index: 18;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.topbar-intro,
.topbar-side,
.hero-intro,
.hero-summary,
.intent-stage-main,
.intent-stage-copy {
  display: grid;
  gap: 10px;
}

.topbar-intro strong {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.topbar-intro span,
.mode-badge,
.panel-note,
.hero-text,
.summary-card-note,
.overview-card p,
.tool-card p,
.history-card p,
.inline-note,
.preview-copy,
.preview-subcopy,
.file-hint,
.file-status,
.catalog-column-note,
.empty-state {
  color: var(--muted);
}

.topbar-intro span,
.mode-badge,
.panel-note,
.hero-text,
.summary-card-note,
.overview-card p,
.tool-card p,
.history-card p,
.inline-note,
.preview-copy,
.preview-subcopy,
.file-hint,
.file-status,
.catalog-column-note {
  line-height: 1.55;
}

.topbar-actions,
.hero-actions,
.hero-steps,
.hero-shortcuts,
.quick-actions,
.tool-meta,
.preview-facts,
.preview-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-badge,
.nav-pill,
.ghost-button,
.secondary-link,
.tiny-button,
.tool-card-badge,
.history-badge,
.tool-meta span,
.file-pill,
.preview-facts span,
.preview-metrics span,
.overview-card-price,
.hero-steps span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
}

.ghost-button,
.secondary-link,
.tiny-button,
.nav-pill,
.primary-button,
.file-trigger {
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.ghost-button,
.secondary-link,
.tiny-button {
  color: var(--text);
  cursor: pointer;
}

.ghost-button,
.secondary-link {
  min-height: 48px;
  padding: 0 18px;
}

.tiny-button {
  min-height: 38px;
  padding: 0 14px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 22px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(10, 132, 255, 0.26);
}

.primary-button:hover,
.ghost-button:hover,
.secondary-link:hover,
.tiny-button:hover,
.nav-pill:hover,
.file-field:hover .file-trigger {
  transform: translateY(-1px);
}

.ghost-button:hover,
.secondary-link:hover,
.tiny-button:hover,
.nav-pill:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.92);
}

.hero {
  padding-top: 4px;
}

.hero-copy {
  padding: 22px 18px;
  background:
    radial-gradient(circle at top right, rgba(10, 132, 255, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.9));
}

.hero-main,
.tool-layout {
  display: grid;
  gap: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1,
.panel-header h2,
.intent-stage h3,
.preview-stage h3,
.tool-card h4,
.history-card h4 {
  margin: 0;
  letter-spacing: -0.045em;
}

.hero h1 {
  font-size: clamp(2.2rem, 8vw, 2.9rem);
  line-height: 0.98;
  max-width: 11ch;
}

.hero-text {
  margin: 0;
  font-size: 1rem;
}

.hero-actions {
  display: grid;
  grid-template-columns: 1fr;
}

.hero-actions .secondary-link,
.hero-actions .primary-button {
  width: 100%;
}

.hero-steps span,
.tool-meta span,
.file-pill,
.preview-facts span,
.preview-metrics span {
  justify-content: flex-start;
  min-height: 34px;
  padding: 8px 12px;
  font-size: 0.91rem;
}

.hero-shortcuts {
  gap: 8px;
}

.hero-shortcuts .tiny-button {
  background: rgba(250, 251, 253, 0.88);
}

.hero-summary {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.hero-metrics,
.summary-grid,
.intent-stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hero-metric,
.summary-card,
.overview-card,
.intent-offer {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
}

.hero-metric strong,
.summary-card-value,
.preview-price {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.05em;
}

.hero-metric span,
.summary-card-label,
.overview-card-label {
  font-size: 0.84rem;
}

.summary-card-label,
.overview-card-label,
.catalog-column h3,
.history-grid h3,
.tool-form label > span {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-feature-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.hero-feature-list li {
  position: relative;
  padding-left: 16px;
  line-height: 1.5;
}

.hero-feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.hero-service-map,
.catalog-overview {
  display: grid;
  gap: 10px;
}

.hero-service-map-item {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(250, 251, 253, 0.82);
}

.hero-service-map-item strong {
  font-size: 0.95rem;
}

.hero-service-map-item span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.dashboard-strip {
  gap: 10px;
}

.status-banner {
  padding: 14px 16px;
  font-size: 0.95rem;
  line-height: 1.55;
}

.status-banner[data-tone="loading"] {
  border-color: rgba(10, 132, 255, 0.18);
  background: rgba(241, 247, 255, 0.92);
}

.status-banner[data-tone="error"] {
  border-color: rgba(217, 79, 68, 0.22);
  background: rgba(255, 245, 244, 0.94);
}

.status-banner[data-tone="ok"] {
  border-color: rgba(47, 163, 107, 0.18);
}

.overview-card h3,
.summary-card-value {
  margin: 0;
}

.overview-card footer,
.panel-header,
.tool-card header,
.history-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.workspace {
  gap: 16px;
}

.intent-stage {
  padding: 18px;
  background:
    radial-gradient(circle at top right, rgba(10, 132, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 248, 250, 0.92));
}

.intent-stage-copy h3 {
  font-size: 1.6rem;
}

.intent-offer header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.workspace-nav {
  position: fixed;
  left: 50%;
  bottom: calc(10px + var(--safe-bottom));
  z-index: 24;
  display: flex;
  gap: 8px;
  width: min(calc(100% - 16px), 460px);
  padding: 10px;
  overflow-x: auto;
  transform: translateX(-50%);
  border-radius: 24px;
  scrollbar-width: none;
}

.workspace-nav::-webkit-scrollbar {
  display: none;
}

.nav-pill {
  flex: 1 0 auto;
  min-width: max-content;
  color: var(--muted);
  cursor: pointer;
}

.nav-pill.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  box-shadow: 0 10px 20px rgba(10, 132, 255, 0.24);
}

.panel {
  display: none;
  padding: 18px;
}

.panel.active {
  display: grid;
  gap: 16px;
}

.panel-header {
  margin-bottom: 2px;
}

.panel-header h2 {
  font-size: 1.8rem;
}

.catalog-grid,
.history-grid {
  grid-template-columns: 1fr;
}

.catalog-column,
.history-grid > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}

.catalog-column h3,
.history-grid h3 {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.catalog-column-note {
  margin: 0;
}

.tool-card,
.history-card {
  min-width: 0;
  padding: 14px;
}

.tool-card.selected,
.intent-offer.selected {
  border-color: var(--line-strong);
  box-shadow: inset 0 0 0 1px rgba(10, 132, 255, 0.12);
}

.tool-card img,
.tool-card video,
.history-card img,
.history-card video,
.preview-stage img,
.preview-stage video {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: cover;
}

.tool-card img,
.preview-stage img {
  aspect-ratio: 4 / 5;
}

.tool-card video,
.preview-stage video,
.history-card video {
  aspect-ratio: 9 / 16;
}

.tool-card header > div,
.history-card header > div,
.intent-offer header > div {
  min-width: 0;
}

.tool-card h4,
.history-card h4 {
  font-size: 1rem;
}

.tool-meta,
.quick-actions,
.preview-facts,
.preview-metrics {
  gap: 8px;
}

.tool-layout {
  gap: 14px;
}

.tool-form {
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}

.tool-form label {
  display: grid;
  gap: 8px;
}

.tool-form label > span {
  font-size: 0.76rem;
  color: var(--muted);
}

.tool-form input,
.tool-form textarea,
.tool-form select {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 14px 15px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.tool-form input:focus,
.tool-form textarea:focus,
.tool-form select:focus {
  outline: none;
  border-color: rgba(10, 132, 255, 0.38);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.12);
}

.tool-form select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 3px),
    calc(100% - 16px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 42px;
}

.tool-form textarea {
  min-height: 124px;
  resize: vertical;
}

.tool-form .primary-button {
  width: 100%;
  position: sticky;
  bottom: calc(88px + var(--safe-bottom));
  z-index: 2;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.inline-note {
  margin: -2px 0 2px;
  font-size: 0.94rem;
}

.file-field {
  position: relative;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
  overflow: hidden;
}

.file-field input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  width: fit-content;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(10, 132, 255, 0.08);
  color: var(--accent-strong);
  font-weight: 700;
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-pill::before {
  content: "•";
  margin-right: 6px;
  color: var(--accent);
}

.preview-stage {
  gap: 12px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 248, 250, 0.92));
}

.preview-stage .empty-state {
  min-height: 220px;
  place-items: center;
}

.preview-stage h3 {
  font-size: 1.45rem;
}

.preview-copy,
.preview-subcopy,
.summary-card-note,
.overview-card p {
  margin: 0;
}

.preview-price {
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  z-index: 30;
  width: min(calc(100% - 24px), 420px);
  padding: 14px 16px;
  transform: translateX(-50%);
  border-radius: 18px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
}

.toast.danger {
  background: rgba(127, 29, 29, 0.92);
}

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

.success {
  color: var(--success);
}

.empty-state {
  padding: 18px 16px;
  border: 1px dashed rgba(15, 23, 42, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
  line-height: 1.5;
}

body.has-focused-intent .hero {
  padding-top: 0;
}

body.has-focused-intent .hero-summary,
body.has-focused-intent .hero-steps,
body.has-focused-intent .hero-shortcuts {
  display: none;
}

body.has-focused-intent .hero-copy {
  padding-bottom: 18px;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.topbar,
.hero-copy,
.status-banner,
.summary-card,
.panel.active,
.intent-stage,
.toast {
  animation: fade-up 260ms ease both;
}

body[data-mode="telegram"] .secondary-link[href*="vk.com"] {
  display: none;
}

@media (min-width: 768px) {
  .app-shell {
    width: min(100% - 24px, 920px);
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .topbar-side {
    justify-items: end;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .hero-main,
  .tool-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
    align-items: start;
  }

  .hero-summary {
    padding-top: 0;
    padding-left: 18px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

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

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

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

  .workspace-nav {
    width: min(calc(100% - 24px), 920px);
  }

  .tool-form .primary-button {
    position: static;
  }

  .preview-stage {
    position: sticky;
    top: 90px;
  }
}

@media (max-width: 767px) {
  .panel-header,
  .overview-card footer,
  .tool-card header,
  .history-card header,
  .intent-offer header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-metrics,
  .summary-grid,
  .intent-stage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: min(100% - 12px, 460px);
  }

  .topbar,
  .hero-copy,
  .panel,
  .tool-form,
  .preview-stage,
  .intent-stage {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero-metrics,
  .summary-grid,
  .intent-stage-grid {
    grid-template-columns: 1fr;
  }

  .workspace-nav {
    width: min(calc(100% - 12px), 460px);
    bottom: calc(6px + var(--safe-bottom));
    padding: 8px;
  }

  .nav-pill {
    min-height: 34px;
    padding-inline: 12px;
    font-size: 0.92rem;
  }

  .toast {
    width: min(calc(100% - 16px), 420px);
    bottom: calc(74px + var(--safe-bottom));
  }
}
