:root {
  color-scheme: light;
  --paper: #f3f0e8;
  --surface: #fffdf7;
  --surface-muted: #e9e4d8;
  --ink: #171c1f;
  --ink-soft: #434b4d;
  --line: #d4cdbf;
  --teal: #1f7775;
  --teal-dark: #145a59;
  --red: #b93833;
  --brass: #b78534;
  --shadow: 0 18px 40px rgba(23, 28, 31, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  min-height: 100vh;
}

.agent-rail {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: var(--ink);
  color: var(--surface);
  min-width: 0;
}

.brand-block {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 253, 247, 0.4);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--teal), var(--red));
  font-family: Georgia, serif;
  font-size: 28px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 4px;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-block .eyebrow,
.workspace-header .eyebrow,
.context-section .eyebrow {
  color: var(--teal);
}

.agent-rail .eyebrow {
  color: rgba(255, 253, 247, 0.68);
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  font-size: 28px;
  line-height: 1.14;
}

h3 {
  font-size: 18px;
  line-height: 1.22;
}

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

.agent-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 70px;
  padding: 14px;
  border: 1px solid rgba(255, 253, 247, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.06);
  color: var(--surface);
  text-align: left;
}

.agent-button:hover,
.agent-button:focus-visible {
  border-color: rgba(255, 253, 247, 0.44);
  outline: none;
}

.agent-button.is-active {
  border-color: var(--brass);
  background: rgba(183, 133, 52, 0.18);
}

.agent-button span {
  font-weight: 800;
}

.agent-button small {
  color: rgba(255, 253, 247, 0.7);
}

.rail-art {
  overflow: hidden;
  margin-top: auto;
  border: 1px solid rgba(255, 253, 247, 0.14);
  border-radius: var(--radius);
  aspect-ratio: 1 / 0.72;
  background: #222;
}

.rail-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-workspace {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  min-width: 0;
  background: var(--surface);
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 92px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.status-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 14px;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
}

.message-panel {
  min-height: 0;
  padding: 24px 28px;
  overflow: hidden;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 320px;
  overflow-y: auto;
  padding-right: 6px;
}

.message {
  width: min(720px, 100%);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 5px 16px rgba(23, 28, 31, 0.04);
}

.message.user {
  align-self: flex-end;
  background: #eef7f4;
  border-color: #bad9d4;
}

.message.assistant {
  align-self: flex-start;
}

.message.system {
  width: 100%;
  background: #fff7e6;
  border-color: #e6cd9d;
  color: #5b431f;
}

.message-label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.composer {
  display: grid;
  gap: 12px;
  padding: 18px 28px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

textarea {
  width: 100%;
  min-height: 92px;
  max-height: 220px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefa;
  color: var(--ink);
  line-height: 1.5;
}

textarea:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(31, 119, 117, 0.16);
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.secondary-button,
.prompt-button {
  min-height: 42px;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary-button {
  min-width: 96px;
  border: 1px solid var(--teal-dark);
  background: var(--teal);
  color: #fffefa;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--teal-dark);
  outline: none;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.secondary-button,
.prompt-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.secondary-button {
  min-width: 82px;
}

.prompt-button {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  line-height: 1.35;
}

.prompt-button:hover,
.prompt-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--teal);
  outline: none;
}

.context-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: #faf7ef;
}

.context-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.72);
}

.context-section p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.compact-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--ink-soft);
}

.prompt-stack {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.teacher-link {
  color: var(--teal-dark);
  font-weight: 800;
}

.visually-hidden {
  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: 1120px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .context-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

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

  .agent-rail {
    padding: 18px;
  }

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

  .agent-button {
    min-height: 82px;
  }

  .rail-art {
    display: none;
  }

  .workspace-header,
  .composer,
  .message-panel,
  .context-panel {
    padding-left: 18px;
    padding-right: 18px;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .context-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .agent-list {
    grid-template-columns: 1fr;
  }

  .composer-actions {
    justify-content: stretch;
  }

  .primary-button,
  .secondary-button {
    flex: 1;
  }
}
