:root {
  color-scheme: dark;
  --bg: #0c1117;
  --panel: #111923;
  --panel-strong: #162230;
  --text: #eef4f8;
  --muted: #9fb0bf;
  --line: #263545;
  --primary: #4aa3d8;
  --primary-dark: #1c5f85;
  --accent: #4fc3a1;
  --accent-soft: rgba(79, 195, 161, 0.12);
  --assistant: #172331;
  --user: #143247;
  --danger: #f27f7f;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Inter", "Segoe UI", Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(74, 163, 216, 0.16), transparent 28%),
    linear-gradient(180deg, #0c1117 0%, #0a0f15 100%);
}

@media (min-width: 821px) {
  body {
    overflow: hidden;
  }
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 18px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: stretch;
}

.intro {
  padding: 4px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 1.1fr);
  gap: 28px;
  align-items: end;
}

.brand-lockup {
  display: flex;
  gap: 16px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 76px;
  height: 76px;
  border: 1px solid rgba(79, 195, 161, 0.42);
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background:
    linear-gradient(135deg, rgba(79, 195, 161, 0.18), rgba(74, 163, 216, 0.12)),
    #101b26;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.26);
}

.brand-mark span {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 2.55rem;
  font-weight: 700;
  color: var(--accent);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.76rem;
  line-height: 1.3;
}

h1 {
  max-width: 18ch;
  margin: 0;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: clamp(2.8rem, 6vw, 5.6rem);
  line-height: 1;
  letter-spacing: 0;
}

.intro-copy {
  max-width: 610px;
  padding: 18px 18px 18px 20px;
  border-left: 3px solid var(--accent);
  background: rgba(17, 25, 35, 0.58);
  border-radius: 8px;
}

.intro-label {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.intro-text {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.75fr);
  gap: 18px;
  align-items: stretch;
}

.chat-panel {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 25, 35, 0.94);
  box-shadow: var(--shadow);
}

.messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 40px;
}

.message.user .avatar {
  grid-column: 2;
  grid-row: 1;
  background: linear-gradient(180deg, #1f6f98, #174d6a);
  color: #ffffff;
}

.message.user .bubble {
  grid-column: 1;
  justify-self: end;
  background: var(--user);
  border-color: rgba(74, 163, 216, 0.28);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(180deg, #1e3142, #152332);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--line);
}

.avatar svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bubble {
  max-width: min(820px, 100%);
  padding: 13px 15px;
  border-radius: 8px;
  background: var(--assistant);
  border: 1px solid var(--line);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.bubble p {
  margin: 0 0 10px;
}

.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4 {
  margin: 4px 0 10px;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1rem;
  line-height: 1.35;
}

.bubble strong {
  font-weight: 700;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul,
.bubble ol {
  margin: 8px 0 0;
  padding-left: 22px;
}

.bubble li {
  margin: 5px 0;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #0f1721;
}

.thinking-indicator {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.thinking-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: thinking-pulse 1.1s infinite ease-in-out;
}

.thinking-indicator span:nth-child(2) {
  animation-delay: 0.16s;
}

.thinking-indicator span:nth-child(3) {
  animation-delay: 0.32s;
}

.message.thinking .bubble {
  border-color: rgba(79, 195, 161, 0.34);
  background: linear-gradient(180deg, rgba(79, 195, 161, 0.08), var(--assistant));
}

@keyframes thinking-pulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

textarea {
  width: 100%;
  min-height: 52px;
  max-height: 160px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--text);
  background: #0b121a;
}

textarea:focus {
  outline: 3px solid rgba(74, 163, 216, 0.2);
  border-color: var(--primary);
}

textarea::placeholder {
  color: #748696;
}

.composer button {
  min-width: 96px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: linear-gradient(180deg, #3f9acb, #27739c);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.composer button:hover {
  background: linear-gradient(180deg, #4aa3d8, #2d80ad);
}

.composer button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.canvas-panel {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 25, 35, 0.94);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr;
}

.canvas-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: start;
  background:
    linear-gradient(180deg, rgba(74, 163, 216, 0.08), transparent),
    rgba(15, 24, 34, 0.72);
}

.canvas-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.canvas-header h2 {
  margin: 0;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.28rem;
}

.canvas-summary {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.canvas-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.canvas-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: #0f1822;
  color: var(--muted);
  cursor: pointer;
}

.canvas-actions button:hover {
  border-color: var(--primary);
  color: var(--text);
}

#clear-canvas:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(242, 127, 127, 0.1);
}

.canvas-progress {
  height: 5px;
  background: #0b121a;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.canvas-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 260ms ease;
}

.canvas-items {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.canvas-group {
  display: grid;
  gap: 10px;
}

.canvas-group-title {
  margin: 0;
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.canvas-group-items {
  display: grid;
  gap: 10px;
}

.canvas-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0f1822;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.canvas-item:hover {
  border-color: rgba(74, 163, 216, 0.45);
  transform: translateY(-1px);
}

.canvas-item.filled {
  border-color: rgba(79, 195, 161, 0.4);
  background: linear-gradient(180deg, rgba(79, 195, 161, 0.12), rgba(15, 24, 34, 0.92));
}

.canvas-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #0b121a;
  border: 1px solid var(--line);
  color: var(--muted);
}

.canvas-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.canvas-item.filled .canvas-icon {
  background: var(--accent-soft);
  border-color: rgba(79, 195, 161, 0.4);
  color: var(--accent);
}

.canvas-item-body {
  min-width: 0;
}

.canvas-item-header {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: start;
}

.canvas-item h3 {
  margin: 0 0 7px;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--text);
}

.canvas-status {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: rgba(11, 18, 26, 0.68);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.canvas-item.filled .canvas-status {
  border-color: rgba(79, 195, 161, 0.36);
  color: var(--accent);
  background: var(--accent-soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 8, 13, 0.76);
  backdrop-filter: blur(10px);
}

.modal-backdrop[hidden] {
  display: none;
}

.confirm-modal {
  width: min(460px, 100%);
  border: 1px solid rgba(242, 127, 127, 0.3);
  border-radius: 8px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(242, 127, 127, 0.08), transparent 42%),
    #121b26;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.55);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
}

.welcome-modal {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  border: 1px solid rgba(79, 195, 161, 0.34);
  border-radius: 8px;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(79, 195, 161, 0.16), transparent 36%),
    linear-gradient(180deg, rgba(74, 163, 216, 0.08), transparent 48%),
    #121b26;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.55);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.welcome-scroll {
  min-height: 0;
}

.welcome-logo {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border: 1px solid rgba(79, 195, 161, 0.42);
  background: rgba(79, 195, 161, 0.12);
  color: var(--accent);
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 2rem;
  font-weight: 700;
}

.welcome-modal h2 {
  margin: 0;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: clamp(1.65rem, 5vw, 2.2rem);
  line-height: 1.1;
}

.welcome-modal p {
  color: var(--muted);
  line-height: 1.55;
}

.welcome-list {
  margin: 16px 0 20px;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.55;
}

.welcome-list li {
  margin: 7px 0;
}

.modal-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(242, 127, 127, 0.13);
  border: 1px solid rgba(242, 127, 127, 0.36);
  color: var(--danger);
  font-weight: 800;
}

.modal-kicker {
  margin: 0 0 5px;
  color: var(--danger);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.confirm-modal h2 {
  margin: 0;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.55rem;
}

.confirm-modal p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.modal-actions button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.secondary-action {
  border: 1px solid var(--line);
  background: #0f1822;
  color: var(--text);
}

.danger-action {
  border: 1px solid rgba(242, 127, 127, 0.5);
  background: rgba(242, 127, 127, 0.15);
  color: #ffd8d8;
}

.primary-action {
  min-height: 46px;
  width: 100%;
  margin: 18px 0 0;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: linear-gradient(180deg, #4fc3a1, #2b806b);
  color: #06120f;
  font-weight: 800;
  cursor: pointer;
}

.primary-action:hover {
  background: linear-gradient(180deg, #62d8b6, #32947c);
}

.secondary-action:hover {
  border-color: var(--primary);
}

.danger-action:hover {
  background: rgba(242, 127, 127, 0.24);
}

.canvas-content {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.canvas-content p {
  margin: 0 0 8px;
}

.canvas-content p:last-child {
  margin-bottom: 0;
}

.canvas-content ul,
.canvas-content ol {
  margin: 6px 0 0;
  padding-left: 18px;
}

.canvas-item.empty {
  background: rgba(15, 24, 34, 0.72);
}

.canvas-item.empty .canvas-content {
  color: #718292;
}

.export-panel {
  border: 1px solid rgba(74, 163, 216, 0.28);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background:
    linear-gradient(135deg, rgba(74, 163, 216, 0.12), rgba(79, 195, 161, 0.08)),
    rgba(17, 25, 35, 0.9);
  box-shadow: var(--shadow);
}

.export-panel.complete {
  border-color: rgba(79, 195, 161, 0.52);
  background:
    linear-gradient(135deg, rgba(79, 195, 161, 0.18), rgba(74, 163, 216, 0.1)),
    rgba(17, 25, 35, 0.94);
}

.export-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.export-panel h2 {
  margin: 0;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.45rem;
}

.export-panel p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.export-panel button {
  min-height: 48px;
  min-width: 160px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: linear-gradient(180deg, #4fc3a1, #2b806b);
  color: #06120f;
  font-weight: 800;
  cursor: pointer;
}

.export-panel button:hover {
  background: linear-gradient(180deg, #62d8b6, #32947c);
}

.export-panel button:disabled {
  cursor: not-allowed;
  color: #80909d;
  background: #182536;
  border: 1px solid var(--line);
}

.print-report {
  display: none;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #263545;
  border-radius: 8px;
}

::-webkit-scrollbar-track {
  background: #0b121a;
}

.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;
}

@media (max-width: 820px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    padding: 16px 0;
    align-items: stretch;
    gap: 14px;
  }

  .intro,
  .workspace {
    grid-template-columns: 1fr;
  }

  .intro-text {
    margin-top: 6px;
    font-size: 1rem;
  }

  h1 {
    max-width: 18ch;
    font-size: clamp(2.6rem, 13vw, 4rem);
  }

  .chat-panel,
  .canvas-panel {
    height: auto;
  }

  .chat-panel {
    height: 68vh;
    min-height: 520px;
  }

  .canvas-panel {
    height: 46vh;
    min-height: 360px;
  }

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

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 12px, 1120px);
    padding: 10px 0;
  }

  .intro {
    gap: 8px;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .brand-mark {
    width: 58px;
    height: 58px;
  }

  .brand-mark span {
    font-size: 2rem;
  }

  .eyebrow {
    font-size: 0.68rem;
    margin-bottom: 6px;
  }

  h1 {
    font-size: clamp(2.35rem, 16vw, 3.3rem);
  }

  .intro-text {
    font-size: 0.94rem;
    line-height: 1.45;
  }

  .intro-copy {
    padding: 13px 14px;
  }

  .messages {
    padding: 10px;
    gap: 12px;
  }

  .message {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .message.user {
    grid-template-columns: minmax(0, 1fr) 34px;
  }

  .avatar {
    width: 34px;
    height: 34px;
    font-size: 0.72rem;
  }

  .bubble {
    padding: 11px 12px;
    font-size: 0.94rem;
  }

  .composer {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .composer button {
    min-height: 46px;
  }

  .chat-panel {
    height: 66vh;
    min-height: 460px;
  }

  .canvas-header {
    padding: 12px;
    align-items: center;
  }

  .canvas-header h2 {
    font-size: 1.05rem;
  }

  .canvas-items {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 8px;
  }

  .canvas-item {
    padding: 10px;
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .canvas-item-header {
    display: grid;
    gap: 4px;
  }

  .canvas-status {
    width: fit-content;
  }

  .canvas-content {
    font-size: 0.86rem;
  }

  .export-panel {
    display: grid;
    gap: 14px;
  }

  .export-panel button {
    width: 100%;
  }

  .confirm-modal {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .welcome-modal {
    max-height: calc(100vh - 24px);
    padding: 18px;
  }

  .welcome-scroll {
    min-height: 0;
  }

  .primary-action {
    width: 100%;
    margin: 14px 0 0;
  }

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

@media print {
  @page {
    margin: 18mm;
  }

  body {
    background: #ffffff !important;
    color: #111111 !important;
  }

  .app-shell,
  .modal-backdrop {
    display: none !important;
  }

  .print-report {
    display: block;
    font-family: Arial, Helvetica, sans-serif;
    color: #111111;
  }

  .print-cover {
    border-bottom: 2px solid #111111;
    padding-bottom: 16px;
    margin-bottom: 18px;
  }

  .print-cover p {
    margin: 0 0 8px;
    text-transform: uppercase;
    font-size: 10pt;
    letter-spacing: 0;
  }

  .print-cover h1 {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 24pt;
  }

  .print-cover h2 {
    margin: 6px 0 0;
    font-size: 13pt;
    font-weight: 400;
  }

  .print-cover dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 18px 0 0;
  }

  .print-cover dt {
    font-size: 9pt;
    font-weight: 700;
    text-transform: uppercase;
  }

  .print-cover dd {
    margin: 3px 0 0;
    font-size: 11pt;
  }

  .print-field {
    break-inside: avoid;
    border: 1px solid #cccccc;
    padding: 10px 12px;
    margin: 0 0 10px;
  }

  .print-field h3 {
    margin: 0 0 6px;
    font-size: 12pt;
  }

  .print-field p,
  .print-field li {
    font-size: 10.5pt;
    line-height: 1.45;
  }

  .print-field p {
    margin: 0 0 6px;
  }
}
