/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --navy-900: #00204a;
  --navy-800: #003478;
  --navy-700: #0a4696;
  --cyan-500: #00b3e9;
  --cyan-100: #e3f7fd;

  --ink-900: #1a2332;
  --ink-600: #4c5a6e;
  --ink-400: #8593a4;

  --surface: #ffffff;
  --page-bg: #f4f7fa;
  --border: #dde4ec;

  --success: #1e824c;
  --success-bg: #eaf6ef;
  --error: #c0392b;
  --error-bg: #fbebe9;

  --gauge-track: #e6ebf1;

  --font-display: "Source Serif 4", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 10px;
  --shadow-card: 0 1px 2px rgba(0, 32, 74, 0.06), 0 16px 40px -20px rgba(0, 32, 74, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--page-bg);
  font-family: var(--font-body);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Ribbon header
   ========================================================================== */
.ribbon {
  background: linear-gradient(155deg, var(--navy-800) 0%, var(--navy-900) 100%);
  border-bottom: 3px solid var(--cyan-500);
  padding: 48px 24px 72px;
}

.ribbon__inner {
  max-width: 640px;
  margin: 0 auto;
}

.ribbon__eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan-500);
  margin: 0 0 12px;
}

.ribbon__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 34px;
  line-height: 1.15;
  color: #ffffff;
  margin: 0 0 8px;
}

.ribbon__subtitle {
  font-size: 15px;
  color: #c3d3e6;
  margin: 0;
  max-width: 46ch;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.page--narrow {
  max-width: 440px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 36px 36px 32px;
  margin-top: -48px;
  position: relative;
}

/* ==========================================================================
   Google sign-in button + divider
   ========================================================================== */
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-900);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.google-btn:hover {
  border-color: var(--ink-400);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.google-btn:focus-visible {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(0, 52, 120, 0.14);
}

.google-btn__icon {
  flex: none;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  font-size: 12.5px;
  color: var(--ink-400);
}

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

.footnote {
  text-align: center;
  font-size: 13px;
  color: var(--ink-400);
  margin-top: 20px;
  line-height: 1.6;
}

/* ==========================================================================
   Context bar (populated when course/assignment come from the URL)
   ========================================================================== */
.context-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.context-bar__item {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  background: var(--cyan-100);
  color: var(--navy-800);
  border: 1px solid rgba(0, 179, 233, 0.35);
  border-radius: 100px;
  padding: 5px 12px;
}

/* ==========================================================================
   Fields
   ========================================================================== */
fieldset.field {
  border: none;
  margin: 0;
  padding: 0;
}

.field {
  margin-bottom: 22px;
}

.field__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-600);
  margin-bottom: 8px;
}

.field__label--sub {
  margin-top: 18px;
}

.field__hint {
  font-size: 13px;
  color: var(--ink-400);
  margin: -4px 0 10px;
}

.field__input,
.field__textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink-900);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field__textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.5;
  font-family: var(--font-mono);
  font-size: 13px;
}

.field__input:hover,
.field__textarea:hover {
  border-color: var(--ink-400);
}

.field__input:focus-visible,
.field__textarea:focus-visible {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(0, 52, 120, 0.14);
}

.field__input[aria-invalid="true"],
.field__textarea[aria-invalid="true"] {
  border-color: var(--error);
}

.field__error {
  font-size: 13px;
  color: var(--error);
  margin: 6px 0 0;
  min-height: 0;
  display: none;
}

.field__error.is-visible {
  display: block;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 28px 0 24px;
}

/* ==========================================================================
   Checkbox
   ========================================================================== */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.checkbox:hover {
  border-color: var(--navy-700);
}

.checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox__box {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1.5px solid var(--ink-400);
  border-radius: 4px;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.checkbox__box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.12s ease;
}

.checkbox input:checked ~ .checkbox__box {
  background: var(--navy-800);
  border-color: var(--navy-800);
}

.checkbox input:checked ~ .checkbox__box::after {
  transform: rotate(45deg) scale(1);
}

.checkbox input:focus-visible ~ .checkbox__box {
  box-shadow: 0 0 0 3px rgba(0, 52, 120, 0.18);
}

.checkbox__text {
  font-size: 14.5px;
  color: var(--ink-900);
  line-height: 1.4;
}

/* ==========================================================================
   Log field (collapses when "no AI used" is checked)
   ========================================================================== */
.log-field {
  margin-top: 18px;
  max-height: 500px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.25s ease;
}

.log-field.is-collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
}

/* ==========================================================================
   Submit row
   ========================================================================== */
.submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
}

.submit-row--stacked {
  flex-direction: column-reverse;
  align-items: stretch;
}

.submit-row--stacked .status {
  text-align: center;
}

.status {
  font-size: 13.5px;
  font-weight: 500;
  flex: 1;
}

.status.is-success { color: var(--success); }
.status.is-error { color: var(--error); }

.submit-btn {
  flex: none;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  color: #ffffff;
  background: var(--navy-800);
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.submit-btn:hover {
  background: var(--navy-700);
}

.submit-btn:active {
  transform: translateY(1px);
}

.submit-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 179, 233, 0.45);
}

.submit-btn:disabled {
  background: var(--ink-400);
  cursor: not-allowed;
}

.submit-btn--full {
  width: 100%;
  text-align: center;
}

/* ==========================================================================
   Success state
   ========================================================================== */
.card.is-submitted .field,
.card.is-submitted .divider,
.card.is-submitted fieldset.field {
  display: none;
}

.confirmation {
  display: none;
  text-align: center;
  padding: 12px 0 4px;
}

.card.is-submitted .confirmation {
  display: block;
}

.confirmation__icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 20px;
}

.confirmation__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px;
}

.confirmation__text {
  font-size: 14px;
  color: var(--ink-600);
  margin: 0;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px 32px;
}

.site-footer__text {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-400);
}

.site-footer__link {
  color: var(--navy-700);
  text-decoration: none;
  margin-left: 6px;
  padding-left: 6px;
  border-left: 1px solid var(--border);
}

.site-footer__link:hover {
  text-decoration: underline;
}

.site-footer__link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 52, 120, 0.14);
  border-radius: 3px;
}

/* ==========================================================================
   Dashboard body reset
   ========================================================================== */
.dashboard-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================================
   Dashboard: top bar
   ========================================================================== */
.topbar {
  flex: none;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--navy-800);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.topbar__brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink-900);
}

.topbar__brand-sub {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-400);
  margin-left: 4px;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-900);
}

/* ==========================================================================
   Dashboard: 3-column layout (25% / 75%)
   ========================================================================== */
.dashboard-columns {
  flex: 1;
  display: grid;
  grid-template-columns: 25% 75%;
  min-height: 0;
}

.col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: #ffffff;
}

.col--submissions {
  border-right: none;
  background: var(--page-bg);
}

.col__header {
  flex: none;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}

.col__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--ink-900);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col__subtitle {
  display: block;
  font-size: 12.5px;
  color: var(--ink-400);
  margin-top: 3px;
}

.col__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px 32px;
}

.col--submissions .col__body {
  padding: 24px 32px 40px;
}

/* ==========================================================================
   Dashboard: entity lists (courses / assignments)
   ========================================================================== */
.entity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.entity-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  transition: background 0.12s ease;
}

.entity-item:hover {
  background: var(--page-bg);
}

.entity-item.is-active {
  background: var(--cyan-100);
  border-left-color: var(--navy-800);
}

.entity-item__code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--cyan-500);
  text-transform: uppercase;
}

.entity-item__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-900);
}

.entity-item__meta {
  font-size: 12px;
  color: var(--ink-400);
}

/* ==========================================================================
   Dashboard: course groups (course header + nested assignment list)
   ========================================================================== */
.course-group {
  margin-bottom: 22px;
}

.course-group + .course-group {
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.course-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  margin-bottom: 8px;
}

.course-group__code {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--cyan-500);
  text-transform: uppercase;
}

.course-group__name {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink-900);
  margin-top: 1px;
}

.entity-list--nested {
  padding-left: 6px;
  border-left: 1px solid var(--border);
  margin-left: 12px;
}

.entity-list--nested .entity-item {
  padding: 8px 10px;
  border-radius: 6px;
}

.entity-list--nested .entity-item__name {
  font-size: 13px;
  font-weight: 450;
}

.course-group__add-btn {
  margin: 10px 0 0 12px;
}

/* ==========================================================================
   Dashboard: buttons
   ========================================================================== */
.btn-primary {
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  color: #ffffff;
  background: var(--navy-800);
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--navy-700);
}

.btn-primary--small {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-secondary {
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-600);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--ink-400);
}

.btn-secondary--small {
  padding: 7px 14px;
  font-size: 13px;
}

/* ==========================================================================
   Dashboard: empty states
   ========================================================================== */
.empty-state {
  font-size: 14px;
  color: var(--ink-400);
  text-align: center;
  padding: 28px 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin-top: 8px;
}

.empty-state--nested {
  margin: 6px 0 0 12px;
  padding: 14px;
  font-size: 12.5px;
}

/* ==========================================================================
   Dashboard: overview row (merged stats+gauge card, plus the disclosure link)
   ========================================================================== */
.overview-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 20px;
  margin-bottom: 28px;
}

.overview-card {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: none;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 28px;
}

.overview-card__stats {
  display: flex;
  flex-direction: column;
  min-width: 140px;
}

.overview-divider {
  align-self: stretch;
  width: 1px;
  background: var(--border);
}

.overview-card__gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-card__value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  color: var(--navy-800);
  margin: 0;
}

.stat-card__label {
  font-size: 12.5px;
  color: var(--ink-600);
  margin: 2px 0 0;
}

/* ==========================================================================
   Dashboard: AI usage gauge
   ========================================================================== */
.gauge-card__eyebrow {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-600);
  margin: 0 0 4px;
}

.gauge {
  position: relative;
  width: 160px;
  max-width: 100%;
}

.gauge svg {
  display: block;
  width: 100%;
  height: auto;
}

.gauge__value {
  position: absolute;
  left: 50%;
  top: 64%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.gauge__value-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  color: var(--ink-900);
}

.status-pill {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  padding: 5px 14px;
  border-radius: 100px;
  margin-top: 6px;
}

.status-pill--amber {
  background: #fdf1cf;
  color: #8a6416;
}

.gauge-legend {
  display: flex;
  gap: 16px;
  margin-top: 14px;
}

.gauge-legend--stacked {
  flex-direction: column;
  gap: 6px;
}

.gauge-legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-600);
}

.gauge-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.gauge-legend__dot--used {
  background: var(--navy-700);
}

.gauge-legend__dot--none {
  background: var(--gauge-track);
  border: 1px solid var(--border);
}

/* ==========================================================================
   Dashboard: disclosure link (baseline-style input, sits beside overview card)
   ========================================================================== */
.share-link {
  flex: 1;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.share-link__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.share-link__row .field__input {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.share-link__row .btn-primary--small {
  flex: none;
}

.field__input--baseline {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 6px 2px;
}

.field__input--baseline:hover {
  border-bottom-color: var(--ink-400);
}

.field__input--baseline:focus-visible {
  outline: none;
  box-shadow: none;
  border-bottom-color: var(--navy-700);
}

/* ==========================================================================
   Dashboard: submissions table
   ========================================================================== */
.submissions-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.submissions-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-600);
  background: #fbfcfd;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.submissions-table td {
  font-size: 13.5px;
  color: var(--ink-900);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

.submissions-table tr:last-child td {
  border-bottom: none;
}

.submissions-table tbody tr:hover td {
  background: var(--page-bg);
}

.submissions-table__email {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.ai-pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 100px;
}

.ai-pill--yes {
  background: var(--success-bg);
  color: var(--success);
}

.ai-pill--no {
  background: #eef1f5;
  color: var(--ink-600);
}

/* ==========================================================================
   Dashboard: modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 32, 74, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px;
}

.modal__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  margin: 0 0 4px;
  color: var(--ink-900);
}

.modal__subtitle {
  font-size: 13px;
  color: var(--ink-400);
  margin: 0 0 18px;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .dashboard-columns {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(280px, auto);
    overflow-y: auto;
  }
  .col {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .col__body {
    overflow-y: visible;
  }
}

@media (max-width: 480px) {
  .ribbon { padding: 36px 20px 64px; }
  .ribbon__title { font-size: 27px; }
  .card { padding: 26px 20px 24px; }
  .submit-row { flex-direction: column-reverse; align-items: stretch; }
  .submit-btn { width: 100%; text-align: center; }

  .topbar { padding: 0 16px; }
  .topbar__brand-sub { display: none; }
  .col__header { padding: 16px 16px 12px; }
  .col__body { padding: 12px 16px 24px; }

  .overview-row { flex-direction: column; }
  .overview-card { width: 100%; justify-content: center; }
  .share-link__row { flex-direction: column; align-items: stretch; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}