:root {
  --paper: #f6f0e2;
  --mist: #fff9ef;
  --ink: #1f2833;
  --muted: #57616e;
  --accent: #005f73;
  --accent-soft: #d7edf2;
  --line: rgba(31, 40, 51, 0.16);
  --success: #2a9d8f;
  --card-shadow: 0 18px 40px rgba(10, 24, 38, 0.09);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, #fff7de 0%, transparent 38%),
    radial-gradient(circle at 90% 12%, #e3f2f4 0%, transparent 34%),
    linear-gradient(165deg, #f6ecda 0%, #f1e7d8 45%, #ebe2d7 100%);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Newsreader", "Iowan Old Style", serif;
  letter-spacing: 0.01em;
}

.ambient-glow {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.35;
  pointer-events: none;
  z-index: -1;
}

.ambient-glow-a {
  background: #ffe4a9;
  top: -8rem;
  left: -6rem;
}

.ambient-glow-b {
  background: #9dd8e4;
  right: -10rem;
  bottom: -9rem;
}

.app-shell {
  width: min(1220px, 96vw);
  margin: 1.4rem auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1rem;
  align-items: start;
}

.conversation-column,
.workspace-panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--mist) 88%, white);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(2px);
}

.conversation-column {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 88vh;
}

.masthead {
  padding: 1rem 1rem 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

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

.masthead h1 {
  margin-top: 0.2rem;
  font-size: clamp(1.45rem, 2.5vw, 2rem);
}

.case-form {
  display: flex;
  gap: 0.45rem;
}

.case-form input {
  width: 130px;
}

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

.card {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: white;
  padding: 0.8rem 0.9rem;
  animation: reveal 220ms ease;
}

.card.user {
  margin-left: auto;
  width: min(82%, 760px);
  background: #e8f4f6;
  border-color: #b4d6de;
}

.card.assistant {
  width: min(88%, 840px);
}

.card.system {
  width: min(88%, 840px);
  border-style: dashed;
  background: #fffaf1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.38rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.role {
  background: #d3e9ed;
  color: #0f3f4a;
}

.badge.phase {
  background: #f0ead9;
  color: #4f4739;
}

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

.card-tools {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.card-tools li {
  background: #f6fafb;
  border: 1px solid #dcebed;
  border-radius: 10px;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 0.9rem;
  background: color-mix(in srgb, white 72%, var(--mist));
}

#message-input,
.case-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffef8;
  color: var(--ink);
  padding: 0.62rem 0.72rem;
  font: inherit;
}

#message-input {
  min-height: 96px;
  resize: vertical;
}

.composer-actions {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.86rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: white;
  background: linear-gradient(130deg, #006f84, #0c90a8);
}

button.secondary {
  color: #0e3640;
  background: #d9edf2;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.workspace-panel {
  position: sticky;
  top: 1rem;
  padding: 1rem;
  display: grid;
  gap: 0.85rem;
}

.workspace-header {
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.workspace-header h2 {
  margin-top: 0.2rem;
  font-size: 1.45rem;
}

.workspace-block {
  display: grid;
  gap: 0.45rem;
}

.workspace-block h3 {
  font-size: 1.05rem;
}

.status-chip {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 0.26rem 0.55rem;
  background: #daf0ec;
  color: #14594f;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

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

.stack-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.stack-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: white;
  line-height: 1.3;
}

.stack-list.compact li {
  font-size: 0.8rem;
  background: #f8fcfd;
}

.placeholder {
  color: var(--muted);
  font-size: 0.86rem;
  padding: 0.3rem 0;
}

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

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace-panel {
    position: static;
    order: -1;
  }

  .conversation-column {
    min-height: 72vh;
  }

  .card.user,
  .card.assistant,
  .card.system {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none;
  }
}
