:root {
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9e1ea;
  --panel: #ffffff;
  --soft: #f6f8fb;
  --brand: #245f7a;
  --brand-dark: #173f52;
  --accent: #d8953f;
  --ok: #207a4c;
  --warn: #b34336;
  --hint: #6d5bd0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(36, 95, 122, 0.08), transparent 34%),
    linear-gradient(300deg, rgba(216, 149, 63, 0.12), transparent 30%),
    var(--soft);
}

button,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 18px;
  align-items: stretch;
  padding: 28px 0;
}

.workspace,
.feedback-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(20, 39, 55, 0.07);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px);
}

.brand-bar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 30px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2.3rem, 4.8vw, 4.1rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.45rem;
}

.tagline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.access-badge {
  align-self: flex-start;
  max-width: 210px;
  padding: 10px 14px;
  border-left: 4px solid var(--accent);
  background: #fff8ed;
  color: #6b431b;
  font-size: 0.9rem;
  font-weight: 700;
}

.input-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 30px 30px;
}

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

.stage-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stage-pill {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #c9d5df;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.stage-number {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e8eef3;
  color: var(--muted);
  font-size: 0.82rem;
}

.stage-pill.active {
  border-color: var(--brand);
  background: #e9f4f7;
  color: var(--brand-dark);
}

.stage-pill.active .stage-number {
  background: var(--brand);
  color: #fff;
}

.stage-pill.done {
  border-color: #b7dbc8;
  background: #edf8f2;
  color: var(--ok);
}

.stage-pill.done .stage-number {
  background: var(--ok);
  color: #fff;
}

.stage-pill.locked {
  background: #f2f4f7;
  color: #9aa4b2;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  border: 1px solid #c9d5df;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

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

.writing-label {
  margin-top: 8px;
}

textarea {
  min-height: 380px;
  flex: 1;
  resize: vertical;
  padding: 16px;
  line-height: 1.7;
}

textarea:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(23, 107, 135, 0.22);
  outline-offset: 2px;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  padding: 0 22px;
  background: var(--brand);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

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

button.coach {
  background: var(--hint);
}

button.coach:hover {
  background: #5747b7;
}

button.secondary {
  background: #e8eef3;
  color: var(--ink);
}

#analyze-btn {
  min-width: 220px;
}

button.secondary:hover {
  background: #dce6ee;
}

.teacher-link,
.test-link {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  font-weight: 900;
  text-decoration: none;
}

.teacher-link:hover,
.test-link:hover {
  color: var(--brand-dark);
}

.feedback-panel {
  min-height: calc(100vh - 56px);
  overflow: auto;
}

.feedback-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 24px 26px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.results {
  padding: 24px 26px;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.results.empty {
  color: var(--muted);
  line-height: 1.7;
}

.attempt-label {
  margin: 0 0 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--brand-dark);
  font-weight: 900;
}

.sentence-block {
  padding: 18px 0;
  border-bottom: 1px solid #edf1f5;
}

.sentence-block:last-child {
  border-bottom: 0;
}

.sentence-title {
  margin: 0 0 10px;
  font-weight: 900;
  color: var(--brand-dark);
}

.status {
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warn);
}

.hint {
  color: var(--hint);
  font-weight: 800;
}

.field-label {
  margin: 14px 0 6px;
  color: var(--muted);
  font-weight: 900;
}

.sentence-text,
.explanation,
.encouragement {
  margin: 0;
  line-height: 1.65;
}

.original-text {
  color: #374151;
}

.error-mark {
  color: var(--warn);
  font-weight: 900;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  background: #fff1ef;
  border-radius: 3px;
  padding: 0 2px;
}

.summary {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid #f0d2aa;
  border-radius: 8px;
  background: #fffaf2;
}

.summary h3 {
  margin: 0 0 12px;
}

.summary ul {
  margin: 8px 0 16px;
  padding-left: 20px;
}

.coach-card {
  margin: 0 0 16px;
  padding: 18px;
  border: 1px solid #cfc8f4;
  border-radius: 8px;
  background: #f7f5ff;
}

.coach-card h3 {
  margin: 0 0 10px;
}

.coach-card p,
.coach-section ul {
  margin-bottom: 0;
}

.coach-section ul {
  padding-left: 20px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.coach-section li,
.coach-card p,
.summary li,
.summary p {
  word-break: keep-all;
  overflow-wrap: break-word;
}

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

.test-header,
.test-panel,
.test-results,
.test-scoreboard article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(20, 39, 55, 0.07);
}

.test-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 28px 30px;
}

.test-panel,
.test-results {
  margin-top: 18px;
  padding: 24px 30px;
}

.test-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.test-note {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.test-scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.test-scoreboard article {
  padding: 18px;
}

.score-label {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.test-scoreboard strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
}

.test-group {
  margin-top: 24px;
}

.test-case {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.test-case p {
  margin: 6px 0;
  line-height: 1.55;
}

.test-case.failed {
  border-color: #efc0ba;
  background: #fff7f6;
}

.test-case.passed {
  border-color: #c6e3d2;
  background: #f4fbf7;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 16px 0;
    width: min(100vw - 24px, 720px);
  }

  .workspace,
  .feedback-panel {
    min-height: auto;
  }

  .brand-bar {
    flex-direction: column;
    padding: 24px;
  }

  .input-panel {
    padding: 24px;
  }

  .controls-row {
    grid-template-columns: 1fr;
  }

  textarea {
    min-height: 260px;
  }

  .stage-progress {
    grid-template-columns: 1fr;
  }

  .test-header {
    flex-direction: column;
  }

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