:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #676767;
  --line: #d8d8d8;
  --paper: #f7f6f2;
  --panel: #ffffff;
  --bad: #b3261e;
  --warn: #b05b00;
  --good: #176b4d;
  --accent: #2d5a80;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--paper);
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(430px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.09);
}

.auth-card h1 {
  font-size: 36px;
}

.auth-card p {
  margin-top: 10px;
  color: var(--muted);
}

.full {
  width: 100%;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--ink);
}

.top-actions {
  display: flex;
  gap: 10px;
}

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

h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar p {
  max-width: 680px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 17px;
}

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

.grid {
  margin-top: 20px;
}

.panel,
.report article,
.chat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-weight: 800;
}

h2 {
  font-size: 22px;
}

h3 {
  margin-bottom: 12px;
  font-size: 17px;
}

label {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

textarea {
  min-height: 230px;
  resize: vertical;
  line-height: 1.45;
}

button {
  margin-top: 16px;
  border: 0;
  border-radius: 6px;
  padding: 12px 15px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

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

.ghost {
  margin-top: 0;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}

.status,
.note {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.research {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

.report {
  margin-top: 18px;
}

.chat-panel {
  margin-top: 18px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
}

.chat-sidebar {
  border-right: 1px solid var(--line);
  padding-right: 14px;
}

.chat-sidebar button {
  width: 100%;
}

.chat-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.chat-item {
  width: 100%;
  margin: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 700;
}

.chat-item.active {
  border-color: var(--accent);
  background: #eef4f8;
}

.chat-log {
  display: grid;
  gap: 10px;
  min-height: 440px;
  max-height: 620px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfb;
}

.message {
  width: min(88%, 760px);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.user {
  justify-self: end;
  background: var(--accent);
  color: #fff;
}

.message.assistant {
  justify-self: start;
  background: #ece9e1;
}

.message.artifacts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message.artifacts a {
  display: inline-block;
  border-radius: 6px;
  padding: 9px 11px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.chat-form button {
  min-width: 92px;
}

.attach-row,
.attach-note {
  grid-column: 1 / -1;
}

.attach-row {
  margin-top: 0;
}

.score-row {
  display: grid;
  grid-template-columns: 180px 180px 1fr;
  gap: 12px;
  align-items: stretch;
}

.score-block,
.verdict {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.score-block span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.score-block strong {
  display: block;
  margin-top: 6px;
  color: var(--good);
  font-size: 38px;
}

.score-block.fail strong {
  color: var(--bad);
}

.verdict {
  display: flex;
  align-items: center;
  font-size: 22px;
  font-weight: 900;
}

.meter {
  height: 14px;
  margin: 14px 0;
  overflow: hidden;
  background: #e4ddd3;
  border-radius: 999px;
}

.meter div {
  width: 0;
  height: 100%;
  background: var(--bad);
  transition: width 0.3s ease;
}

.report-grid {
  margin-top: 14px;
}

ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.55;
}

li + li {
  margin-top: 8px;
}

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

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: #fafafa;
  font-size: 13px;
}

.chip.bad {
  border-color: #efb2ad;
  color: var(--bad);
}

.chip.good {
  border-color: #a7d9c7;
  color: var(--good);
}

@media (max-width: 800px) {
  .topbar,
  .score-row {
    display: block;
  }

  .ghost {
    margin-top: 16px;
  }

  .grid,
  .report-grid,
  .chat-form,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 14px;
  }

  .score-block,
  .verdict {
    margin-bottom: 10px;
  }
}
