:root {
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --text: #17202a;
  --muted: #657182;
  --line: #dfe5eb;
  --green: #159b65;
  --blue: #2563eb;
  --amber: #c77800;
  --red: #d43f3a;
  --shadow: 0 18px 50px rgba(31, 41, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1420px;
  margin: 0 auto;
}

.input-pane,
.result-pane {
  min-height: calc(100vh - 48px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.input-pane {
  padding: 22px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.result-pane {
  border-radius: 8px;
  padding: 24px;
  overflow: hidden;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.status-pill {
  border: 1px solid #b9d9c8;
  color: #0f7f51;
  background: #eefaf3;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span,
.section-title {
  font-size: 13px;
  font-weight: 800;
  color: #334155;
}

input,
textarea {
  width: 100%;
  border: 1px solid #ccd5df;
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 170px;
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.divider-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.divider-label::before,
.divider-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.primary-button {
  height: 46px;
  border: 0;
  border-radius: 6px;
  background: #17202a;
  color: white;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.primary-button:hover {
  background: #0f1720;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.button-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  align-items: center;
  justify-content: center;
}

.source-panel {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.source-item {
  border-left: 3px solid #8aa4bd;
  padding-left: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.source-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 2px;
}

.empty-state {
  min-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  color: var(--muted);
}

.empty-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

.empty-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 600px;
}

.empty-grid span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  min-height: 52px;
  display: flex;
  align-items: center;
  color: #3d4958;
  font-weight: 700;
}

.loading-state,
.error-state {
  min-height: calc(100vh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #cbd5e1;
  border-top-color: var(--green);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-state {
  color: var(--red);
  text-align: center;
  line-height: 1.7;
}

.result {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.score-header {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}

.score-box {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.score-value {
  font-size: 62px;
  line-height: 1;
  font-weight: 900;
}

.score-meta {
  display: flex;
  gap: 10px;
  color: var(--muted);
  align-items: center;
  margin-top: 8px;
}

#gradeValue {
  color: #0f1720;
  background: #e8edf2;
  border-radius: 5px;
  padding: 4px 8px;
  font-weight: 900;
}

.score-copy {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.page-title {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 850;
  line-height: 1.35;
}

.summary-text {
  margin: 0;
  line-height: 1.8;
  color: #445064;
}

.metrics-section,
.priority-section,
.rewrite-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.category-item,
.priority-item,
.rewrite-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.category-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 28px;
}

.category-title {
  font-size: 14px;
  font-weight: 850;
}

.category-score {
  font-size: 13px;
  font-weight: 900;
}

.bar {
  height: 8px;
  background: #e6ecf2;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

.bar-fill {
  height: 100%;
  background: var(--green);
  width: 0;
}

.bar-fill.warn {
  background: var(--amber);
}

.bar-fill.bad {
  background: var(--red);
}

.category-advice,
.priority-reason {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.category-evidence {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-evidence span {
  border-radius: 999px;
  background: #eef2f7;
  color: #4b5563;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
}

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

.priority-rank {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #17202a;
  color: white;
  font-size: 13px;
  font-weight: 900;
  margin-right: 8px;
}

.priority-title {
  font-weight: 850;
  margin-bottom: 8px;
}

.priority-action {
  line-height: 1.7;
}

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

.rewrite-item h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.rewrite-item pre {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 13px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.copy-button {
  margin-top: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 6px;
  min-height: 34px;
  padding: 0 12px;
  color: #17202a;
  font-weight: 800;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

@media (max-width: 1040px) {
  .workspace,
  .score-header,
  .category-list,
  .priority-list,
  .rewrite-list {
    grid-template-columns: 1fr;
  }

  .input-pane,
  .result-pane {
    min-height: auto;
  }

  .empty-state,
  .loading-state,
  .error-state {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px;
  }

  .input-pane,
  .result-pane {
    padding: 16px;
  }

  .empty-grid {
    grid-template-columns: 1fr 1fr;
  }

  .score-value {
    font-size: 52px;
  }
}
