/* ═══════════════════════════════════════════════════════
   ÍSAT — Nordic Editorial Design System
   Icelandic as a Second Language Assessment Tool
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,500&display=swap');

:root {
  /* ── Palette ── */
  --ink:        #1A2332;
  --ink-75:     #3D4A5C;
  --ink-50:     #6B7A8D;
  --ink-25:     #A0ABB8;
  --ink-10:     #D4DAE2;
  --ink-05:     #EDF0F4;

  --teal:       #0B7A6F;
  --teal-dark:  #065E55;
  --teal-light: #D1FAF0;
  --teal-glow:  #0DCCB5;

  --ocean:      #1B5E8A;
  --ocean-light:#DAF0FF;

  --amber:      #D4870B;
  --amber-light:#FFF3D6;

  --coral:      #C4443A;
  --coral-light:#FDECEB;

  --sage:       #2D8A5E;
  --sage-light: #E4F5EC;

  --paper:      #FAFBFC;
  --parchment:  #F5F3EF;
  --card:       #FFFFFF;
  --card-hover: #FCFCFD;

  /* ── Grading Colors (Mentor match) ── */
  --grade-4:    #1B7A44;
  --grade-4-bg: #D1FAE5;
  --grade-3:    #2D8A5E;
  --grade-3-bg: #E4F5EC;
  --grade-2:    #D48B0B;
  --grade-2-bg: #FFF3D6;
  --grade-1:    #C4443A;
  --grade-1-bg: #FDECEB;

  /* ── Type ── */
  --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body:    'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* ── Geometry ── */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-xs:  0 1px 2px rgba(26,35,50,0.04);
  --shadow-sm:  0 1px 3px rgba(26,35,50,0.06), 0 1px 2px rgba(26,35,50,0.04);
  --shadow:     0 4px 6px -1px rgba(26,35,50,0.07), 0 2px 4px -2px rgba(26,35,50,0.05);
  --shadow-md:  0 10px 25px -5px rgba(26,35,50,0.08), 0 8px 10px -6px rgba(26,35,50,0.04);
  --shadow-lg:  0 20px 50px -12px rgba(26,35,50,0.15);
  --shadow-glow:0 0 0 3px rgba(11,122,111,0.15);

  --transition: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}


/* ════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  padding-top: 72px;
  min-height: 100vh;
}

/* Subtle paper texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.015'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: -1;
}

a {
  color: var(--teal);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--teal-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.25;
  color: var(--ink);
  letter-spacing: -0.01em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; font-family: var(--font-body); font-weight: 600; }

p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
img { max-width: 100%; height: auto; display: block; }


/* ════════════════════════════════════════
   NAVIGATION
   ════════════════════════════════════════ */

.main-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--ink-10);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  height: 72px;
  gap: 2.5rem;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--teal);
  text-decoration: none;
  letter-spacing: -1px;
  position: relative;
}
.nav-brand::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--teal-glow));
  border-radius: 2px;
  opacity: 0.6;
}
.nav-brand:hover { text-decoration: none; color: var(--teal-dark); }

.nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}
.nav-links a {
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius);
  color: var(--ink-50);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  transition: all var(--transition);
  position: relative;
}
.nav-links a:hover {
  color: var(--ink);
  background: var(--ink-05);
  text-decoration: none;
}
.nav-links a.active {
  color: var(--teal);
  background: var(--teal-light);
  font-weight: 600;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.nav-username {
  color: var(--ink-50);
  font-size: 0.85rem;
  font-weight: 500;
}
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--ink-10);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--ink-50);
  transition: all var(--transition);
}
.nav-toggle:hover { border-color: var(--ink-25); color: var(--ink); }


/* ════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════ */

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

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


/* ════════════════════════════════════════
   CARDS
   ════════════════════════════════════════ */

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--ink-10);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--ink-05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: linear-gradient(180deg, var(--ink-05) 0%, transparent 100%);
}

.card-body {
  padding: 1.75rem;
}

.card-footer {
  padding: 1rem 1.75rem;
  border-top: 1px solid var(--ink-05);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: var(--paper);
}

/* Stat Cards */
.stat-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  border: 1px solid var(--ink-10);
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--teal-glow));
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-number {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--teal);
  line-height: 1.1;
}
.stat-label {
  color: var(--ink-50);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.35rem;
}
.stat-inline { font-size: 1.1rem; }


/* ════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.35rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: all var(--transition);
  line-height: 1.4;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  box-shadow: 0 1px 3px rgba(11,122,111,0.25);
}
.btn-primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  box-shadow: 0 4px 12px rgba(11,122,111,0.3);
  color: #fff;
}

.btn-secondary {
  background: var(--ocean);
  color: #fff;
  border-color: var(--ocean);
}
.btn-secondary:hover {
  background: #144F75;
  border-color: #144F75;
  color: #fff;
}

.btn-success {
  background: var(--sage);
  color: #fff;
  border-color: var(--sage);
}
.btn-success:hover { background: #247A51; color: #fff; }

.btn-danger {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral);
}
.btn-danger:hover { background: #A83830; color: #fff; }

.btn-outline {
  background: var(--card);
  color: var(--ink-75);
  border-color: var(--ink-10);
}
.btn-outline:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-light);
}

.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.78rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 0.85rem 2.25rem; font-size: 1rem; border-radius: var(--radius); }
.btn-block { display: flex; width: 100%; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }


/* ════════════════════════════════════════
   FORMS
   ════════════════════════════════════════ */

.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-50);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--ink-10);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--card);
  transition: all var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: var(--shadow-glow);
}
.form-control::placeholder {
  color: var(--ink-25);
}

.form-control-inline { width: auto; display: inline-block; min-width: 140px; }

.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 2.75rem; }
.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--ink-50);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.password-toggle:hover { color: var(--ink); }
.password-toggle:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle .icon-eye-off { display: none; }
.password-toggle.is-visible .icon-eye { display: none; }
.password-toggle.is-visible .icon-eye-off { display: block; }

.form-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.35rem 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.form-check input[type="radio"],
.form-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--teal);
  margin: 0;
  cursor: pointer;
}

.radio-group { display: flex; gap: 1.5rem; flex-wrap: wrap; }

textarea.form-control { resize: vertical; min-height: 80px; }


/* ════════════════════════════════════════
   TABLES
   ════════════════════════════════════════ */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table th {
  padding: 0.75rem 1.25rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-50);
  background: var(--ink-05);
  border-bottom: 2px solid var(--ink-10);
}
.table th:first-child { border-radius: var(--radius) 0 0 0; }
.table th:last-child  { border-radius: 0 var(--radius) 0 0; }

.table td {
  padding: 0.85rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--ink-05);
  font-size: 0.92rem;
  vertical-align: middle;
}
.table-hover tbody tr {
  transition: background var(--transition);
}
.table-hover tbody tr:hover {
  background: var(--parchment);
}


/* ════════════════════════════════════════
   BADGES & PILLS
   ════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-info    { background: var(--ocean-light); color: var(--ocean); }
.badge-success { background: var(--sage-light);  color: var(--sage); }
.badge-warning { background: var(--amber-light); color: var(--amber); }
.badge-orange  { background: var(--amber-light); color: #B5750A; }
.badge-danger  { background: var(--coral-light); color: var(--coral); }

.grade-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.85rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.82rem;
  min-width: 44px;
}


/* ════════════════════════════════════════
   ALERTS
   ════════════════════════════════════════ */

.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border-left: 4px solid;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
  line-height: 1.5;
}
.alert-success { background: var(--sage-light);  border-color: var(--sage);  color: #1B5E3A; }
.alert-error   { background: var(--coral-light); border-color: var(--coral); color: #8B2920; }
.alert-warning { background: var(--amber-light); border-color: var(--amber); color: #7A5006; }
.alert-info    { background: var(--ocean-light); border-color: var(--ocean); color: #134468; }


/* ════════════════════════════════════════
   LOGIN
   ════════════════════════════════════════ */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(11,122,111,0.06) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, rgba(27,94,138,0.05) 0%, transparent 60%),
    var(--parchment);
}
body:has(.login-wrapper) { padding-top: 0; }
body:has(.login-wrapper)::before { display: none; }

.login-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 3rem 2.75rem;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  border: 1px solid var(--ink-10);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--teal), var(--teal-glow), var(--ocean));
}

.login-logo {
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--teal);
  text-align: center;
  margin-bottom: 0.15rem;
  letter-spacing: -1.5px;
}
.login-subtitle {
  text-align: center;
  color: var(--ink-50);
  margin-bottom: 2.5rem;
  font-size: 0.9rem;
  font-weight: 400;
}


/* ════════════════════════════════════════
   TEST ADMINISTRATION
   ════════════════════════════════════════ */

.test-container { max-width: 820px; margin: 0 auto; }

.test-info .card-body {
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.test-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--teal-light);
  color: var(--teal-dark);
  padding: 0.35rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 3px;
  border: 1px solid rgba(11,122,111,0.15);
}

/* Progress */
.test-progress { margin: 1.5rem 0; }
.progress-bar {
  height: 6px;
  background: var(--ink-05);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-glow));
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.progress-text {
  font-size: 0.8rem;
  color: var(--ink-50);
  margin-top: 0.4rem;
  display: block;
  font-weight: 500;
}

/* Questions */
.question-card {
  animation: questionSlideIn 0.35s ease-out;
}
.question-card.hidden { display: none; }

.question-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.question-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(11,122,111,0.25);
}
.question-number-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--teal-light);
  color: var(--teal);
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.question-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}
.question-text {
  margin-bottom: 1.25rem;
  line-height: 1.75;
  color: var(--ink-75);
  font-size: 0.95rem;
}

.example-box {
  background: var(--parchment);
  border-left: 3px solid var(--amber);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.25rem 0;
  font-style: italic;
  color: var(--ink-75);
  font-size: 0.92rem;
}

.reading-passage {
  background: var(--parchment);
  border: 1px solid var(--ink-10);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin: 1.25rem 0;
  line-height: 1.85;
  font-size: 0.95rem;
  position: relative;
}
.reading-passage::before {
  content: '„';
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--ink-10);
  position: absolute;
  top: 0.25rem; left: 0.75rem;
  line-height: 1;
}

.answer-area { margin-top: 1.75rem; }
.sub-question { margin-bottom: 1.15rem; }
.sub-question label {
  font-weight: 500;
  display: block;
  margin-bottom: 0.3rem;
  color: var(--ink);
  font-size: 0.92rem;
  text-transform: none;
  letter-spacing: normal;
}
.inline-question { display: flex; align-items: center; gap: 0.85rem; }

.nav-buttons {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
}

/* Save indicator */
.save-indicator {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  background: var(--sage);
  color: #fff;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow-md);
  transition: opacity 0.3s, transform 0.3s;
}
.save-indicator.hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}


/* ════════════════════════════════════════
   QUESTION TYPES
   ════════════════════════════════════════ */

/* Colors */
.color-question {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
}
.color-swatch {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  border: 2px solid var(--ink-10);
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

/* Question main image (scene/article photo) */
.question-main-image {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--ink-10);
  display: block;
  margin: 0 auto;
}

/* Image Labels */
.image-label-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.image-label-item { text-align: center; }
.image-label-grid.inline-layout { grid-template-columns: 1fr; gap: 1rem; }
.image-label-grid.inline-layout .image-label-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
}
.image-label-grid.inline-layout .image-label-item img,
.image-label-grid.inline-layout .image-label-item .slot-image {
  width: 120px;
  max-height: 120px;
  flex-shrink: 0;
  margin-bottom: 0;
}
.image-label-grid.inline-layout .image-label-item .image-placeholder {
  width: 120px;
  min-height: 80px;
  flex-shrink: 0;
  margin-bottom: 0;
}
.image-label-grid.inline-layout .image-label-item input,
.image-label-grid.inline-layout .image-label-item .preview-answer-placeholder {
  flex: 1;
  min-width: 0;
}
.image-label-item img,
.image-label-item .slot-image {
  width: 100%;
  max-height: 140px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ink-10);
  background: var(--parchment);
  padding: 0.25rem;
  margin-bottom: 0.5rem;
}
.image-placeholder {
  background: var(--parchment);
  border: 2px dashed var(--ink-10);
  border-radius: var(--radius);
  padding: 1.75rem 0.75rem;
  margin-bottom: 0.5rem;
  color: var(--ink-50);
  font-size: 0.82rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

/* True/False */
.tf-question {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--ink-05);
}
.tf-question:last-child { border-bottom: none; }
.tf-question p { color: var(--ink); }

/* Multiple Choice */
.mc-question {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--ink-05);
}

/* Matching */
.matching-container { display: flex; gap: 2rem; }
.matching-col { flex: 1; }
.matching-col-header {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-50);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--ink-10);
}

/* 3-column matching */
.matching-3col {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.matching-3col input[type="hidden"] { display: none; }
.matching-left-col, .matching-mid-col, .matching-right-col {
  flex: 1;
  min-width: 0;
}
.match-col-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-50);
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--ink-10);
}
.match-label {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--ink-05);
}
.match-box {
  min-height: 42px;
  border: 2px dashed var(--ink-10);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.95rem;
  color: var(--ink-25);
  background: var(--paper);
}
.match-box:hover { border-color: var(--teal); background: var(--teal-light); }
.match-box.filled {
  border-style: solid;
  border-color: var(--teal);
  background: var(--teal-light);
  color: var(--ink);
  font-weight: 600;
}
.match-box-preview {
  min-height: 38px;
  border: 2px dashed var(--ink-10);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-25);
  font-size: 0.9rem;
}
.match-words-col,
.matching-right-col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.match-word, .match-word-preview {
  padding: 0.5rem 0.85rem;
  background: var(--ocean-light);
  color: var(--ocean);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.15s;
  text-align: center;
  border: 2px solid transparent;
  user-select: none;
}
.match-word:hover { background: var(--ocean); color: #fff; }
.match-word.selected { border-color: var(--ocean); background: var(--ocean); color: #fff; }
.match-word.used { opacity: 0.3; pointer-events: none; text-decoration: line-through; }
.match-word-preview { cursor: default; }

/* Drawing Canvas */
.drawing-container { margin-top: 0.5rem; }
.drawing-canvas {
  border: 3px solid var(--teal);
  border-radius: var(--radius);
  cursor: crosshair;
  touch-action: none;
  display: block;
  width: 100%;
  max-width: 700px;
  height: 350px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--ink-10);
}
.drawing-tools {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  background: var(--parchment);
  border-radius: var(--radius);
  border: 1px solid var(--ink-10);
}
.draw-color {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--ink-10);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  background: none;
}
.draw-color:hover { transform: scale(1.15); }
.draw-color.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink-25); }
.draw-size {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--ink-10);
  background: var(--card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.draw-size.active { border-color: var(--teal); background: var(--teal-light); }
.draw-size-dot { border-radius: 50%; background: var(--ink); }
.draw-eraser, .draw-clear {
  padding: 0.3rem 0.6rem;
  border: 1.5px solid var(--ink-10);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-50);
}
.draw-eraser:hover, .draw-clear:hover { border-color: var(--ink-25); }
.draw-eraser.active { border-color: var(--teal); background: var(--teal-light); color: var(--teal); }
.draw-separator { width: 1px; height: 20px; background: var(--ink-10); margin: 0 0.25rem; }
.drawing-saved-image { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--ink-10); }

@media (max-width: 600px) {
  .matching-3col { flex-direction: column; }
  .matching-left-col, .matching-mid-col, .matching-right-col { width: 100%; }
  .matching-right-col { border-left: none; border-top: 2px solid var(--ink-10); padding-top: 0.75rem; }
  .match-words-col { border-left: none; }
}
.matching-item {
  padding: 0.7rem 1.15rem;
  margin: 0.4rem 0;
  border: 2px solid var(--ink-10);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  font-weight: 500;
  font-size: 0.92rem;
  background: var(--card);
}
.matching-item:hover {
  border-color: var(--teal);
  background: var(--teal-light);
  transform: translateY(-1px);
}
.matching-item.selected {
  border-color: var(--teal);
  background: var(--teal-light);
  box-shadow: var(--shadow-glow);
}
.matching-item.matched {
  border-color: var(--sage);
  background: var(--sage-light);
  opacity: 0.75;
  cursor: pointer;
  position: relative;
}
.matching-item.matched::after {
  content: '✕';
  position: absolute;
  top: -6px; right: -6px;
  width: 18px; height: 18px;
  background: var(--coral);
  color: #fff;
  border-radius: 50%;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.matching-item.matched:hover::after {
  opacity: 1;
}

/* Word Order */
.word-groups { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.word-group { flex: 1; min-width: 200px; }
.word-group h4 { font-size: 0.9rem; margin-bottom: 0.5rem; }
.word-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.word-chip {
  padding: 0.45rem 0.9rem;
  background: var(--ocean-light);
  color: var(--ocean);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all var(--transition);
  border: 1.5px solid transparent;
  user-select: none;
}
.word-chip:hover {
  background: var(--ocean);
  color: #fff;
  transform: translateY(-1px);
}
.word-chip.used { opacity: 0.35; text-decoration: line-through; pointer-events: none; }

/* Grammar Table */
.grammar-table { border-radius: var(--radius); overflow: hidden; }
.grammar-table th { background: var(--ink-05); font-size: 0.78rem; }
.grammar-given { color: var(--ink-50); font-style: italic; }
.grammar-example td,
.grammar-example .grammar-given {
  color: var(--ocean) !important;
  font-weight: 600;
  font-style: normal;
}
.grammar-blank {
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
}
.grammar-blank::placeholder {
  color: var(--ink-25);
  font-style: italic;
  font-size: 0.82rem;
}
.grammar-row-label {
  font-weight: 600;
  font-style: italic;
  color: var(--ink-75);
}

/* Audio */
.audio-player-container {
  margin: 1.25rem 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem;
  background: var(--parchment);
  border-radius: var(--radius);
}
.audio-player-container audio { max-width: 320px; height: 40px; }

.audio-recorder { text-align: center; padding: 2.5rem 1rem; }
.record-btn {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 2rem;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(196,68,58,0.3);
  position: relative;
}
.record-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--coral-light);
}
.record-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(196,68,58,0.35);
}
.record-btn.recording { animation: recordPulse 1.5s infinite; }
.record-label { font-size: 0.6rem; font-weight: 600; display: block; margin-top: 2px; }
.audio-playback { margin-top: 1rem; }
.audio-playback audio { width: 100%; max-width: 400px; }


/* ════════════════════════════════════════
   RUBRIC / GRADING
   ════════════════════════════════════════ */

.rubric-section { margin-top: 1.25rem; }

.rubric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.rubric-option {
  border: 2px solid var(--ink-10);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  background: var(--card);
  position: relative;
}
.rubric-option:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.rubric-option.selected {
  border-color: var(--teal);
  background: var(--teal-light);
  box-shadow: var(--shadow-glow);
}
.rubric-option[data-score="4"] { border-left: 4px solid var(--grade-4); }
.rubric-option[data-score="3"] { border-left: 4px solid var(--grade-3); }
.rubric-option[data-score="2"] { border-left: 4px solid var(--grade-2); }
.rubric-option[data-score="1"] { border-left: 4px solid var(--grade-1); }

.rubric-score {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1;
}
.rubric-description {
  font-size: 0.76rem;
  color: var(--ink-50);
  margin-top: 0.35rem;
  line-height: 1.45;
}

.rubric-simple .btn.btn-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}


/* ════════════════════════════════════════
   GRADES & RESULTS
   ════════════════════════════════════════ */

.grade-overview { text-align: center; }

.grade-circle {
  width: 68px; height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
  border: 3px solid rgba(255,255,255,0.8);
}
.grade-circle-lg {
  width: 100px; height: 100px;
  font-size: 2rem;
}

.grade-label {
  font-size: 0.8rem;
  color: var(--ink-50);
  margin-top: 0.4rem;
  font-weight: 600;
}

.result-item { transition: all var(--transition); }
.grade-item { scroll-margin-top: 90px; }

.student-response {
  background: var(--parchment);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin-top: 0.75rem;
  border: 1px solid var(--ink-05);
}
.response-text { font-style: italic; color: var(--ink-75); word-wrap: break-word; overflow-wrap: break-word; }
.response-list { list-style: none; }
.response-list li { padding: 0.3rem 0; font-size: 0.92rem; }

/* Progress Chart */
.simple-chart {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  height: 220px;
  padding: 1.5rem 0 0.5rem;
}
.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.chart-bar {
  width: 100%;
  max-width: 56px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 0.5rem;
  font-weight: 700;
  font-size: 0.82rem;
  min-height: 30px;
  transition: height 0.5s ease;
}
.chart-label {
  font-size: 0.7rem;
  color: var(--ink-50);
  margin-top: 0.5rem;
  text-align: center;
  font-weight: 500;
}

/* Side-by-side layout (preview + grading) */
.preview-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  align-items: start;
}
.preview-student-side { min-width: 0; }
.preview-rubric-side { position: sticky; top: 88px; }
.preview-question-card.hidden,
.preview-rubric-card.hidden,
.grade-question-card.hidden,
.grade-rubric-card.hidden { display: none; }

.preview-answer-placeholder {
  background: var(--parchment);
  border: 1.5px dashed var(--ink-10);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  color: var(--ink-25);
  font-style: italic;
  font-size: 0.9rem;
  min-height: 44px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.preview-answer-placeholder.tall { min-height: 120px; }
.preview-answer-placeholder.inline { display: inline-block; min-width: 100px; min-height: auto; }

/* Bigger text inputs for sub-questions */
.sub-question input.form-control {
  min-height: 44px;
}
.sub-question input.answer-sub {
  font-size: 0.95rem;
}
/* For long-answer text_multi questions, use textarea-like display */
.sub-question label + .preview-answer-placeholder:not(.inline) {
  min-height: 60px;
}

.rubric-preview-stack { display: flex; flex-direction: column; gap: 0.5rem; }
.rubric-preview-item,
.rubric-grade-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  background: var(--paper);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 0.25rem;
}
.rubric-preview-item { cursor: default; }
.rubric-grade-item:hover {
  background: var(--parchment);
  transform: translateX(2px);
}
.rubric-grade-item.selected {
  background: var(--teal-light);
  border-right: 3px solid var(--teal);
  box-shadow: var(--shadow-sm);
}
.rubric-preview-item.score-4, .rubric-grade-item.score-4 { border-left-color: var(--grade-4); }
.rubric-preview-item.score-3, .rubric-grade-item.score-3 { border-left-color: var(--grade-3); }
.rubric-preview-item.score-2, .rubric-grade-item.score-2 { border-left-color: var(--grade-2); }
.rubric-preview-item.score-1, .rubric-grade-item.score-1 { border-left-color: var(--grade-1); }
.rubric-preview-score {
  font-family: var(--font-display);
  font-size: 1.3rem;
  line-height: 1;
  min-width: 24px;
  flex-shrink: 0;
}
.rubric-preview-text { font-size: 0.82rem; color: var(--ink-75); line-height: 1.45; }

.preview-header { border-bottom: 2px solid var(--ink-05); padding-bottom: 1rem; }

/* Grade dots */
.grade-dots { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.grade-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--ink-10);
  background: var(--card);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-50);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.grade-dot:hover { border-color: var(--teal); color: var(--teal); }
.grade-dot.active { border-color: var(--teal); background: var(--teal); color: #fff; }
.grade-dot.graded { border-color: var(--grade-4); background: var(--grade-4-bg); color: var(--grade-4); }
.grade-dot.graded.active { background: var(--teal); color: #fff; border-color: var(--teal); }

.grade-header { border-bottom: 2px solid var(--ink-05); padding-bottom: 1rem; }

.response-item {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--ink-05);
  display: flex;
  gap: 0.5rem;
  font-size: 0.92rem;
  min-width: 0;
  overflow-wrap: break-word;
}
.response-item:last-child { border-bottom: none; }
.response-label { color: var(--ink-50); min-width: 40%; flex-shrink: 0; }
.response-value { font-weight: 500; word-wrap: break-word; overflow-wrap: break-word; min-width: 0; }
.student-response { overflow-wrap: break-word; word-wrap: break-word; overflow: hidden; }

.results-header {
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--ink-05);
  margin-bottom: 1.5rem;
}


/* ════════════════════════════════════════
   MARKMID LIST
   ════════════════════════════════════════ */

.markmid-list {
  padding-left: 1.5rem;
  font-size: 0.9rem;
  color: var(--ink-75);
}
.markmid-list li {
  margin-bottom: 0.35rem;
  line-height: 1.6;
}
.markmid-list li::marker {
  color: var(--teal);
}


/* ════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════ */

.site-footer {
  text-align: center;
  padding: 2.5rem 1.5rem;
  margin-top: 4rem;
  border-top: 1px solid var(--ink-10);
  color: var(--ink-25);
  font-size: 0.82rem;
  font-weight: 500;
}


/* ════════════════════════════════════════
   UTILITIES
   ════════════════════════════════════════ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--ink-50); }
.text-success{ color: var(--sage); }
.text-danger { color: var(--coral); }

.mt-1 { margin-top: 0.35rem; }
.mt-2 { margin-top: 0.85rem; }
.mt-3 { margin-top: 1.75rem; }
.mt-4 { margin-top: 3rem; }
.mb-2 { margin-bottom: 0.85rem; }
.mb-3 { margin-bottom: 1.75rem; }


/* ════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════ */

@keyframes questionSlideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes recordPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(196,68,58,0.35);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 14px rgba(196,68,58,0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}


/* ════════════════════════════════════════
   PRINT
   ════════════════════════════════════════ */

@media print {
  body { padding-top: 0; background: #fff; }
  body::before { display: none; }
  .main-nav, .nav-buttons, .btn, .site-footer,
  .save-indicator, .audio-recorder { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .container { max-width: 100%; padding: 0; }
  .grade-circle { border: 2px solid #999; }
}


/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */

@media (max-width: 768px) {
  body { padding-top: 64px; }

  .nav-inner { height: 64px; padding: 0 1rem; gap: 1rem; }
  .nav-brand { font-size: 1.4rem; }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 64px; left: 0; right: 0;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--ink-10);
    padding: 0.75rem;
    box-shadow: var(--shadow-md);
  }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
  .nav-user { margin-left: auto; }
  .nav-username { display: none; }

  .container { padding: 1.25rem; }
  h1 { font-size: 1.6rem; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

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

  .rubric-grid { grid-template-columns: repeat(2, 1fr); }
  .image-label-grid { grid-template-columns: repeat(2, 1fr); }
  .matching-container { flex-direction: column; gap: 1rem; }
  .preview-layout { grid-template-columns: 1fr; }
  .preview-rubric-side { position: static; }

  .card-body { padding: 1.25rem; }
  .card-header { padding: 1rem 1.25rem; }
}

@media (max-width: 480px) {
  .container { padding: 1rem; }
  h1 { font-size: 1.35rem; }
  .stat-number { font-size: 2rem; }

  .rubric-grid { grid-template-columns: 1fr; }
  .image-label-grid { grid-template-columns: 1fr; }

  .login-card { padding: 2rem 1.75rem; }
  .login-logo { font-size: 2.5rem; }

  .btn-group { flex-direction: column; }
}
