:root {
  --font-body: "Inter", "Segoe UI", Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --ink: #241204;
  --ink-soft: rgba(36, 18, 4, 0.76);
  --line: rgba(72, 35, 9, 0.28);
  --line-strong: rgba(72, 35, 9, 0.42);
  --gold: #c8952f;
  --leaf: #315f3d;
  --berry: #9a4d32;
  --panel: rgba(255, 224, 139, 0.2);
  --panel-strong: rgba(255, 224, 139, 0.34);
  --highlight: rgba(255, 238, 174, 0.44);
  --stage-width: min(1080px, 112vw);
  --content-top: clamp(190px, 19vw, 236px);
  --content-bottom: clamp(18px, 3vw, 38px);
  --content-width: min(680px, calc(var(--stage-width) * 0.64), calc(100vw - 150px));
  --content-offset-x: 20px;
  --title-top: clamp(28px, 4.8vw, 58px);
  --title-width: min(900px, calc(100vw - 48px));
  --stage-title-scroll-y: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html.aventara-page {
  background: #29482f;
}

body.aventara-variant {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    linear-gradient(90deg, rgba(7, 24, 17, 0.46), rgba(7, 24, 17, 0.04) 24%, rgba(7, 24, 17, 0.02) 76%, rgba(7, 24, 17, 0.46)),
    url("./assets/aventara-forest-bg-wide.png") center center / cover no-repeat,
    #29482f;
}

@media (max-aspect-ratio: 4 / 5) {
  body.aventara-variant {
    background:
      linear-gradient(90deg, rgba(7, 24, 17, 0.46), rgba(7, 24, 17, 0.04) 24%, rgba(7, 24, 17, 0.02) 76%, rgba(7, 24, 17, 0.46)),
      url("./assets/aventara-forest-bg.png") center top / cover no-repeat,
      #29482f;
  }
}

body.aventara-variant::before,
body.aventara-variant::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body.aventara-variant::before {
  z-index: 0;
  background:
    url("./assets/aventara-tree-stage-cutout.png") center top / var(--stage-width) auto no-repeat;
}

body.aventara-variant::after {
  z-index: 10;
  background:
    url("./assets/aventara-tree-stage-frame.png") center top / var(--stage-width) auto no-repeat;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

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

h1,
h2,
h3,
.aventara-stage-title,
.character-copy strong {
  font-family: var(--font-display);
  letter-spacing: 0;
}

.aventara-stage-title {
  position: fixed;
  top: var(--title-top);
  left: 50%;
  z-index: 12;
  width: var(--title-width);
  pointer-events: none;
  color: #fff2b8;
  font-size: clamp(3.2rem, 7vw, 6.8rem);
  font-weight: 900;
  line-height: 0.9;
  text-align: center;
  text-shadow:
    0 3px 0 #4b2108,
    0 7px 0 rgba(93, 48, 16, 0.66),
    0 12px 18px rgba(31, 13, 3, 0.54),
    0 0 22px rgba(255, 219, 95, 0.44);
  transform: translate(calc(-50% + var(--content-offset-x)), var(--stage-title-scroll-y));
}

.aventara-shell {
  position: fixed;
  z-index: 2;
  top: var(--content-top);
  bottom: var(--content-bottom);
  left: 50%;
  width: var(--content-width);
  margin: 0;
  padding: 0 14px 86px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  transform: translateX(calc(-50% + var(--content-offset-x)));
}

.aventara-shell::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.aventara-intro {
  max-width: 660px;
  margin: 0 auto;
  padding: clamp(18px, 3dvh, 34px) 14px 26px;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 231, 154, 0.48);
}

.eyebrow,
.meta-label,
.message-label {
  margin-bottom: 8px;
  color: rgba(44, 93, 80, 0.9);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.aventara-intro .eyebrow {
  display: none;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 227, 139, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 245, 197, 0.72), 0 5px 12px rgba(67, 32, 8, 0.12);
}

.aventara-intro h1 {
  max-width: 520px;
  margin: 0 auto 14px;
  color: #251204;
  font-size: clamp(1.65rem, 3.5vw, 2.35rem);
  line-height: 1.06;
}

.lede {
  max-width: 560px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.55;
}

.aventara-main,
.setup-grid,
.message-list,
.idea-list,
.archive-preview-list {
  display: grid;
  gap: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0 10px 14px;
  padding: 0 0 12px;
  border-bottom: 1px solid rgba(74, 36, 10, 0.22);
  box-shadow: 0 1px 0 rgba(255, 233, 163, 0.36);
}

.character-choice .section-heading {
  display: block;
  text-align: center;
}

.section-heading h2,
.chat-header h2,
.panel-card h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  line-height: 1.04;
}

.status-pill,
.character-copy span,
.idea-meta span,
.archive-preview-score,
.debug-summary,
.agent-elapsed,
.workflow-status-button {
  border: 1px solid rgba(75, 36, 9, 0.2);
  border-radius: 8px;
  background: rgba(255, 223, 137, 0.34);
  box-shadow: inset 0 1px 0 var(--highlight), inset 0 -1px 0 rgba(77, 37, 9, 0.12);
}

.status-pill {
  flex: 0 0 auto;
  padding: 10px 13px;
  font-weight: 900;
}

.character-choice {
  padding-top: 8px;
}

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

.character-option {
  appearance: none;
  display: grid;
  grid-template-rows: auto minmax(92px, auto);
  gap: 14px;
  width: 100%;
  min-height: 0;
  padding: 12px;
  border: 1px solid rgba(76, 37, 10, 0.34);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 222, 127, 0.22), rgba(88, 43, 12, 0.1));
  box-shadow:
    inset 0 1px 0 rgba(255, 238, 174, 0.45),
    inset 0 -1px 0 rgba(72, 35, 9, 0.18),
    0 7px 12px rgba(48, 22, 5, 0.08);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.character-option:hover {
  transform: translateY(-1px);
  border-color: rgba(200, 149, 47, 0.58);
}

.character-option.is-selected {
  border-color: rgba(165, 111, 29, 0.72);
  background:
    linear-gradient(180deg, rgba(255, 222, 116, 0.32), rgba(108, 133, 58, 0.14));
  box-shadow:
    inset 0 0 0 2px rgba(255, 221, 104, 0.24),
    inset 0 0 26px rgba(96, 49, 13, 0.13),
    0 8px 14px rgba(48, 22, 5, 0.1);
}

.character-image-wrap {
  display: block;
  aspect-ratio: 2 / 3;
  min-height: 0;
  overflow: hidden;
  border: 2px solid rgba(63, 30, 8, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 226, 143, 0.2), rgba(70, 35, 10, 0.12)),
    rgba(58, 31, 12, 0.16);
  box-shadow:
    inset 0 0 0 3px rgba(255, 227, 139, 0.38),
    0 4px 8px rgba(42, 22, 8, 0.12);
}

.character-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

.character-symbol {
  display: grid;
  place-items: center;
  color: rgba(255, 242, 184, 0.94);
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, 4.8rem);
  font-weight: 900;
  line-height: 1;
  text-shadow:
    0 2px 0 rgba(72, 35, 9, 0.72),
    0 7px 16px rgba(42, 22, 8, 0.24);
}

.character-copy {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 2px 2px 6px;
}

.character-copy strong {
  color: var(--ink);
  font-size: clamp(1.45rem, 2.1vw, 2rem);
  line-height: 1.08;
}

.character-copy span,
.idea-meta span {
  width: fit-content;
  max-width: 100%;
  padding: 8px 10px;
  color: rgba(42, 22, 8, 0.86);
  font-weight: 800;
}

.panel-card,
.aventara-chat-card {
  border: 1px solid rgba(76, 37, 10, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(180deg, var(--panel), rgba(111, 61, 17, 0.08));
  box-shadow:
    inset 0 1px 0 rgba(255, 237, 168, 0.5),
    inset 0 -1px 0 rgba(72, 36, 10, 0.22),
    inset 0 0 22px rgba(74, 36, 10, 0.08);
}

.panel-card {
  padding: 22px;
}

.guidance-panel,
.webhook-panel {
  padding: 0;
}

.guidance-panel summary,
.webhook-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px;
  cursor: pointer;
  list-style: none;
}

.guidance-panel summary::-webkit-details-marker,
.webhook-panel summary::-webkit-details-marker {
  display: none;
}

.guidance-panel summary::after,
.webhook-panel summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 223, 137, 0.28);
  font-family: var(--font-body);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.guidance-panel[open] summary::after,
.webhook-panel[open] summary::after {
  content: "-";
}

.guidance-body {
  padding: 0 22px 22px;
}

.webhook-panel summary span {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  font-weight: 900;
  line-height: 1.04;
}

.webhook-panel .field {
  margin: 0 22px 16px;
}

.webhook-panel .field:last-child {
  margin-bottom: 22px;
}

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

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span,
.checkbox-row span {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 850;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid rgba(67, 32, 8, 0.26);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 234, 166, 0.24);
  box-shadow:
    inset 0 2px 8px rgba(54, 25, 7, 0.1),
    inset 0 1px 0 rgba(255, 239, 184, 0.34);
}

.field input {
  min-height: 44px;
  padding: 10px 14px;
}

.field textarea {
  min-height: 140px;
  resize: vertical;
  padding: 12px 14px;
}

.field input[readonly] {
  background: rgba(255, 224, 139, 0.18);
}

.story-id {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 14px;
  padding: 8px 10px;
  overflow-wrap: anywhere;
  border: 1px solid rgba(67, 32, 8, 0.26);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 234, 166, 0.3);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
  font-weight: 750;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.checkbox-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--leaf);
}

.aventara-chat-card {
  position: relative;
  min-height: 620px;
  overflow: hidden;
}

.chat-header,
.composer-actions,
.agent-status-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.chat-header {
  padding: 22px 22px 0;
}

.message-list {
  padding: 18px 22px 22px;
}

.message {
  border: 1px solid rgba(66, 31, 8, 0.16);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 224, 139, 0.18);
}

.message.user {
  background: linear-gradient(140deg, rgba(49, 95, 77, 0.16), rgba(200, 149, 47, 0.2));
}

.workflow-message {
  border-color: rgba(255, 229, 150, 0.34);
  color: #fff1c8;
  background:
    linear-gradient(140deg, rgba(25, 18, 8, 0.76), rgba(36, 63, 43, 0.72)),
    rgba(24, 15, 6, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 236, 177, 0.24),
    inset 0 -1px 0 rgba(5, 18, 12, 0.36),
    0 10px 18px rgba(35, 16, 5, 0.18);
}

.workflow-message .message-label,
.workflow-message .meta-label {
  color: rgba(255, 232, 166, 0.92);
}

.workflow-message .agent-status-text,
.workflow-message .progress-step {
  color: rgba(255, 246, 212, 0.88);
}

.workflow-message .agent-elapsed {
  color: #fff4c9;
  background: rgba(255, 223, 137, 0.14);
  border-color: rgba(255, 232, 166, 0.26);
}

.workflow-message .workflow-status-button {
  color: #fff8dc;
  background: linear-gradient(135deg, rgba(49, 95, 61, 0.96), rgba(91, 74, 28, 0.96));
  border-color: rgba(255, 232, 166, 0.32);
}

.workflow-message .step-dot {
  background: rgba(255, 237, 177, 0.28);
}

.message-copy,
.message p,
.story-summary,
.archive-preview-copy,
.archive-preview-text {
  color: var(--ink-soft);
  line-height: 1.55;
}

.composer {
  display: grid;
  gap: 14px;
  padding: 18px 22px 22px;
  border-top: 1px solid rgba(67, 32, 8, 0.22);
}

.composer-field {
  margin-bottom: 0;
}

.primary-button,
.ghost-button,
.workflow-status-button {
  min-height: 44px;
  border: 2px solid rgba(61, 29, 8, 0.38);
  border-radius: 8px;
  padding: 10px 16px;
  color: #fff8dc;
  font-weight: 900;
  box-shadow:
    0 10px 18px rgba(54, 25, 7, 0.18),
    inset 0 -3px 0 rgba(74, 36, 10, 0.18),
    inset 0 1px 0 rgba(255, 238, 169, 0.62);
}

.primary-button {
  background: linear-gradient(135deg, rgba(43, 87, 45, 0.94), rgba(135, 100, 28, 0.96) 55%, rgba(132, 62, 39, 0.96));
}

.ghost-button {
  color: var(--ink);
  background: linear-gradient(135deg, rgba(255, 227, 142, 0.32), rgba(118, 68, 18, 0.14));
}

.status-pill {
  color: var(--ink);
  font-size: 0.86rem;
}

.idea-option {
  appearance: none;
  display: grid;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 223, 137, 0.2);
}

.idea-option.is-selected {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 2px rgba(255, 221, 104, 0.24);
}

.idea-option-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.idea-number {
  font-weight: 900;
  color: var(--leaf);
}

.idea-check {
  display: none;
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 900;
}

.idea-option.is-selected .idea-check {
  display: inline;
}

.idea-copy {
  color: var(--ink-soft);
  line-height: 1.5;
}

.idea-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.story-result {
  display: grid;
  gap: 10px;
}

.story-result h3 {
  margin-bottom: 0;
  font-size: 1.45rem;
}

.story-text {
  white-space: pre-wrap;
  line-height: 1.65;
}

.archive-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 224, 139, 0.14);
}

.archive-preview summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 900;
}

.archive-preview-body {
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.revision-detail-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
}

.debug-workbench,
.is-hidden {
  display: none !important;
}

.progress-tracker {
  display: grid;
  gap: 10px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(67, 32, 8, 0.24);
}

.progress-step.is-active .step-dot {
  background: var(--gold);
}

.progress-step.is-done .step-dot {
  background: var(--leaf);
}

.progress-step.is-error .step-dot {
  background: var(--berry);
}

pre {
  overflow: auto;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .section-heading,
  .chat-header,
  .composer-actions,
  .agent-status-header {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  :root {
    --stage-width: min(960px, max(620px, 82dvh));
    --content-top: clamp(150px, 37vw, 188px);
    --content-bottom: 14px;
    --content-width: min(360px, calc(100vw - 54px));
    --content-offset-x: 0px;
    --title-top: 26px;
    --title-width: calc(100vw - 22px);
  }

  .aventara-shell {
    padding: 0 8px 72px;
  }

  .aventara-stage-title {
    font-size: clamp(2.35rem, 11vw, 3.4rem);
    line-height: 0.92;
    text-shadow:
      0 2px 0 #4b2108,
      0 5px 0 rgba(93, 48, 16, 0.62),
      0 9px 14px rgba(31, 13, 3, 0.5),
      0 0 18px rgba(255, 219, 95, 0.38);
  }

  .aventara-intro h1 {
    font-size: clamp(1.65rem, 7vw, 2.2rem);
  }
}

@media (max-width: 620px) {
  .character-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) and (orientation: landscape), (orientation: landscape) and (pointer: coarse) {
  :root {
    --stage-width: min(760px, 82vw);
    --content-top: clamp(112px, 18dvh, 142px);
    --content-bottom: 12px;
    --content-width: min(440px, calc(var(--stage-width) * 0.58), calc(100vw - 76px));
    --content-offset-x: 0px;
    --title-top: 14px;
    --title-width: min(620px, calc(100vw - 36px));
  }

  .aventara-stage-title {
    font-size: clamp(2rem, 7.8vw, 3.7rem);
    line-height: 0.88;
    text-shadow:
      0 2px 0 #4b2108,
      0 4px 0 rgba(93, 48, 16, 0.6),
      0 8px 12px rgba(31, 13, 3, 0.48);
  }

  .aventara-shell {
    padding: 0 8px 48px;
  }

  .aventara-intro {
    padding-top: 18px;
    padding-bottom: 14px;
  }

  .aventara-intro h1 {
    max-width: 360px;
    font-size: clamp(1.1rem, 3.6vw, 1.55rem);
  }

  .lede {
    display: none;
  }

  .section-heading h2,
  .chat-header h2,
  .panel-card h2 {
    font-size: clamp(1.35rem, 4.4vw, 2rem);
  }

  .character-grid {
    gap: 10px;
  }

  .character-option {
    gap: 8px;
    padding: 8px;
  }

  .character-copy {
    gap: 7px;
  }

  .character-copy strong {
    font-size: clamp(1.1rem, 3.8vw, 1.45rem);
  }

  .character-copy span {
    padding: 7px 9px;
    font-size: 0.82rem;
  }

  .panel-card,
  .chat-header,
  .message-list,
  .composer {
    padding-left: 14px;
    padding-right: 14px;
  }
}
