:root {
  color-scheme: light;
  --bg: #f7fbf4;
  --panel: rgba(255, 252, 244, 0.9);
  --panel-2: #fffdf7;
  --text: #1f2f2c;
  --muted: #66736e;
  --line: rgba(31, 47, 44, 0.18);
  --accent: #d96f32;
  --accent-2: #2f7a6b;
  --accent-3: #3f6f58;
  --sun: #f7c96d;
  --mint: #70bda7;
  --danger: #b85d35;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 8%, rgba(247, 201, 109, 0.36), transparent 18rem),
    radial-gradient(circle at 88% 12%, rgba(112, 189, 167, 0.22), transparent 20rem),
    linear-gradient(135deg, #f7fbf4 0%, #fffdf7 48%, #eef7f1 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(63, 111, 88, 0.13), rgba(247, 201, 109, 0.1), rgba(217, 111, 50, 0.08));
  mask-image: linear-gradient(to bottom, black, transparent 48%);
}

button,
input,
select,
textarea {
  font: inherit;
  position: relative;
  z-index: 1;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.96);
  color: var(--text);
  cursor: pointer;
  min-height: 42px;
  padding: 0.7rem 0.9rem;
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.primary {
  background: linear-gradient(135deg, #2f7a6b, #70bda7);
  border-color: transparent;
  color: #ffffff;
  font-weight: 800;
}

a {
  color: var(--text);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  color: var(--accent);
  outline: none;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

.mission-panel,
.workspace,
.action-panel,
.offer-panel,
.opportunity-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(31, 47, 44, 0.14);
  backdrop-filter: blur(12px);
}

.mission-panel {
  display: grid;
  grid-template-columns: minmax(620px, 1.08fr) minmax(420px, 0.92fr);
  gap: 0;
  padding: 0;
  margin-bottom: 1rem;
  border-top: 5px solid var(--accent-2);
  overflow: hidden;
}

.hero-image {
  min-height: 720px;
  margin: 0;
  position: relative;
  background:
    radial-gradient(circle at 20% 15%, rgba(247, 201, 109, 0.28), transparent 18rem),
    linear-gradient(135deg, #fff6d9 0%, #e6f4e9 58%, #d9efe9 100%);
  padding: 0;
  overflow: hidden;
}

.hero-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 70%, rgba(31, 47, 44, 0.1));
  pointer-events: none;
}

.hero-image img {
  width: 100%;
  height: 100%;
  min-height: 720px;
  display: block;
  object-fit: cover;
  object-position: 50% 44%;
}

.hero-content {
  display: grid;
  align-content: center;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 2rem);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.92), rgba(244, 250, 241, 0.9));
}

.eyebrow,
.label {
  color: var(--accent-3);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.5rem);
  line-height: 0.98;
  max-width: 13ch;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.2rem;
  margin-bottom: 0;
}

.intro {
  color: var(--muted);
  max-width: 34rem;
  font-size: 1.05rem;
  line-height: 1.55;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1rem 0;
}

.status-strip span,
.hero-actions a {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.82);
  padding: 0.58rem 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-strip strong {
  color: var(--text);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hero-actions .primary-link {
  background: linear-gradient(135deg, #2f7a6b, #70bda7);
  border-color: transparent;
  color: #ffffff;
  font-weight: 800;
}

.hero-actions .buy-link,
.offer-buy {
  background: linear-gradient(135deg, #d96f32, #f7c96d);
  border-color: transparent;
  color: #1f2f2c;
  font-weight: 900;
}

.mission-form {
  display: grid;
  gap: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 247, 0.72);
  padding: 1rem;
  box-shadow: 0 18px 50px rgba(31, 47, 44, 0.1);
  position: relative;
  z-index: 2;
}

.ready-status {
  margin: 0;
  border: 1px solid rgba(217, 111, 50, 0.24);
  border-radius: 8px;
  background: rgba(247, 201, 109, 0.18);
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 760;
  padding: 0.55rem 0.65rem;
}

html[data-jack-ready="true"] .ready-status {
  border-color: rgba(47, 122, 107, 0.26);
  background: rgba(112, 189, 167, 0.14);
  color: var(--accent-3);
}

html[data-jack-ready="true"] .ready-status::before {
  content: "Jack controls ready";
}

html[data-jack-ready="true"] .ready-status {
  font-size: 0;
}

html[data-jack-ready="true"] .ready-status::before {
  font-size: 0.88rem;
}

.jack-loop {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
}

.jack-loop span {
  border: 1px solid rgba(47, 122, 107, 0.22);
  border-radius: 999px;
  background: rgba(112, 189, 167, 0.13);
  color: var(--accent-3);
  font-size: 0.78rem;
  font-weight: 850;
  padding: 0.44rem 0.5rem;
  text-align: center;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.92);
  color: var(--text);
  padding: 0.75rem 0.8rem;
  min-height: 42px;
}

select {
  appearance: auto;
  background-color: #fffdf7;
  cursor: pointer;
  font-weight: 760;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent-2);
  outline: none;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.suggestion-row button {
  min-height: 34px;
  border-color: rgba(47, 122, 107, 0.24);
  background: rgba(255, 253, 247, 0.9);
  color: var(--accent-3);
  font-size: 0.86rem;
  font-weight: 760;
  padding: 0.45rem 0.62rem;
}

.project-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
}

.project-controls button {
  min-height: 38px;
  padding: 0.55rem 0.65rem;
  font-size: 0.88rem;
  font-weight: 800;
}

.project-controls button[data-project="save"] {
  border-color: rgba(47, 122, 107, 0.34);
  background: rgba(112, 189, 167, 0.16);
}

.project-controls button[data-project="addon"] {
  border-color: rgba(217, 111, 50, 0.34);
  background: rgba(247, 201, 109, 0.18);
}

.danger-button {
  border-color: rgba(184, 93, 53, 0.38);
  background: rgba(184, 93, 53, 0.1);
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  min-height: 660px;
  overflow: hidden;
}

.action-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 280px;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem;
}

.offer-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem;
  background:
    linear-gradient(135deg, rgba(47, 122, 107, 0.12), rgba(247, 201, 109, 0.2)),
    var(--panel);
}

.offer-panel p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0.85rem;
}

.offer-buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: 0 14px 28px rgba(217, 111, 50, 0.18);
}

.offer-panel ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.offer-panel li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.78);
  color: var(--text);
  padding: 0.8rem;
  font-weight: 750;
}

.opportunity-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background:
    radial-gradient(circle at 5% 0%, rgba(247, 201, 109, 0.3), transparent 18rem),
    linear-gradient(135deg, rgba(255, 253, 247, 0.92), rgba(230, 244, 233, 0.88));
}

.opportunity-intro {
  align-self: center;
}

.opportunity-intro p {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
}

.opportunity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.opportunity-grid button {
  display: grid;
  gap: 0.45rem;
  min-height: 132px;
  padding: 0.9rem;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(247, 251, 244, 0.88));
}

.opportunity-grid button:hover,
.opportunity-grid button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(31, 47, 44, 0.12);
}

.opportunity-grid strong {
  color: var(--text);
  font-size: 1rem;
}

.opportunity-grid span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.42;
}

.action-panel p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0;
}

.action-panel figure {
  margin: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #223531;
}

.action-panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 28%;
  display: block;
}

.map,
.asset-panel {
  background: rgba(244, 250, 241, 0.72);
  padding: 1rem;
}

.map {
  border-right: 1px solid var(--line);
}

.asset-panel {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.map-card {
  border-bottom: 1px solid var(--line);
  padding: 0 0 1rem;
  margin-bottom: 1rem;
}

.map-card p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0.45rem 0 0;
}

.path-list {
  margin: 0.7rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.path-list li {
  margin-bottom: 0.55rem;
}

.thread {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-width: 0;
}

.bot-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(47, 122, 107, 0.14), rgba(247, 201, 109, 0.18)),
    rgba(255, 253, 247, 0.72);
  padding: 0.8rem 1rem;
}

.avatar-balloon {
  position: relative;
  align-self: flex-start;
  min-height: 0;
  margin-left: -0.45rem;
  padding: 0.5rem 0.65rem;
  border-color: rgba(217, 111, 50, 0.34);
  background: rgba(247, 201, 109, 0.18);
  color: var(--accent-3);
  font-weight: 850;
  line-height: 1.05;
  white-space: nowrap;
}

.avatar-balloon::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 14px;
  width: 12px;
  height: 12px;
  border-left: 1px solid rgba(217, 111, 50, 0.34);
  border-bottom: 1px solid rgba(217, 111, 50, 0.34);
  background: #fcf4db;
  transform: rotate(45deg);
}

.avatar-balloon span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
}

.bot-header h2,
.bot-header p {
  margin: 0;
}

.bot-header p {
  color: var(--muted);
  line-height: 1.4;
}

.jack-avatar {
  position: relative;
  width: 82px;
  height: 82px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.jack-avatar img {
  position: relative;
  z-index: 2;
  width: 72px;
  height: 72px;
  object-fit: cover;
  object-position: 48% 30%;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 34px rgba(47, 122, 107, 0.22);
  animation: avatar-breathe 3s ease-in-out infinite;
}

.jack-avatar .pulse {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(47, 122, 107, 0.38);
  border-radius: 50%;
  animation: avatar-pulse 2.2s ease-out infinite;
}

.jack-avatar.thinking img {
  animation: avatar-thinking 0.8s ease-in-out infinite;
}

.messages {
  padding: 1rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.message {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem;
  background: rgba(255, 253, 247, 0.86);
  max-width: 860px;
}

.message p {
  line-height: 1.5;
  margin: 0.4rem 0 0;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: rgba(112, 189, 167, 0.16);
}

.message.jack strong {
  color: var(--accent-3);
}

.choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  border-top: 1px solid var(--line);
  padding: 0.75rem;
}

.choices button[data-action="return"] {
  border-color: var(--danger);
}

.choices button[data-action="create"] {
  border-color: var(--accent);
}

.reply-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  border-top: 1px solid var(--line);
  padding: 0.75rem;
}

.asset-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.asset-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.asset-actions button {
  min-height: 38px;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  font-weight: 800;
}

.asset-actions button[data-asset="clear"] {
  border-color: rgba(184, 93, 53, 0.38);
  background: rgba(184, 93, 53, 0.1);
  color: var(--danger);
}

pre {
  flex: 1;
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 247, 0.86);
  padding: 1rem;
  color: var(--text);
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.jr-guide {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  align-items: end;
  gap: 0.75rem;
  max-width: min(94vw, 520px);
}

.jr-guide:not(.open) {
  max-width: 82px;
}

.jr-guide-icon {
  position: relative;
  width: 82px;
  height: 82px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 16px 50px rgba(31, 47, 44, 0.24);
  overflow: hidden;
  padding: 0;
}

.jr-guide-icon::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(47, 122, 107, 0.3);
  border-radius: 50%;
  animation: avatar-pulse 2.4s ease-out infinite;
}

.jr-guide-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 48% 30%;
}

.jr-guide-panel {
  width: 420px;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(244, 250, 241, 0.94));
  box-shadow: 0 18px 70px rgba(31, 47, 44, 0.2);
  padding: 1rem;
  backdrop-filter: blur(10px);
  transform-origin: bottom right;
  transform: scale(1);
  opacity: 1;
  transition: transform 160ms ease, opacity 160ms ease;
}

.jr-guide:not(.open) .jr-guide-panel {
  transform: scale(0.92);
  opacity: 0;
  pointer-events: none;
}

.jr-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.jr-guide-panel p {
  color: #3f4f4a;
  font-size: 0.98rem;
  line-height: 1.5;
}

.jr-task-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(47, 122, 107, 0.1), rgba(247, 201, 109, 0.18));
  padding: 0.75rem;
  margin: 0.75rem 0;
}

.jr-task-card p {
  margin: 0.3rem 0 0;
}

.jr-route-label {
  display: block;
  color: var(--accent-3);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.jr-guide-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.jr-guide-actions button {
  min-height: 38px;
  padding: 0.5rem;
  background: rgba(255, 253, 247, 0.88);
  font-size: 0.86rem;
  text-align: left;
}

.jr-guide-actions button[data-guide="return"] {
  grid-column: 1 / -1;
  border-color: var(--accent-2);
  font-weight: 800;
}

@keyframes avatar-breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-2px) scale(1.035);
  }
}

@keyframes avatar-pulse {
  0% {
    opacity: 0.65;
    transform: scale(0.84);
  }
  100% {
    opacity: 0;
    transform: scale(1.38);
  }
}

@keyframes avatar-thinking {
  0%,
  100% {
    transform: rotate(-1deg) scale(1.02);
  }
  50% {
    transform: rotate(1deg) scale(1.08);
  }
}

@keyframes ear-left {
  0%,
  100% {
    transform: rotate(-18deg);
  }
  50% {
    transform: rotate(-8deg);
  }
}

@keyframes ear-right {
  0%,
  100% {
    transform: rotate(18deg);
  }
  50% {
    transform: rotate(8deg);
  }
}

@media (max-width: 1120px) {
  .mission-panel,
  .workspace,
  .action-panel,
  .offer-panel,
  .opportunity-panel {
    grid-template-columns: 1fr;
  }

  .hero-image {
    min-height: 0;
  }

  .hero-image img {
    width: min(100%, 520px);
    height: auto;
    min-height: 0;
    max-height: none;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(31, 47, 44, 0.18);
  }

  .workspace {
    min-height: auto;
  }

  .map,
  .asset-panel {
    border: 0;
  }

  .action-panel figure {
    max-height: 420px;
  }

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

@media (max-width: 720px) {
  .shell {
    padding: 0.5rem;
  }

  .mission-panel {
    padding: 1rem;
  }

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

  .field-grid,
  .choices,
  .reply-form,
  .project-controls,
  .offer-panel ul,
  .opportunity-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: 100%;
    font-size: 2.4rem;
  }

  .jr-guide {
    left: auto;
    right: 0.5rem;
    bottom: 0.5rem;
    align-items: end;
  }

  .jr-guide.open {
    left: 0.5rem;
  }

  .jr-guide-panel {
    width: 100%;
    max-height: 70vh;
  }

  .bot-header {
    flex-wrap: wrap;
  }

  .avatar-balloon {
    order: 2;
  }

  .bot-header > div:not(.jack-avatar) {
    flex: 1 1 100%;
    order: 3;
  }

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