:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #607069;
  --line: #d9ded9;
  --accent: #006b3f;
  --accent-dark: #004b2c;
  --accent-soft: #e6f2eb;
  --accent-pale: #f7faf8;
  --danger: #b42318;
  --danger-soft: #fff6f5;
  --danger-line: #f1aaa3;
  --gold: #c8a542;
  --warn: #a15c10;
  --shadow: 0 12px 28px rgba(31, 41, 51, 0.08);
}

body.dark-mode {
  --bg: #101614;
  --panel: #17211d;
  --ink: #edf4ef;
  --muted: #a8b8af;
  --line: #314139;
  --accent: #31a66a;
  --accent-dark: #7ed9a7;
  --accent-soft: #153425;
  --accent-pale: #13231b;
  --danger: #ff8a80;
  --danger-soft: #311b1b;
  --danger-line: #7b3430;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

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

button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  min-height: 36px;
  padding: 7px 11px;
}

body.dark-mode button,
body.dark-mode .file-button {
  background: #1d2a25;
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

button.primary,
#exportBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover,
#exportBtn:hover {
  background: var(--accent-dark);
}

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 12px rgba(31, 41, 51, 0.06);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 14px 24px;
  position: relative;
  z-index: 4;
}

body.dark-mode .topbar {
  background: #111916;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.24);
}

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

.brand-logo {
  display: block;
  flex: 0 0 auto;
  height: 38px;
  object-fit: contain;
  width: auto;
}

.topbar h1,
.workspace h2,
.sidebar h2,
.dialog-card h2 {
  margin: 0;
}

.topbar h1 {
  color: var(--accent-dark);
  font-size: 23px;
  line-height: 1.15;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.topbar-actions,
.export-actions,
.step-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-toggle {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.theme-icon {
  align-items: center;
  display: inline-flex;
  font-size: 16px;
  height: 18px;
  justify-content: center;
  line-height: 1;
  width: 18px;
}

.topbar-actions button,
.topbar-actions .file-button {
  background: #fff;
}

body.dark-mode .topbar-actions button,
body.dark-mode .topbar-actions .file-button {
  background: #1d2a25;
}

.theme-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.file-button input {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: calc(100vh - 130px);
  min-width: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #f1f3f1;
  overflow: auto;
  padding: 20px;
}

body.dark-mode .sidebar {
  background: #121a17;
}

.student-panel,
.mark-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(31, 41, 51, 0.04);
}

.student-panel h2,
.mark-panel h2 {
  color: var(--accent-dark);
  font-size: 18px;
}

.form-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

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

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #101816;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 107, 63, 0.14);
  outline: 0;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.score-row {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin: 12px 0;
}

.score-row strong {
  color: var(--accent-dark);
  font-size: 34px;
}

.panel-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 12px;
}

.mark-panel label + label,
.total-score {
  margin-top: 12px;
}

.total-score {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.total-score strong {
  color: var(--accent);
}

.progress-meter {
  background: #d9e5e6;
  border-radius: 999px;
  height: 10px;
  margin-top: 14px;
  overflow: hidden;
}

.progress-meter span {
  background: var(--accent);
  display: block;
  height: 100%;
  width: 0;
}

#progressText {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
}

body.dark-mode .progress-meter {
  background: #263831;
}

.criterion-nav {
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.05);
  margin: 0;
  overflow-x: auto;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 3;
}

body.dark-mode .criterion-nav {
  background: rgba(17, 25, 22, 0.96);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.criterion-nav-head {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 700;
  justify-content: space-between;
  margin-bottom: 10px;
}

#criterionList {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.criterion-group {
  border-top: 2px solid var(--line);
  display: grid;
  gap: 7px;
  min-width: min(100%, 250px);
  padding-top: 7px;
}

.criterion-group-title {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 8px;
  min-height: 28px;
}

.criterion-group-title span {
  background: var(--accent-pale);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
}

.criterion-group-title strong {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  max-width: 330px;
}

.criterion-group-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.criterion-link {
  align-items: center;
  aspect-ratio: 1;
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-radius: 6px;
  color: var(--danger);
  display: inline-flex;
  justify-content: center;
  padding: 0;
  position: relative;
  text-align: center;
  width: 38px;
}

.criterion-link strong {
  align-items: center;
  background: transparent;
  border-radius: 0;
  color: var(--danger);
  display: inline-flex;
  font-size: 13px;
  height: auto;
  justify-content: center;
  width: auto;
}

.criterion-link span {
  display: none;
}

.criterion-link.active {
  box-shadow: 0 0 0 2px rgba(0, 107, 63, 0.32);
}

.criterion-link.complete {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.criterion-link.complete strong {
  color: var(--accent-dark);
}

.criterion-link.complete::after {
  background: var(--accent);
  border-radius: 999px;
  bottom: 4px;
  content: "";
  height: 5px;
  position: absolute;
  width: 5px;
}

.workspace {
  background: var(--bg);
  overflow: auto;
  padding: 28px;
  min-width: 0;
}

.workspace-head {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

#criterionTitle {
  color: var(--accent-dark);
  font-size: 24px;
  max-width: 900px;
}

.criterion-description {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  margin: 6px 0 0;
  max-width: 900px;
}

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

.band-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 8px;
  font-weight: 400;
  min-height: 150px;
  padding: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.band-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.08);
}

.band-card input {
  width: auto;
}

.band-card.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.band-card-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.band-card-head > span:first-child {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.band-card h3 {
  font-size: 16px;
  margin: 0;
}

.band-card strong {
  color: var(--accent-dark);
}

.band-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.band-score {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
}

.band-card p {
  color: #334149;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  margin: 0;
}

body.dark-mode .band-card p {
  color: #d7e1dc;
}

.feedback-field {
  margin-top: 18px;
}

.criterion-feedback-toggle {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
  margin-top: 14px;
  padding: 12px 14px;
  width: 100%;
}

body.dark-mode .criterion-feedback-toggle,
body.dark-mode .criterion-feedback-field,
body.dark-mode .main-feedback-field {
  background: var(--panel);
}

.criterion-feedback-toggle summary {
  cursor: pointer;
}

.criterion-feedback-toggle:focus-within,
.criterion-feedback-toggle:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 107, 63, 0.14);
  outline: 0;
}

.criterion-feedback-field {
  background: #fff;
  margin-top: 12px;
}

.section-divider {
  border-top: 1px solid var(--line);
  margin: 22px 0 0;
}

.main-feedback-field {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.summary-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 20px;
  padding: 18px;
}

.summary-table {
  border-collapse: collapse;
  width: 100%;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.summary-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.site-footer {
  align-items: center;
  background: #fff;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 6px;
  justify-content: center;
  padding: 14px 20px;
  text-align: center;
}

.site-footer a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

body.dark-mode .site-footer {
  background: #111916;
}

dialog {
  background: var(--panel);
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  box-shadow: var(--shadow);
  max-width: min(1000px, 94vw);
  width: 1000px;
}

dialog::backdrop {
  background: rgba(8, 17, 22, 0.5);
}

.dialog-card {
  margin: 0;
}

.dialog-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.export-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 360px;
  overflow: auto;
  padding: 16px;
}

body.dark-mode .export-preview {
  background: #f7faf8;
  color: #172024;
}

.moodle-feedback {
  color: #172024;
  font-family: Arial, Helvetica, sans-serif;
}

.moodle-feedback h2,
.moodle-feedback h3 {
  margin: 18px 0 8px;
}

.moodle-feedback table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
}

.moodle-feedback th,
.moodle-feedback td {
  border: 1px solid #cfd7dc;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }

  .criterion-nav {
    max-height: 150px;
    top: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 14px;
  }

  #criterionList {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    min-width: max-content;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .criterion-group {
    border-top-width: 1px;
    flex: 0 0 auto;
    gap: 5px;
    min-width: 0;
    padding-top: 5px;
  }

  .criterion-group-title {
    min-height: 22px;
  }

  .criterion-group-title strong {
    display: none;
  }

  .criterion-group-title span {
    font-size: 11px;
    padding: 1px 7px;
  }

  .criterion-group-buttons {
    flex-wrap: nowrap;
    gap: 5px;
  }

  .criterion-link {
    height: 32px;
    min-height: 32px;
    width: 32px;
  }

  .criterion-link strong {
    font-size: 12px;
  }

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

@media (max-width: 680px) {
  .topbar,
  .workspace-head {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-logo {
    height: 34px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .workspace,
  .sidebar {
    padding: 14px;
  }

}
