:root {
  color-scheme: light;
  --ink: #18201f;
  --muted: #5d6965;
  --line: #d7dfdc;
  --surface: #f8faf8;
  --panel: #ffffff;
  --accent: #0d6b5f;
  --accent-dark: #084b43;
  --warn: #9b4d16;
  --ok: #167348;
  --bad: #9a2d2d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
textarea {
  font: inherit;
}

.shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.brief {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(320px, 1.22fr);
  gap: 36px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
}

.course {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.brief-text {
  display: grid;
  gap: 12px;
  color: #2f3835;
  font-size: 1rem;
}

.brief-text p {
  margin: 0;
}

.quote {
  color: var(--accent-dark);
  font-weight: 650;
}

.workspace {
  padding-top: 22px;
}

.composer {
  display: grid;
  gap: 10px;
}

.composer-head,
.composer-actions,
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

label,
h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 750;
}

#paper-count,
.composer-actions span {
  color: var(--muted);
  font-size: 0.88rem;
}

textarea {
  width: 100%;
  min-height: 142px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 107, 95, 0.12);
}

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 720;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button.ghost,
.tab {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

button.ghost:hover,
.tab:hover {
  border-color: var(--accent);
  background: #eef7f5;
}

.panes {
  display: grid;
  grid-template-columns: minmax(300px, 0.84fr) minmax(420px, 1.16fr);
  gap: 18px;
  margin-top: 18px;
}

.pane {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.pane-head {
  min-height: 56px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.progress {
  height: 620px;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event {
  border-left: 3px solid var(--line);
  padding: 8px 10px;
  background: #fbfcfb;
}

.event.status {
  border-color: var(--accent);
}

.event.tool {
  border-color: #546a9b;
}

.event.thinking {
  border-color: #6c5c7d;
}

.event.error {
  border-color: var(--bad);
  color: var(--bad);
}

.event-title {
  margin: 0 0 4px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 780;
  text-transform: uppercase;
  letter-spacing: 0;
}

.event summary {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  cursor: pointer;
}

.event summary .event-title {
  margin: 0;
}

.event-summary {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 6px 0 0;
  font-size: 0.86rem;
}

.tabs {
  min-height: 56px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.output {
  display: none;
  height: 620px;
  overflow: auto;
  padding: 18px;
}

.output.active {
  display: block;
}

.output h1,
.output h2,
.output h3 {
  font-size: 1.15rem;
  line-height: 1.25;
  margin: 1.1em 0 0.4em;
}

.output h1:first-child,
.output h2:first-child,
.output h3:first-child {
  margin-top: 0;
}

.output p {
  margin: 0 0 0.85em;
}

.feedback-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.score {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  font-weight: 780;
}

.score.ok {
  background: var(--ok);
}

.score.no {
  background: var(--warn);
}

@media (max-width: 900px) {
  .shell {
    width: min(100vw - 20px, 720px);
    padding-top: 16px;
  }

  .brief,
  .panes {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.3rem;
  }

  .progress,
  .output {
    height: 430px;
  }
}

.waiting {
  color: var(--muted);
}

.dots span {
  animation: dot-blink 1.4s infinite both;
}

.dots span:nth-child(2) {
  animation-delay: 0.25s;
}

.dots span:nth-child(3) {
  animation-delay: 0.5s;
}

@keyframes dot-blink {
  0%,
  20% {
    opacity: 0;
  }
  50%,
  100% {
    opacity: 1;
  }
}

.tab.waiting::after {
  content: "...";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: dot-blink 1.4s infinite both;
}

.footer {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 20px 28px;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer a {
  color: var(--accent);
}
