/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
}

/* ---- Layout ---- */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen { display: flex; flex-direction: column; flex: 1; }
.screen.hidden { display: none !important; }

/* ---- Cards ---- */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
  padding: 2rem;
}

/* ---- Top bar ---- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.875rem;
  color: #64748b;
}

.student-label strong { color: #1e293b; }

/* ---- Join screen ---- */
#screen-join {
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.join-card {
  width: 100%;
  max-width: 420px;
}

.app-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: #0f172a;
}

.app-subtitle {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  line-height: 1.5;
}

/* ---- Join confirm ---- */
.join-confirm { margin-bottom: 0; }

.confirm-text {
  font-size: 1.05rem;
  margin-bottom: 1rem;
  color: #334155;
}

.confirm-buttons {
  display: flex;
  gap: 0.75rem;
}

/* ---- Form fields ---- */
.field {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.4rem;
}

.optional {
  font-weight: 400;
  color: #94a3b8;
  font-size: 0.8em;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: #1e293b;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
  resize: vertical;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

textarea { line-height: 1.55; }

.char-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.35rem;
}

.char-count {
  font-size: 0.78rem;
  color: #94a3b8;
  transition: color 0.2s;
  margin-left: auto;
}
.char-count.char-ok { color: #16a34a; }
.char-count.char-warn { color: #f59e0b; }

/* ---- Errors ---- */
.field-error {
  display: block;
  font-size: 0.8rem;
  color: #dc2626;
  margin-top: 0.3rem;
}
.field-error.hidden { display: none; }

#err-submit {
  display: block;
  font-size: 0.85rem;
  color: #dc2626;
  margin-bottom: 0.75rem;
}
#err-submit.hidden { display: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.4rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: #2563eb;
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }

.btn-secondary {
  background: #f1f5f9;
  color: #2563eb;
  border: 1.5px solid #2563eb;
}
.btn-secondary:hover:not(:disabled) { background: #dbeafe; }

.btn-ghost {
  background: transparent;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.btn-ghost:hover:not(:disabled) { background: #f8fafc; }

.btn-full { width: 100%; }

.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  color: #2563eb;
  font-size: 0.875rem;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
}
.btn-link:hover { color: #1d4ed8; }

/* ---- Passage layout ---- */
.passage-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  padding: 1.5rem;
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.passage-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.passage-meta { border-bottom: 1px solid #f1f5f9; padding-bottom: 0.75rem; }

.passage-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

.passage-source {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 0.35rem;
}

.passage-text {
  font-size: 1rem;
  line-height: 1.75;
  color: #334155;
  white-space: pre-wrap;
}

/* ---- Claim panel ---- */
.claim-panel { display: flex; flex-direction: column; }

.claim-heading {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: #0f172a;
}

.claim-prompt {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* ---- No passage ---- */
.no-passage-card {
  max-width: 500px;
  margin: 2rem auto;
  text-align: center;
}

.no-passage-text {
  color: #64748b;
  font-size: 1rem;
}

/* ---- Feedback screen ---- */
#screen-feedback .feedback-card {
  max-width: 700px;
  margin: 1.5rem auto;
  width: calc(100% - 3rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.submitted-claim {
  background: #f8fafc;
  border-left: 3px solid #2563eb;
  border-radius: 4px;
  padding: 0.9rem 1rem;
}

.submitted-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 0.4rem;
}

.submitted-text {
  font-size: 1rem;
  color: #1e293b;
  line-height: 1.6;
}

/* ---- Feedback loading ---- */
.feedback-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #64748b;
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ---- Feedback results ---- */
.feedback-block {
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.feedback-block.assessment {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.feedback-block.challenge {
  background: #fef3c7;
  border: 1px solid #fde68a;
}

.feedback-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #475569;
  margin-bottom: 0.6rem;
}

.feedback-block p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

.follow-up { color: #1d4ed8 !important; }
.counter-evidence { color: #92400e !important; }

.feedback-placeholder {
  font-size: 0.9rem;
  color: #94a3b8;
  font-style: italic;
  padding: 0.5rem 0;
}

.feedback-error {
  font-size: 0.9rem;
  color: #dc2626;
  padding: 0.5rem 0;
}

/* ---- Utilities ---- */
.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .card { padding: 1.25rem; }

  .passage-layout {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
  }

  #screen-feedback .feedback-card {
    margin: 1rem;
    width: calc(100% - 2rem);
  }

  .confirm-buttons { flex-direction: column; }
  .confirm-buttons .btn { width: 100%; }

  .app-title { font-size: 1.4rem; }

  .top-bar { padding: 0.6rem 1rem; }
}
