:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #eef3ee;
  --ink: #1c2321;
  --muted: #68726d;
  --line: #dce3dd;
  --blue: #245bce;
  --blue-dark: #17439d;
  --green: #24745a;
  --green-soft: #e2f2ec;
  --coral: #bf5b45;
  --coral-soft: #f8e7e1;
  --shadow: 0 20px 50px rgba(28, 35, 33, 0.08);
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 28px;
  background: #18211f;
  color: #f8fbf6;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #f3c677;
  color: #18211f;
  font-weight: 800;
}

.brand-name,
.brand-subtitle,
.sidebar-footer p,
.page-note,
.eyebrow,
.label,
.metric-card span,
.prompt-item p,
.essay-row p,
.progress-item p {
  margin: 0;
}

.brand-name {
  font-weight: 800;
  line-height: 1.25;
}

.brand-subtitle,
.sidebar-footer,
.nav-icon {
  color: rgba(248, 251, 246, 0.68);
}

.brand-subtitle {
  margin-top: 4px;
  font-size: 0.88rem;
}

.nav-list {
  display: grid;
  gap: 10px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(248, 251, 246, 0.82);
  text-align: left;
  text-decoration: none;
}

.nav-button:hover,
.nav-button.active {
  border-color: rgba(248, 251, 246, 0.22);
  background: rgba(248, 251, 246, 0.1);
  color: #ffffff;
}

.login-only-nav .nav-button {
  cursor: default;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(248, 251, 246, 0.08);
  font-size: 0.78rem;
  font-weight: 800;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid rgba(248, 251, 246, 0.14);
  line-height: 1.5;
}

.label,
.eyebrow {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-footer .label {
  color: rgba(248, 251, 246, 0.48);
}

.workspace {
  min-width: 0;
  padding: 34px;
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-bottom: 22px;
  color: var(--muted);
  font-weight: 750;
}

.account-bar[hidden] {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  margin-top: 8px;
  font-size: 3.2rem;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

.page-note {
  max-width: 320px;
  color: var(--muted);
  line-height: 1.6;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(280px, 680px);
  gap: 20px;
  align-items: start;
  max-width: 680px;
}

.login-panel,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.login-stack {
  display: grid;
  gap: 20px;
}

.first-login-note {
  margin-top: 10px;
}

.recovery-panel,
.account-form {
  display: grid;
  gap: 14px;
}

.stacked-heading {
  align-items: flex-start;
}

.stacked-heading > div {
  display: grid;
  gap: 7px;
}

.recovery-divider {
  height: 1px;
  background: var(--line);
}

.login-panel label,
.form-field label {
  color: var(--ink);
  font-weight: 750;
}

.login-panel input,
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
}

.login-panel input:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(36, 91, 206, 0.16);
}

.form-field textarea {
  min-height: 180px;
  padding: 14px;
  resize: vertical;
  line-height: 1.5;
}

.form-field {
  display: grid;
  gap: 8px;
}

.role-toggle,
.auth-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.role-toggle {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.role-option,
.mode-option {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.role-option.active,
.mode-option.active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: 0 10px 24px rgba(28, 35, 33, 0.08);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.form-message.success {
  color: var(--green);
}

.form-message.error {
  color: var(--coral);
}

.primary-action,
.secondary-action {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 850;
  text-decoration: none;
}

.primary-action {
  border: 0;
  background: var(--blue);
  color: #ffffff;
}

.primary-action:hover {
  background: var(--blue-dark);
}

.primary-action:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.compact-action {
  min-width: 150px;
  padding: 0 18px;
}

.secondary-action {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  color: var(--ink);
}

.secondary-action:hover {
  border-color: #b9c5bd;
}

.text-action {
  justify-self: start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-action:hover {
  color: var(--blue-dark);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metric-card {
  display: grid;
  gap: 12px;
  min-height: 126px;
  padding: 20px;
  border-top: 4px solid var(--blue);
}

.metric-card strong {
  font-size: 2rem;
}

.metric-card span {
  color: var(--muted);
  font-weight: 750;
}

.accent-green {
  border-top-color: var(--green);
}

.accent-coral {
  border-top-color: var(--coral);
}

.teacher-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 20px;
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
  gap: 20px;
  margin-bottom: 20px;
}

.account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.account-actions time {
  color: var(--muted);
}

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

.reset-request-list {
  display: grid;
  gap: 12px;
}

.reset-request-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.reset-request-item p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.reset-code-card {
  display: grid;
  gap: 5px;
  max-width: 320px;
  padding: 12px 14px;
  border: 1px solid #b7d9ca;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
}

.reset-code-card strong {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.reset-code-card small {
  color: var(--muted);
  line-height: 1.4;
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.prompt-list,
.essay-list,
.progress-list,
.account-list,
.task-choice-grid {
  display: grid;
  gap: 12px;
}

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

.task-choice-grid.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.prompt-item,
.essay-row,
.progress-item,
.account-item,
.empty-state,
.task-choice-card,
.task-set-card,
.essay-submission-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.task-choice-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
  color: var(--ink);
  text-decoration: none;
  text-align: left;
}

.task-choice-card {
  width: 100%;
  min-height: 170px;
}

.task-choice-card:hover {
  border-color: #aebdb4;
  background: #ffffff;
  transform: translateY(-1px);
}

.task-choice-card p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.task-choice-card h3 {
  overflow-wrap: anywhere;
}

.task-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: #e8eefc;
  color: var(--blue-dark);
  font-weight: 900;
}

.discussion-card .task-icon {
  background: var(--green-soft);
  color: var(--green);
}

.speaking-card .task-icon {
  background: var(--coral-soft);
  color: var(--coral);
}

.task-library {
  display: grid;
  gap: 28px;
}

.task-library-header {
  display: grid;
  gap: 18px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.task-library-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.library-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--green);
  font-size: 1.2rem;
  font-weight: 900;
}

.section-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.section-pill {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
}

.section-pill.active {
  border-color: #317b70;
  background: #317b70;
  color: #ffffff;
}

.task-catalog {
  display: grid;
  gap: 18px;
}

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

.task-set-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 16px;
  padding: 20px;
}

.task-set-content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.task-set-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.task-set-header h3 {
  margin-top: 6px;
  font-size: 1.08rem;
}

.task-tag-list span {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.task-set-summary {
  margin: 0;
  min-height: 68px;
  padding: 14px;
  border-radius: 8px;
  background: #f7f9f7;
  color: var(--muted);
  line-height: 1.5;
}

.task-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-start-link {
  min-height: 44px;
  text-decoration: none;
}

.prompt-item {
  padding: 18px;
}

.prompt-item h3 {
  margin-top: 8px;
}

.prompt-item p:last-child,
.essay-row p,
.progress-item p,
.account-item p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.5;
}

.essay-row,
.progress-item,
.account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px 16px;
}

.account-item time {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.empty-state {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.writing-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(340px, 1.05fr);
  gap: 20px;
  align-items: start;
}

.speaking-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(340px, 1.1fr);
  gap: 20px;
  align-items: start;
}

.upload-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 20px;
  align-items: start;
}

.upload-form {
  display: grid;
  gap: 14px;
}

.email-task-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.email-task-details[hidden] {
  display: none;
}

.prompt-document {
  display: grid;
  gap: 16px;
  line-height: 1.65;
}

.prompt-document h2 {
  font-size: 1.35rem;
}

.prompt-document p {
  margin: 0;
}

.prompt-document ul {
  margin: 0;
  padding-left: 26px;
}

.professor-block,
.response-info {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.response-info p:first-child {
  font-weight: 850;
}

.discussion-response-list {
  display: grid;
  gap: 14px;
  margin-top: 4px;
}

.discussion-response {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border-left: 3px solid var(--line);
  background: #fbfcfb;
}

.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #f3c677;
  color: #18211f;
  font-weight: 900;
}

.writing-panel {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 14px;
}

.writing-panel textarea {
  width: 100%;
  min-height: 430px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  line-height: 1.55;
}

.writing-panel textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(36, 91, 206, 0.16);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topic-list,
.recording-list {
  display: grid;
  gap: 12px;
}

.topic-card {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  text-align: left;
}

.topic-card:hover,
.topic-card.active {
  border-color: var(--blue);
  background: #ffffff;
}

.topic-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.recorder-panel {
  display: grid;
  gap: 16px;
}

.selected-topic-prompt {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  line-height: 1.55;
}

.timer-pill {
  display: inline-grid;
  place-items: center;
  min-width: 76px;
  height: 38px;
  border-radius: 8px;
  background: #e8eefc;
  color: var(--blue-dark);
  font-weight: 900;
}

.recorder-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.audio-preview {
  width: 100%;
}

.attachment-list {
  display: grid;
  gap: 12px;
}

.attachment-list.compact {
  margin-top: 4px;
}

.attachment-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.attachment-name {
  margin: 0;
  color: var(--ink);
  font-weight: 850;
}

.attachment-item img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface-soft);
}

.attachment-item audio {
  width: 100%;
}

.attachment-item a {
  color: var(--blue);
  font-weight: 850;
}

.essay-submission-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.essay-submission-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
}

.recording-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.uploaded-task-list {
  display: grid;
  gap: 12px;
}

.uploaded-task-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.uploaded-task-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.recording-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.recording-card audio {
  width: 100%;
}

.teacher-recordings-panel {
  margin-top: 20px;
}

.student-feedback-panel {
  margin-top: 20px;
}

.feedback-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
  gap: 20px;
  align-items: start;
}

.feedback-source {
  display: grid;
  gap: 12px;
}

.source-essay {
  max-height: 560px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  line-height: 1.6;
  white-space: pre-wrap;
}

.feedback-editor,
.feedback-form,
.feedback-list,
.feedback-card {
  display: grid;
  gap: 14px;
}

.feedback-field {
  display: grid;
  gap: 8px;
}

.feedback-field span {
  color: var(--muted);
  font-weight: 850;
}

.feedback-field input,
.feedback-field textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  line-height: 1.55;
}

.feedback-field textarea {
  min-height: 120px;
  resize: vertical;
}

#feedbackEssayText,
#feedbackImprovedVersion {
  min-height: 220px;
}

.feedback-field input:focus,
.feedback-field textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(36, 91, 206, 0.16);
}

.score-input {
  max-width: 180px;
}

.feedback-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.feedback-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.feedback-section {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.feedback-section h4 {
  margin: 0;
  color: var(--ink);
}

.feedback-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.58;
  white-space: pre-wrap;
}

.submission-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.submission-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.score-pill,
.status-pill {
  display: inline-grid;
  place-items: center;
  min-width: 64px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 850;
}

.score-pill {
  background: #e8eefc;
  color: var(--blue-dark);
}

.status-pill {
  background: var(--coral-soft);
  color: var(--coral);
}

.status-pill.green {
  background: var(--green-soft);
  color: var(--green);
}

.submission-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(92px, 1.2fr) minmax(82px, 0.8fr) minmax(78px, 0.8fr) minmax(42px, 0.4fr);
  gap: 8px;
  align-items: center;
  min-width: 460px;
  min-height: 54px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.table-header {
  min-height: 40px;
  border-color: transparent;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.progress-item meter {
  width: 120px;
  height: 14px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    gap: 18px;
    padding: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-button {
    justify-content: center;
  }

  .nav-icon,
  .sidebar-footer,
  .brand-subtitle {
    display: none;
  }

  .workspace {
    padding: 24px;
  }

  .login-layout,
  .management-grid,
  .teacher-grid,
  .writing-layout,
  .speaking-layout,
  .upload-layout,
  .feedback-layout,
  .email-task-details,
  .task-choice-grid,
  .task-set-grid {
    grid-template-columns: 1fr;
  }

  .writing-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  h1 {
    font-size: 2.25rem;
  }

  .page-heading,
  .heading-actions,
  .task-set-header,
  .feedback-card-header,
  .submission-actions,
  .essay-row,
  .progress-item,
  .account-item,
  .account-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading {
    display: grid;
  }

  .reset-request-item {
    grid-template-columns: 1fr;
  }

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

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-action,
  .secondary-action {
    width: 100%;
  }

  .form-actions,
  .recorder-controls,
  .submission-meta {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .progress-item meter {
    width: 100%;
  }
}
