html,
body {
  min-height: 100%;
}

[data-theme="coffee"] {
  color-scheme: light;
  --color-base-100: oklch(98% 0.012 72);
  --color-base-200: oklch(94% 0.018 72);
  --color-base-300: oklch(88% 0.026 72);
  --color-base-content: oklch(22% 0.035 54);
  --color-primary: oklch(43% 0.112 55);
  --color-primary-content: oklch(98% 0.012 72);
  --color-secondary: oklch(48% 0.072 48);
  --color-secondary-content: oklch(98% 0.012 72);
  --color-accent: oklch(62% 0.118 62);
  --color-accent-content: oklch(20% 0.035 54);
  --color-neutral: oklch(25% 0.035 54);
  --color-neutral-content: oklch(98% 0.012 72);
}

body {
  margin: 0;
}

a {
  text-decoration: none;
}

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

.wrap {
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.brand {
  font-weight: 800;
}

.header-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-form,
.panel-actions form,
.row-actions form,
.student-detail-actions form,
.submission-ops-line form {
  margin: 0;
}

.page-shell {
  padding: 2rem 0 3.5rem;
}

.flash-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.hero-card,
.detail-grid {
  display: grid;
  gap: 1.5rem;
}

.hero-card {
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  align-items: start;
}

.hero-copy {
  padding-top: 1rem;
}

.hero-copy h1,
.panel h1 {
  margin: 0 0 0.875rem;
  font-size: clamp(2.25rem, 4vw, 4rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.panel h1 {
  font-size: clamp(2rem, 3vw, 3rem);
}

.panel :is(h1, h2) {
  overflow-wrap: break-word;
  text-wrap: balance;
}

.panel h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.2vw, 2.125rem);
  font-weight: 700;
  line-height: 1.15;
}

.heading-subtext {
  display: block;
  margin-top: 0.375rem;
  max-width: 100%;
  font-size: clamp(1rem, 1.45vw, 1.25rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
  opacity: 0.68;
  overflow-wrap: anywhere;
  text-wrap: wrap;
}

.hero-copy p,
.panel p,
.content-list dd,
.meta-grid dd,
.followup-message-text,
.followup-context-label {
  line-height: 1.75;
}

.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.72;
}

.panel {
  padding: 1.5rem;
}

.form-panel,
.auth-panel {
  display: grid;
  gap: 1rem;
}

.form-panel :is(.input, .select, .textarea),
.auth-panel :is(.input, .select, .textarea) {
  width: 100%;
  max-width: none;
}

.form-panel > .btn,
.auth-panel > .btn {
  width: 100%;
}

.form-panel.form-inline {
  grid-template-columns: minmax(16rem, 24rem) auto;
  align-items: end;
}

.form-panel.form-inline .compact-copy {
  grid-column: 1 / -1;
}

.form-panel.form-inline > .btn {
  align-self: end;
  justify-self: start;
  width: auto;
}

.form-panel.form-grid {
  grid-template-columns: repeat(3, minmax(12rem, 1fr)) auto;
  align-items: end;
}

.form-panel.form-grid .compact-copy {
  grid-column: 1 / -1;
}

.form-panel.form-grid > .btn {
  align-self: end;
  justify-self: start;
  width: auto;
}

.form-panel + .form-panel {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-base-300);
}

.field {
  display: grid;
  gap: 0.5rem;
  padding: 0;
}

.field span,
dt {
  font-size: 0.8125rem;
  font-weight: 800;
}

.textarea,
textarea {
  min-height: 20rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.55;
}

.text-link {
  font-weight: 800;
}

.auth-shell {
  display: flex;
  justify-content: center;
  padding-top: 3rem;
}

.auth-panel {
  width: min(460px, 100%);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel-actions,
.row-actions,
.pagination-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.625rem;
}

.row-reset-form,
.inline-edit-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.action-stack,
.student-detail-actions {
  display: grid;
  gap: 0.875rem;
}

.admin-inline-input,
.admin-reset-input {
  width: 150px;
}

.compact-copy {
  padding: 0;
}

.table-shell {
  overflow-x: auto;
}

.spaced-table {
  margin-top: 1.5rem;
}

table {
  width: 100%;
  min-width: 720px;
}

.submission-table-shell {
  overflow-x: visible;
}

.submission-list-table {
  min-width: 0;
  table-layout: fixed;
}

.student-overview-table {
  min-width: 860px;
}

.status-cell,
.actions-cell,
.student-cell,
.student-meta-cell,
.student-count-cell,
.student-submission-table td {
  vertical-align: middle;
}

.actions-cell {
  min-width: 210px;
}

.student-name-cell {
  min-width: 240px;
}

.student-meta-cell {
  min-width: 150px;
  white-space: nowrap;
}

.student-count-cell {
  min-width: 72px;
  white-space: nowrap;
}

.student-summary {
  display: grid;
  gap: 0.375rem;
}

.student-summary strong {
  font-size: 1rem;
}

.student-label {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.table-note {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  opacity: 0.72;
}

.submission-list-table th,
.submission-list-table td {
  padding: 0.8125rem 0.625rem;
}

.submission-primary-cell {
  width: 64%;
  vertical-align: middle;
}

.submission-primary-line {
  display: grid;
  gap: 0.4375rem;
  min-width: 0;
}

.submission-meta-line {
  display: flex;
  align-items: center;
  min-width: 0;
  white-space: nowrap;
  font-size: 0.8125rem;
  font-weight: 700;
}

.submission-meta-line > span {
  min-width: 0;
}

.submission-meta-line > span:not(:first-child)::before {
  content: "·";
  margin: 0 0.5rem;
  opacity: 0.72;
}

.submission-time,
.submission-student,
.submission-mode {
  flex: none;
  white-space: nowrap;
}

.submission-title-line {
  display: block;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
  opacity: 0.72;
}

.submission-status-cell {
  width: 36%;
  vertical-align: middle;
}

.submission-status-panel {
  display: grid;
  align-content: center;
  gap: 0.5625rem;
}

.submission-status-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}

.submission-ops-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

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

.detail-grid > .panel:nth-child(1) {
  grid-column: 1 / -1;
}

.detail-form-panel {
  max-width: 420px;
}

.meta-grid,
.content-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.125rem;
}

.meta-grid div,
.content-list div,
.issue-card,
.note-block {
  padding-top: 0.875rem;
  border-top: 1px solid var(--color-base-300);
}

.code-block,
.inline-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.65;
}

.code-block {
  padding: 1rem;
  overflow: auto;
}

.inline-pre {
  padding: 0.75rem;
}

.diagnosis-summary {
  margin-bottom: 1.25rem;
}

.diagnosis-summary .eyebrow {
  margin-bottom: 0.625rem;
}

.diagnosis-summary h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.3125rem, 2vw, 1.75rem);
  line-height: 1.4;
}

.diagnosis-summary-meta {
  margin: 0;
  font-size: 0.8125rem;
}

.issue-card,
.note-block {
  margin-top: 1rem;
  padding: 1rem;
}

.issue-card h3,
.note-block h3,
.diagnosis-program-panel h3,
.followup-history-block h3 {
  margin: 0 0 0.625rem;
  font-size: 1.25rem;
  line-height: 1.25;
}

.note-block ul {
  margin: 0.625rem 0 0;
  padding-left: 1.25rem;
  line-height: 1.75;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.weak-point-panel {
  grid-column: 1 / -1;
}

.operations-failures-panel {
  grid-column: 1 / -1;
}

.weak-point-note {
  margin-bottom: 1rem;
}

.student-weak-point-actions {
  margin-bottom: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-base-300);
}

.student-weak-point-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.student-weak-point-action {
  margin: 0.625rem 0 0;
  line-height: 1.65;
}

.weak-point-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.weak-point-section-title {
  margin-bottom: 0.75rem;
}

.weak-point-list {
  display: grid;
  gap: 0.75rem;
}

.weak-point-item {
  padding: 0.875rem;
  border: 1px solid var(--color-base-300);
  background: var(--color-base-100);
}

.weak-point-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.weak-point-badges,
.weak-point-evidence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.weak-point-evidence-list {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.6;
}

.diagnosis-program-panel .code-block {
  max-height: 720px;
}

.empty-state {
  margin: 0;
  opacity: 0.72;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.125rem;
}

.pagination-info {
  margin: 0;
  opacity: 0.72;
}

.success-panel {
  max-width: 760px;
}

.detail-layout-with-followup {
  display: flex;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
}

.detail-main-column {
  flex: 1 1 auto;
  min-width: 0;
}

.followup-drawer-scrim {
  display: none;
}

.followup-drawer-frame {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  margin-left: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition:
    width 0.28s ease,
    flex-basis 0.28s ease,
    margin-left 0.28s ease,
    opacity 0.18s ease;
}

.detail-layout-with-followup.is-followup-open .followup-drawer-frame {
  flex-basis: clamp(300px, 29vw, 380px);
  width: clamp(300px, 29vw, 380px);
  margin-left: 1.125rem;
  opacity: 1;
  pointer-events: auto;
}

.followup-drawer-panel {
  display: grid;
  align-content: start;
  gap: 1rem;
  max-height: calc(100vh - 132px);
  overflow-y: auto;
  position: sticky;
  top: 92px;
}

.followup-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.followup-drawer-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.35;
}

.followup-intro,
.followup-meta {
  margin: 0;
}

.followup-history-block {
  display: grid;
  gap: 0.75rem;
}

.followup-thread-shell {
  max-height: min(56vh, 560px);
  overflow-y: auto;
  padding-right: 0.375rem;
}

.followup-thread {
  display: grid;
  gap: 0.75rem;
}

.followup-message {
  display: grid;
  gap: 0.625rem;
  padding: 1rem;
}

.followup-message-text,
.followup-context-label {
  margin: 0;
}

.followup-context {
  display: grid;
  gap: 0.5rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--color-base-300);
}

.followup-form textarea {
  min-height: 120px;
}

.followup-inline-error {
  margin: 0;
}

@media (max-width: 900px) {
  body.followup-drawer-open {
    overflow: hidden;
  }

  .wrap {
    width: min(100vw - 24px, 1160px);
  }

  .header-content,
  .panel-header,
  .student-weak-point-header {
    flex-direction: column;
  }

  .header-nav {
    justify-content: flex-start;
  }

  .hero-card,
  .detail-grid,
  .meta-grid,
  .content-list,
  .weak-point-layout {
    grid-template-columns: 1fr;
  }

  .hero-card {
    gap: 1.125rem;
  }

  .hero-copy {
    padding-top: 0.75rem;
  }

  .form-panel.form-inline,
  .form-panel.form-grid {
    grid-template-columns: 1fr;
  }

  .form-panel.form-inline > .btn,
  .form-panel.form-grid > .btn {
    width: 100%;
  }

  .submission-table-shell {
    overflow-x: auto;
  }

  .submission-list-table {
    min-width: 720px;
  }

  .detail-layout-with-followup {
    display: block;
  }

  .followup-drawer-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 24;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .detail-layout-with-followup.is-followup-open .followup-drawer-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .followup-drawer-frame {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    flex: none;
    width: min(92vw, 380px);
    max-width: 380px;
    opacity: 1;
    pointer-events: none;
    transform: translateX(100%);
    transition: transform 0.28s ease;
  }

  .detail-layout-with-followup.is-followup-open .followup-drawer-frame {
    margin-left: 0;
    transform: translateX(0);
    pointer-events: auto;
  }

  .followup-drawer-panel {
    position: relative;
    top: auto;
    height: 100dvh;
    max-height: none;
  }

  .followup-thread-shell {
    max-height: min(48vh, 420px);
  }
}

@media (max-width: 560px) {
  .page-shell {
    padding: 1.375rem 0 2.5rem;
  }

  .header-nav {
    width: 100%;
  }

  .header-nav .btn,
  .nav-form,
  .nav-form .btn {
    flex: 1 1 auto;
  }

  .panel-actions,
  .row-actions,
  .pagination-bar {
    align-items: stretch;
  }

  .panel-actions,
  .row-actions,
  .pagination-actions {
    width: 100%;
  }

  .panel-actions form,
  .row-actions form,
  .student-detail-actions form,
  .submission-ops-line form {
    width: 100%;
  }

  .panel-actions .btn,
  .row-actions .btn,
  .student-detail-actions .btn,
  .submission-ops-line .btn,
  .pagination-actions .btn {
    width: 100%;
  }

  .hero-copy h1,
  .panel h1 {
    font-size: clamp(1.75rem, 9vw, 2.25rem);
    line-height: 1.05;
  }

  .heading-subtext {
    font-size: 0.9375rem;
  }
}
