:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: #d8d4cc;
  --accent: #3b6ea5;
  --accent-hover: #2d5687;
  --accent-light: #e8f0f9;
  --danger: #c0392b;
  --danger-light: #fdecea;
  --success: #27ae60;
  --success-light: #eafaf1;
  --warn: #e67e22;
  --warn-light: #fef5e7;
  --text: #1a1a1a;
  --text-muted: #666;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.changelog-link {
  margin-left: auto;
  font-size: .8rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: .85rem 0;
  white-space: nowrap;
}
.changelog-link:hover { color: var(--accent); }

.app-footer {
  text-align: center;
  padding: 1.25rem 1rem 2rem;
  font-size: .8rem;
  color: var(--text-muted);
}
.app-footer a { color: var(--text-muted); text-decoration: underline; }
.app-footer a:hover { color: var(--accent); }

.site-announcement {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--accent);
  color: #fff;
  padding: .6rem 1.25rem;
  font-size: .88rem;
  text-align: center;
}
.site-announcement a { color: #fff; font-weight: 600; }
.site-announcement-close {
  background: none;
  border: none;
  color: #fff;
  opacity: .8;
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
  flex-shrink: 0;
}
.site-announcement-close:hover { opacity: 1; }

header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  padding: 1rem 0;
}

nav#tabs {
  display: flex;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  padding: .85rem 1.25rem;
  font-size: .9rem;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.tab-btn:hover:not(:disabled) { color: var(--accent); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-btn:disabled { opacity: .4; cursor: not-allowed; }

main { max-width: 900px; margin: 0 auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

.tab-content { display: none; flex-direction: column; gap: 1rem; }
.tab-content.active { display: flex; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card h2 .hint {
  font-weight: 400;
  font-size: .8rem;
  color: var(--text-muted);
}

label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.label-hint {
  font-size: .78rem;
  font-weight: 400;
  color: var(--text-muted);
  opacity: .7;
  margin-top: -.15rem;
}

textarea, input[type="text"], input[type="email"], input[type="password"], select {
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .9rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s;
  width: 100%;
}


textarea:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

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

.lang-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}
.lang-row label { flex: 1; }
.lang-row .arrow { font-size: 1.3rem; padding-bottom: .4rem; color: var(--text-muted); }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.upload-zone.drag-over { border-color: var(--accent); background: var(--accent-light); }

.upload-zone button {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .75rem;
  cursor: pointer;
  font-size: .85rem;
  color: var(--accent);
}
.upload-zone button:disabled { opacity: .4; cursor: not-allowed; }

.upload-label-row {
  font-size: .9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.upload-count {
  font-size: .8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.image-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  width: 100%;
  justify-content: center;
}

.thumb-item {
  position: relative;
  width: 80px;
  height: 60px;
  flex-shrink: 0;
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.thumb-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: .6rem;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.thumb-remove:hover { background: #a93226; }

.thumb-pdf {
  width: 100%;
  height: 100%;
  background: var(--danger-light);
  border: 1px solid #f5c6c0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--danger);
}

.exercise-options {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1.5rem;
  padding: .65rem 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .88rem;
  align-items: center;
}

.exercise-option-group {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}

.option-label {
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: .1rem;
}

.option-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .3rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}
.option-check input[type="checkbox"] { cursor: pointer; width: auto; }

.option-select {
  font-size: .85rem;
  padding: .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  width: auto;
}

.notes-guide {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
}

.notes-guide summary {
  padding: .55rem .85rem;
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  list-style: none;
}
.notes-guide summary::-webkit-details-marker { display: none; }
.notes-guide summary::before { content: '▸ '; font-size: .75rem; }
details.notes-guide[open] summary::before { content: '▾ '; }

.notes-guide-body {
  padding: .6rem .85rem .75rem;
  border-top: 1px solid var(--border);
}

.guide-table { font-size: .85rem; border-collapse: collapse; width: 100%; }
.guide-table td { padding: .25rem .6rem .25rem 0; vertical-align: top; }
.guide-table td:first-child { white-space: nowrap; }
.guide-table td code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .1rem .35rem;
  font-size: .82rem;
  font-family: "Fira Code", "Consolas", monospace;
}
.guide-ex { color: var(--text-muted); font-style: italic; }

.actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.import-hint {
  font-size: .82rem;
  color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .65rem 1.4rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: .6rem 1.2rem;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--accent-light); }

.btn-small {
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: .35rem .8rem;
  font-size: .85rem;
  cursor: pointer;
  color: var(--text-muted);
  align-self: flex-start;
}
.btn-small:hover { border-color: var(--accent); color: var(--accent); }

.loader {
  align-items: center;
  gap: .75rem;
  color: var(--text-muted);
  font-size: .9rem;
}

.loader:not([hidden]) {
  display: flex;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  background: var(--danger-light);
  border: 1px solid #f5c6c0;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  color: var(--danger);
  font-size: .9rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.error-box a { color: inherit; font-weight: 600; }

.ambiguities-card {
  background: var(--warn-light);
  border-color: #f0c080;
}
.ambiguities-card h2 { color: var(--warn); }
.ambiguities-card li { margin-left: 1.25rem; }

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

th {
  text-align: left;
  padding: .5rem .7rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

td {
  padding: .4rem .7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

td[contenteditable="true"] {
  outline: none;
  cursor: text;
}
td[contenteditable="true"]:focus {
  background: var(--accent-light);
  box-shadow: inset 0 0 0 1px var(--accent);
  border-radius: 3px;
}

.del-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .9rem;
  padding: .2rem .4rem;
  border-radius: 4px;
}
.del-btn:hover { color: var(--danger); background: var(--danger-light); }

select.pos-select {
  font-size: .85rem;
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  width: 100%;
}

/* Output tabs */
.output-tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.out-tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: .75rem 1rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  transition: background .15s, color .15s;
}
.out-tab-btn:last-child { border-right: none; }
.out-tab-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.out-tab-btn:hover:not(.active) { background: var(--bg); color: var(--accent); }

.mode-tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: .75rem 1rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  transition: background .15s, color .15s;
}
.mode-tab-btn:last-child { border-right: none; }
.mode-tab-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.mode-tab-btn:hover:not(.active) { background: var(--bg); color: var(--accent); }

.out-content { display: none; }
.out-content.active { display: flex; }

/* Markdown preview */
.markdown-preview {
  font-size: .95rem;
  line-height: 1.7;
}
.markdown-preview h1 { font-size: 1.3rem; margin-bottom: .75rem; }
.markdown-preview h2 { font-size: 1.05rem; margin: 1rem 0 .4rem; color: var(--accent); }
.markdown-preview table { margin: .5rem 0 1rem; font-size: .85rem; }
.markdown-preview th, .markdown-preview td { padding: .35rem .7rem; border: 1px solid var(--border); }
.markdown-preview th { background: var(--bg); }
.markdown-preview ul { margin-left: 1.25rem; }
.markdown-preview li { margin-bottom: .2rem; }

/* CSV preview */
#csv-preview {
  font-family: "Fira Code", "Consolas", monospace;
  font-size: .82rem;
  background: var(--bg);
  border-radius: 6px;
  padding: .75rem 1rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

/* Hints toggle */
.hint-toggle-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .35rem;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
}
.hint-toggle-label input[type="checkbox"] { cursor: pointer; width: auto; }
#exercises-widget.hints-hidden .q-hint { display: none; }

/* Exercises widget */
#exercises-widget { display: flex; flex-direction: column; gap: 1.25rem; }

.question-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  background: var(--bg);
}
.q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .4rem;
}
.question-card .q-tag {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .06em;
}
.q-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .85rem;
  padding: .1rem .3rem;
  border-radius: 4px;
  line-height: 1;
}
.q-delete:hover { color: var(--danger); background: var(--danger-light); }
.question-card .q-prompt { font-weight: 600; margin-bottom: .75rem; }
.question-card .q-hint { font-size: .82rem; color: var(--text-muted); margin-bottom: .5rem; font-style: italic; }

/* MCQ */
.mcq-options { display: flex; flex-direction: column; gap: .5rem; }
.mcq-btn {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem 1rem;
  cursor: pointer;
  font-size: .9rem;
  transition: background .12s, border-color .12s;
}
.mcq-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-light); }
.mcq-btn.correct { background: var(--success-light); border-color: var(--success); color: var(--success); }
.mcq-btn.wrong { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }

/* Fill */
.fill-form { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.open-answer-form { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.open-answer-form .fill-input { width: 100%; }
.fill-input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .8rem;
  font-size: .9rem;
  min-width: 180px;
  flex: 1;
}
.fill-input.correct { border-color: var(--success); background: var(--success-light); }
.fill-input.wrong { border-color: var(--danger); background: var(--danger-light); }
.fill-submit { padding: .55rem 1rem; }

/* Match */
.match-columns { display: flex; gap: 1rem; }
.match-col { flex: 1; display: flex; flex-direction: column; gap: .4rem; }
.match-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .85rem;
  cursor: pointer;
  font-size: .9rem;
  background: var(--surface);
  transition: background .12s, border-color .12s;
  text-align: center;
  user-select: none;
}
.match-item:hover:not(.locked):not(:disabled) { border-color: var(--accent); background: var(--accent-light); }
.match-item.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.match-item.locked { cursor: default; background: var(--success-light); border-color: var(--success); color: var(--success); }
.match-item.shake { animation: shake .35s; border-color: var(--danger); background: var(--danger-light); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.opt-level-saved { font-size: .78rem; color: var(--text-muted); margin-left: .3rem; visibility: hidden; }

/* Passage */
.q-passage { display: flex; flex-direction: column; gap: .75rem; }
.passage-word-bank { display: flex; flex-wrap: wrap; gap: .4rem; }
.word-bank-chip {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: .2rem .7rem;
  font-size: .8rem;
}
.q-passage-text { line-height: 1.9; white-space: pre-wrap; }
input[type="text"].passage-blank-input {
  display: inline-block;
  width: auto;
  min-width: 0;
  margin: 0 .2rem;
  padding: .15rem .4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .9rem;
  font-family: inherit;
  text-align: center;
}
input[type="text"].passage-blank-input.correct { border-color: var(--success); background: var(--success-light); }
input[type="text"].passage-blank-input.wrong { border-color: var(--danger); background: var(--danger-light); }

/* Feedback text after answer */
.q-why {
  margin-top: .6rem;
  font-size: .85rem;
  color: var(--text-muted);
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: .4rem .75rem;
  border-radius: 0 4px 4px 0;
  display: none;
}
.q-why.visible { display: block; }

/* Exercises editor */
#exercises-mode-toggle { margin-bottom: 1rem; max-width: 260px; }
#exercises-editor { display: flex; flex-direction: column; gap: 1.25rem; }
.edit-field-row { display: flex; gap: .4rem; align-items: baseline; margin-bottom: .5rem; font-size: .82rem; }
.edit-field-label { color: var(--text-muted); flex-shrink: 0; }
.edit-field-value { flex: 1; font-style: italic; }
.edit-option-row { display: flex; gap: .5rem; align-items: center; }
.edit-option-row .mcq-btn, .edit-option-row .edit-cell { flex: 1; }
.edit-cell {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .85rem;
  font-size: .9rem;
  background: var(--surface);
}
.edit-pairs { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .5rem; }
.q-passage-text-edit {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  min-height: 5rem;
  white-space: pre-wrap;
  margin-bottom: .5rem;
}
.edit-field-caption { font-size: .78rem; color: var(--text-muted); margin-bottom: .5rem; }
.edit-answer-mark {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1;
}
.edit-answer-mark.active { border-color: var(--success); color: var(--success); background: var(--success-light); }

/* Progress */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.progress-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }

.score-box {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

/* ── Auth area (header) ───────────────────────────────────────────────────── */
.auth-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}

.auth-area + .changelog-link {
  margin-left: 0;
}

.auth-user-email {
  font-size: .82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.btn-sm {
  padding: .35rem .85rem;
  font-size: .82rem;
}

/* ── Share link area ─────────────────────────────────────────────────────── */
.share-link-area {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  padding: .6rem 1rem;
  background: var(--accent-light);
  border: 1px solid #b8d0ee;
  border-radius: var(--radius);
  font-size: .88rem;
  margin-top: .25rem;
}

.share-link-label {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.share-link-area a {
  color: var(--accent);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}

.dashboard-hero {
  display: flex;
  justify-content: center;
  margin: 1rem 0 1.5rem;
}

.dashboard-hero .btn-primary {
  font-size: 1.05rem;
  padding: .75rem 1.75rem;
}

.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem 2rem;
  width: 100%;
}

.dashboard-card .modal-tabs {
  margin: -1.75rem -2rem 1.5rem;
  padding: 0 1.25rem;
  gap: .25rem;
}

.dashboard-card .modal-tab {
  font-size: 1.05rem;
  font-weight: 500;
  padding: 1.1rem 1rem;
  border-bottom-width: 3px;
}

.dashboard-card .modal-tab.active { font-weight: 700; }

.sessions-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.sessions-loading, .sessions-empty {
  font-size: .88rem;
  color: var(--text-muted);
}

.session-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: .6rem;
}

.session-row-main {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.25rem;
  background: var(--surface);
  flex-wrap: wrap;
}

.session-title-text {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-date {
  font-size: .85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.session-slug {
  font-size: .82rem;
  color: var(--accent);
  font-family: monospace;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-count {
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
}

.session-row-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafaf8;
}

.session-submissions {
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafaf8;
}

.draft-preview {
  padding: .5rem 1rem .65rem;
  border-top: 1px solid var(--border);
  background: #fafaf8;
  font-size: .82rem;
  color: var(--text-muted);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.results-table th {
  text-align: left;
  font-weight: 700;
  padding: .35rem .6rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.results-table td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border);
}

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

.answers-modal-card {
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
}

.answers-modal-meta {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: -.75rem;
}

.answer-review-block {
  margin-top: .6rem;
  padding-top: .6rem;
  border-top: 1px solid var(--border);
}

.answer-review-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .3rem;
}

.answer-review-text {
  font-size: .92rem;
  white-space: pre-wrap;
  padding: .5rem .7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.answer-review-text.correct { border-color: var(--success); background: var(--success-light); }
.answer-review-text.wrong { border-color: var(--danger); background: var(--danger-light); }

/* ── Auth modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 2.25rem 2.5rem;
  width: 100%;
  max-width: 460px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-close {
  position: absolute;
  top: .85rem;
  right: .85rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: .2rem .4rem;
  border-radius: 4px;
  line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: -.25rem -2rem 0;
  padding: 0 2rem;
}

.modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: .6rem 1rem;
  font-size: .9rem;
  cursor: pointer;
  color: var(--text-muted);
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.modal-tab:hover:not(.active) { color: var(--text); }

/* Auth forms */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.auth-form-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.auth-form-desc {
  font-size: .9rem;
  color: var(--text-muted);
  margin-top: -.25rem;
}

.auth-form .btn-primary { margin-top: .25rem; }

.auth-form-hint {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: .5rem;
  text-align: center;
}

.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: .85rem;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent-hover); }

.success-box {
  background: var(--success-light);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: .65rem 1rem;
  color: var(--success);
  font-size: .9rem;
}

/* ── Email verification gate ─────────────────────────────────────────────── */
.verify-pending {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem 1.5rem;
}

.verify-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  max-width: 440px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}

.verify-card h2 { font-size: 1.15rem; }
.verify-card p { font-size: .93rem; color: var(--text-muted); line-height: 1.6; }
.verify-spam-hint { font-style: italic; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: .65rem 1.25rem;
  border-radius: var(--radius);
  font-size: .9rem;
  z-index: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  pointer-events: none;
  white-space: nowrap;
}
.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--success); }
.toast[hidden] { display: none; }

/* ── Student select (input tab) ─────────────────────────────────────────── */
.student-select-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-top: .25rem;
}

.student-select-label {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

#student-select { width: auto; min-width: 160px; }

.add-student-link {
  font-size: .82rem;
  color: var(--accent);
  white-space: nowrap;
}

.quick-add-student {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: .4rem;
  flex-wrap: wrap;
}

.quick-student-name-input {
  flex: 1;
  min-width: 140px;
  max-width: 240px;
  padding: .4rem .7rem;
  font-size: .88rem;
}

.quick-student-error {
  font-size: .8rem;
  color: #c0392b;
}

/* ── Notes label row ─────────────────────────────────────────────────────── */
.notes-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .65rem;
}
.notes-label-row .btn-link {
  font-size: .82rem;
  white-space: nowrap;
}
.notes-label-group {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .5rem;
}
.draft-status {
  font-size: .78rem;
  color: var(--text-muted);
}
.draft-status.saving { color: var(--accent); }
.draft-status.error { color: var(--danger); }

/* ── Inline notes hint ───────────────────────────────────────────────────── */
.notes-inline-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .3rem;
}
.notes-inline-hint code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 .3rem;
  font-size: .8rem;
  color: var(--text);
}

/* ── User menu dropdown ──────────────────────────────────────────────────── */
.user-menu-wrap {
  position: relative;
}

.user-menu-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .35rem .75rem;
  font-size: .82rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color .15s, color .15s;
}
.user-menu-btn:hover { border-color: var(--accent); color: var(--accent); }

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 140px;
  z-index: 200;
  overflow: hidden;
}

.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: .6rem 1rem;
  font-size: .88rem;
  cursor: pointer;
  color: var(--text);
  transition: background .12s;
}
.user-menu-item:hover { background: var(--bg); color: var(--accent); }

/* ── Library modal ───────────────────────────────────────────────────────── */
.lib-tab-content {
  margin-top: 1.25rem;
  max-height: 60vh;
  overflow-y: auto;
}

.session-student-sel {
  font-size: .8rem;
  padding: .2rem .4rem;
  max-width: 160px;
}

.session-student-tag {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex: 1;
}

.session-student-name {
  font-size: .8rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.session-student-name:hover { text-decoration: underline; }

.session-assign-btn {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
}
.btn-link:hover { color: var(--accent); text-decoration: underline; }

.title-edit-input {
  font: inherit;
  padding: .1rem .35rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  min-width: 10rem;
}

.session-assign-wrap {
  padding: .35rem .5rem .2rem;
  border-top: 1px solid var(--border);
}

/* ── Student list / summary ──────────────────────────────────────────────── */
.student-add-row {
  margin-bottom: 1rem;
}

.student-add-fields {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .35rem;
}

.student-lang-sel {
  width: auto;
  min-width: unset;
  padding-right: 1.4rem;
}

.student-name-input {
  flex: 1;
  min-width: 140px;
}

.lang-badge {
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #555;
  background: #e8f0f9;
  border-radius: 4px;
  padding: .1rem .4rem;
}

.share-kind-badge {
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-radius: 4px;
  padding: .1rem .4rem;
  white-space: nowrap;
}

.share-kind-exercises { color: var(--accent); background: var(--accent-light); }
.share-kind-recap { color: var(--warn); background: var(--warn-light); }
.share-kind-progress { color: var(--success); background: var(--success-light); }

.share-about-text {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.student-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: .6rem;
}

.student-item-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.25rem;
  background: var(--surface);
}

.student-name {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
}

.student-name-link {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  color: #3b6ea5;
  text-decoration: none;
}
.student-name-link:hover { text-decoration: underline; }

.student-lang-hint { font-size: .8rem; color: var(--text-muted); margin-top: -.25rem; }
.student-lang-hint a { color: var(--accent); }
.option-hint { font-size: .8rem; color: var(--text-muted); flex-basis: 100%; margin-top: -.15rem; }

.student-reminder-banner {
  font-size: .88rem;
  line-height: 1.5;
  color: var(--text);
  background: #f5f4f0;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: .6rem .9rem;
  margin: .5rem 0;
}

select:disabled {
  background: #f0eeea;
  color: #999;
  border-color: #ddd;
  cursor: not-allowed;
}

/* ── Session notes ───────────────────────────────────────────────────────── */

.session-summary-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .4rem;
}

.session-summary-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  font-size: .88rem;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
}
.session-summary-input:focus {
  outline: none;
  border-color: var(--accent);
}

.teacher-prompt-input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .8rem;
  font-size: .88rem;
  font-family: inherit;
  flex: 1;
  min-width: 160px;
  max-width: 280px;
  background: var(--bg);
  color: var(--text);
}
.teacher-prompt-input:focus {
  outline: none;
  border-color: var(--accent);
}

@media (max-width: 600px) {
  header { gap: .5rem 1rem; padding: .6rem 1rem; flex-wrap: wrap; }
  header h1 { font-size: 1rem; padding: .4rem 0; }
  .auth-area { margin-left: 0; }
  .changelog-link { margin-left: 0; padding: .4rem 0; }
  .user-menu-btn { max-width: 130px; }
  nav#tabs { flex-wrap: wrap; }
  .tab-btn { padding: .75rem .6rem; font-size: .8rem; }
  .lang-row { flex-direction: column; }
  .lang-row .arrow { display: none; }
  .match-columns { flex-direction: column; }
  .auth-user-email { display: none; }

  main { padding: 1rem; }
  .card { padding: 1rem 1.1rem; }

  .dashboard-card { padding: 1.1rem 1rem; }
  .dashboard-card .modal-tabs { margin: -1.1rem -1rem 1.25rem; padding: 0 .5rem; }
  .dashboard-card .modal-tab { font-size: .92rem; padding: .8rem .5rem; }
}
