@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Mono:wght@500&display=swap");

:root {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --text: #111111;
  --muted: #5f5f5f;
  --line: #dedede;
  --line-strong: #bdbdbd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  background: var(--bg);
  position: relative;
}

body::before {
  display: none;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 44px 24px 56px;
  position: relative;
  z-index: 1;
}

.hero {
  margin-bottom: 22px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  margin: 0;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

h1 {
  margin: 10px 0;
  font-size: clamp(2.1rem, 5.8vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: lowercase;
}

.subtitle {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.06rem;
}

.locale-switch {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.locale-btn {
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #111111;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 42px;
}

.locale-btn.is-active {
  background: #111111;
  color: #ffffff;
}

.collections-card {
  margin-top: 18px;
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 22px;
  background: var(--surface);
}

.collections-head {
  margin-bottom: 10px;
}

.collections-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.collections-head h2 {
  margin: 0;
  font-size: 1.2rem;
  text-transform: lowercase;
}

.collections-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.collections-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.collections-refresh-btn {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: #111111;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.collections-refresh-btn:hover {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

.chat-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 22px;
  background: var(--surface);
  display: grid;
  gap: 24px;
}

.story-stage {
  display: block;
  width: 100%;
  transition: transform 260ms ease, opacity 260ms ease;
}

.story-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.72fr);
  gap: 28px;
  align-items: start;
}

.story-narrative {
  padding: 4px 0;
}

.story-view-card {
  position: sticky;
  top: 20px;
  width: 100%;
  max-width: 440px;
  height: auto;
  aspect-ratio: auto;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 4px;
  background: #f8f8f8;
  padding: 40px 30px 30px;
  overflow: visible;
  transition: transform 220ms ease;
}

.story-view-card.is-loading .story-view-title,
.story-view-card.is-loading .story-view-theses,
.story-view-card.is-loading .story-view-text,
.story-view-card.is-loading .story-view-footer {
  filter: blur(1.8px);
  opacity: 0.52;
  transition: filter 0.5s ease, opacity 0.5s ease;
}

.story-loading-indicator {
  display: none !important;
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.94);
  padding: 10px 12px;
}

.story-loading-bar {
  height: 2px;
  width: 100%;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    rgba(40, 40, 40, 0.22) 0%,
    rgba(40, 40, 40, 0.72) 50%,
    rgba(40, 40, 40, 0.22) 100%
  );
  animation: story-loading-pulse 1.15s ease-in-out infinite;
}

.story-loading-text {
  margin: 8px 0 0;
  color: #565656;
  font-size: 0.86rem;
  letter-spacing: 0.01em;
  text-transform: lowercase;
}

.story-view-line {
  display: none;
}

.story-view-eyebrow {
  margin: 0 0 16px;
  font-size: clamp(1.45rem, 4.2vw, 2.45rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 0.92;
  text-transform: lowercase;
}

.story-view-title {
  margin: 0 0 22px;
  font-size: clamp(1.25rem, 2.4vw, 1.88rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
  max-width: 20ch;
  text-transform: none;
}

.story-view-text {
  margin: 0;
  color: #151515;
  font-size: clamp(1.08rem, 1.65vw, 1.34rem);
  line-height: 1.72;
  letter-spacing: -0.01em;
  max-width: none;
}

.story-view-detail-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 18px;
}

.story-view-detail-item {
  margin: 0;
}

.story-view-detail-year {
  margin: 0 0 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1a1a;
}

.story-view-detail-title {
  margin: 0 0 6px;
  font-size: clamp(1.1rem, 1.7vw, 1.42rem);
  font-weight: 700;
  line-height: 1.3;
}

.story-view-detail-text {
  margin: 0;
  font-size: clamp(1.02rem, 1.4vw, 1.2rem);
  line-height: 1.64;
  color: #252525;
}

.story-view-theses {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  max-width: 34ch;
}

.story-view-thesis {
  margin: 0;
  font-size: clamp(1rem, 1.75vw, 1.28rem);
  line-height: 1.34;
  color: #181818;
  opacity: 0;
  transform: translateY(10px);
  animation: thesis-rise 420ms ease forwards;
  animation-delay: var(--story-delay, 0ms);
}

.story-view-thesis-year {
  font-weight: 700;
}

.story-view-footer {
  margin: 22px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-view-footer-domain {
  margin: 0;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 4px;
  background: #0f0f0f;
  color: #f8f8f8;
  font-size: clamp(0.8rem, 1.2vw, 0.92rem);
  font-weight: 700;
  letter-spacing: 0.015em;
}

.story-view-footer-cta {
  margin: 0;
  font-size: 0.86rem;
  color: #3a3a3a;
  max-width: 20ch;
  line-height: 1.25;
}

.story-view-card.story-enter {
  animation: story-rise 360ms ease;
}

@keyframes story-rise {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes thesis-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes story-loading-pulse {
  0% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-view-card.story-enter,
  .story-view-thesis {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

.story-actions {
  position: static;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.story-action-btn {
  min-width: 168px;
}

.story-action-secondary {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: #111111;
}

.story-action-secondary:hover {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

.form {
  display: grid;
  gap: 10px;
}

.global-loading-indicator {
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #ffffff;
  padding: 10px 12px;
}

.global-loading-bar {
  height: 3px;
  width: 100%;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    rgba(20, 20, 20, 0.15) 0%,
    rgba(20, 20, 20, 0.85) 50%,
    rgba(20, 20, 20, 0.15) 100%
  );
  animation: story-loading-pulse 1.1s ease-in-out infinite;
}

.global-loading-text {
  margin: 8px 0 0;
  font-size: 0.95rem;
  color: #2a2a2a;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: lowercase;
}

label {
  font-weight: 700;
  font-size: 1.05rem;
}

.input-shell {
  position: relative;
  background: transparent;
  border-radius: 0;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 14px 58px 62px 14px;
  font: inherit;
  min-height: 120px;
  background: transparent;
  color: var(--text);
}

textarea:focus {
  outline: none;
  border-color: #1a1a1a;
  box-shadow: none;
}

button {
  border-radius: 4px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  border: 1px solid #111111;
  background: #111111;
  color: #ffffff;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

#submit-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
}

.ghost-btn,
.branch-btn {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: #111111;
  padding: 8px 13px;
  font-size: 0.9rem;
  font-weight: 600;
}

.ghost-btn:hover,
.branch-btn:hover {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

.collection-btn {
  border: 0;
  background: rgba(0, 0, 0, 0.03);
  color: #131313;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 600;
}

.collection-btn:hover {
  border-color: transparent;
  background: rgba(0, 0, 0, 0.08);
  color: #111111;
  transform: scale(1.02);
}

.chat-window {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.messages {
  display: grid;
  gap: 12px;
  max-height: none;
  overflow: visible;
}

.message {
  border-radius: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
}

.message.user {
  background: #f1f1f1;
}

.message.assistant {
  background: #ffffff;
}

.scenario-message {
  padding: 0;
  border: 0;
  background: transparent;
}

.scenario-message-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  padding: 22px 18px 18px 24px;
  overflow: hidden;
}

.scenario-message-line {
  display: none;
}

.scenario-message-eyebrow {
  margin: 0 0 10px;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.scenario-message-title {
  margin: 0 0 12px;
  font-size: 1.34rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
}

.scenario-message-theses {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.scenario-message-thesis {
  margin: 0;
  font-size: 1rem;
  line-height: 1.32;
  color: #191919;
}

.scenario-message-year {
  font-weight: 700;
}

.scenario-message-alt {
  margin-top: 12px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.045);
  padding: 10px 12px;
}

.scenario-message-alt-label {
  margin: 0 0 6px;
  font-size: 0.96rem;
  font-weight: 700;
}

.scenario-message-alt-text {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.35;
  color: #242424;
}

.scenario-message-footer {
  margin: 14px 0 0;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 4px;
  background: #0f0f0f;
  color: #f8f8f8;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 7px;
  color: var(--muted);
}

.body {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.section-title {
  margin: 12px 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.year-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  position: static;
}

.year-timeline::before {
  display: none;
}

.year-item {
  display: block;
  position: static;
  padding-left: 0;
}

.year-item::before {
  display: none;
}

.year-badge {
  position: static;
  width: auto;
  border: 0;
  background: transparent;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: left;
  padding: 0;
  color: #111111;
  font-family: "IBM Plex Mono", monospace;
}

.year-content {
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.year-title {
  margin: 0 0 3px;
  font-size: 0.92rem;
  font-weight: 700;
}

.year-details {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #262626;
}

.branch-box {
  margin-top: 8px;
}

.message-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

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

.branch-btn:disabled {
  opacity: 0.55;
}

.history-card {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  background: var(--surface);
}

.history-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.history-head h2 {
  margin: 0;
  font-size: 1.15rem;
  text-transform: lowercase;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  background: #ffffff;
}

.history-item h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.history-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.history-preview {
  margin: 8px 0;
  color: #2a2a2a;
  font-size: 0.93rem;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-empty {
  margin: 0;
  color: var(--muted);
}

.note {
  margin: 14px 2px 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.share-panel {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.share-panel[hidden] {
  display: none !important;
}

.share-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 500px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8f8f8;
  padding: 12px;
  margin-bottom: 20px;
}

.share-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.share-top h3 {
  margin: 0;
  font-size: 1rem;
}

.share-hint {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.share-preview {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 10px;
}

.share-overline {
  margin: 0;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  font-size: 0.7rem;
  color: var(--muted);
}

.share-event {
  margin: 6px 0 4px;
  font-weight: 700;
}

.share-summary {
  margin: 0;
  color: #303030;
  font-size: 0.9rem;
}

.share-link-label {
  margin: 10px 0 6px;
  font-size: 0.84rem;
  color: var(--muted);
}

.share-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.share-input {
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
  color: #111;
  min-width: 0;
}

.share-actions {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 500px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 2px;
}

.share-action-btn {
  min-height: 54px;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 14px;
}

.share-action-primary {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

.share-action-secondary {
  background: #ffffff;
  color: #111111;
  border-color: var(--line-strong);
}

.share-action-secondary:hover {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

.share-status {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 500px;
  margin: 4px 0 0;
  min-height: 1.2em;
  font-size: 0.82rem;
  color: #f1f1f1;
  text-align: center;
}

body.share-open {
  overflow: hidden;
}

#share-card-template {
  position: fixed;
  left: -99999px;
  top: 0;
  width: 1080px;
  height: 1920px;
  pointer-events: none;
}

.story-card {
  position: relative;
  width: 1080px;
  height: 1920px;
  padding: 120px 100px 100px 120px;
  background: #0b0b0b;
  color: #f0f0f0;
  font-family: "Space Grotesk", sans-serif;
  overflow: hidden;
}

/* Декоративная вертикальная линия слева */
.story-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(180deg, #7df9e8 0%, #5bc8f5 50%, #a78bfa 100%);
}

/* Фоновый паттерн — тонкая сетка */
.story-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(125,249,232,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125,249,232,0.04) 1px, transparent 1px);
  background-size: 80px 80px;
  pointer-events: none;
}

.story-line {
  display: none;
}

.story-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 1680px;
  max-height: 1680px;
  overflow: hidden;
  padding-bottom: 40px;
  position: relative;
  z-index: 1;
}

.story-eyebrow {
  margin: 0 0 28px;
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
  color: #7df9e8;
}

.story-event-title {
  margin: 0 0 44px;
  font-size: 68px;
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.story-theses {
  margin: 0;
  padding: 0;
  max-width: 820px;
  list-style: none;
  display: grid;
  gap: 0;
}

.story-thesis-item {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #e8e8e8;
  padding: 26px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  position: relative;
}

.story-thesis-item:first-child {
  border-top: 1px solid rgba(255,255,255,0.1);
}

.story-thesis-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.08;
}

.story-thesis-year {
  font-weight: 700;
  color: #7df9e8;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.story-thesis-title {
  font-weight: 700;
  color: #ffffff;
}

.story-thesis-details {
  font-size: 31px;
  font-weight: 400;
  line-height: 1.42;
  color: #b0b0b0;
}

.story-footer {
  position: absolute;
  left: 120px;
  right: auto;
  bottom: 72px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 1;
}

.story-footer-domain {
  margin: 0;
  display: inline-flex;
  align-items: center;
  padding: 14px 28px;
  border-radius: 6px;
  background: #7df9e8;
  color: #0b0b0b;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.story-footer-cta {
  margin: 0;
  color: #7a7a7a;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

@media (max-width: 760px) {
  .page {
    padding: 20px 12px 56px;
  }

  .chat-card,
  .history-card {
    padding: 14px;
  }

  .collections-card {
    padding: 14px;
  }

  .collections-grid {
    gap: 8px;
  }

  .history-actions .ghost-btn,
  .history-head .ghost-btn,
  .branch-btn,
  .share-action-btn,
  .story-action-btn {
    width: 100%;
  }

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

  .hero-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .collections-head-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .story-actions {
    width: 100%;
    flex-direction: column;
    justify-content: stretch;
  }

  .story-view-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .story-view-footer-cta {
    max-width: none;
  }

  .year-item {
    padding-left: 52px;
  }
}

@media (max-width: 980px) {
  .story-layout {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .story-view-card {
    position: static;
    order: 1;
    max-width: none;
  }

  .story-narrative {
    order: 2;
  }
}
