/* Korrektorat editor — minimal styling, no framework. */

:root {
  --primary: #02437b;
  --primary-on: #ffffff;
  --primary-tint: #eaf1f8;
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #d8d8d8;
  --border-strong: #b0b0b0;
  --text: #1a1a1a;
  --text-muted: #666;
  --error: #c0392b;
  --warning: #d97706;
  --success: #16a34a;
  --modified: #f59e0b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button {
  font: inherit;
  cursor: pointer;
}

button.primary {
  background: var(--primary);
  color: var(--primary-on);
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  font-weight: 500;
}
button.primary:hover { filter: brightness(1.1); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border-strong);
  padding: 0.5rem 1rem;
  border-radius: 6px;
}
button.secondary:hover { background: var(--primary-tint); }

input[type="password"], input[type="text"], textarea {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
input:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
textarea {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 13.5px;
  line-height: 1.55;
  resize: vertical;
  min-height: 4.5rem;
}
textarea.html { font-size: 12.5px; }

/* === Layout === */
.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.shell.editor {
  max-width: none;
  padding: 0;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* === Login === */
.login {
  max-width: 420px;
  margin: 6rem auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.login h1 { margin: 0 0 0.5rem 0; font-size: 1.4rem; }
.login p { color: var(--text-muted); margin: 0 0 1.5rem 0; }
.login form { display: flex; flex-direction: column; gap: 1rem; }
.login .error { color: var(--error); font-size: 0.9rem; }

/* === Module list === */
.module-list h1 { margin: 0 0 0.3rem 0; }
.module-list .lead { color: var(--text-muted); margin: 0 0 2rem 0; }
.module-list .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.module-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.module-card:hover {
  border-color: var(--primary);
  box-shadow: 0 1px 4px rgba(2, 67, 123, 0.1);
}
.module-card .title {
  font-weight: 600;
  margin: 0 0 0.4rem 0;
  font-size: 1rem;
}
.module-card .desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0 0 0.8rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.module-card .meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.module-card.dirty {
  border-color: var(--modified);
  background: #fffaf0;
}
.module-card .draft-badge {
  display: inline-block;
  background: var(--modified);
  color: white;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.4rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.topbar .right { display: flex; gap: 0.5rem; align-items: center; }

/* === Editor === */
.sidebar {
  background: #f0f3f6;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.2rem 1rem;
  font-size: 0.9rem;
}
.sidebar h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 1.2rem 0 0.4rem 0;
}
.sidebar h2:first-child { margin-top: 0; }
.sidebar a.back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li a {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}
.sidebar li a:hover { background: var(--primary-tint); }
.sidebar li a .count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sidebar li a .changes {
  color: var(--modified);
  font-weight: 600;
}

.main {
  padding: 1.5rem 2rem 6rem 2rem;
  max-width: 920px;
}
.main header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  gap: 1rem;
}
.main header h1 { margin: 0; font-size: 1.4rem; }
.main header .lead { color: var(--text-muted); margin: 0.4rem 0 1.5rem 0; }
.main header .actions { display: flex; gap: 0.5rem; align-items: center; flex-shrink: 0; }
.main header .changes-badge {
  background: var(--modified);
  color: white;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-right: 0.5rem;
}

.section {
  border-top: 2px solid var(--border);
  margin-top: 2rem;
  padding-top: 1rem;
}
.section:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.section h2 {
  font-size: 1rem;
  margin: 0 0 0.8rem 0;
  color: var(--primary);
}
.section .section-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  font-weight: normal;
}

.field {
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  position: relative;
}
.field.modified {
  border-color: var(--modified);
  background: #fffdf6;
}
.field.modified::before {
  content: '';
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 4px;
  background: var(--modified);
  border-radius: 6px 0 0 6px;
}
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
  gap: 0.5rem;
}
.field-label .label {
  font-weight: 500;
  font-size: 0.9rem;
}
.field-label .path {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  word-break: break-all;
  text-align: right;
}
.field-label .kind-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.05rem 0.45rem;
  border-radius: 3px;
  background: #e7eef5;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-right: 0.4rem;
}
.field-label .kind-badge.html { background: #fef0e6; color: #c2410c; }
.field-label .kind-badge.markdown { background: #ecfdf5; color: #047857; }
.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}
.field-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.4rem;
  gap: 1rem;
}
.reset-link {
  font-size: 0.78rem;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.reset-link:hover { text-decoration: underline; }

.field.has-original {
  border-left: 4px solid var(--success);
}
.field.has-original.modified {
  border-left: 4px solid var(--modified);
}
.kind-badge.saved {
  background: #ecfdf5;
  color: var(--success);
  margin-left: 0.4rem;
}

.original-block {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}
.original-block summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.original-block pre {
  margin: 0.4rem 0 0 0;
  padding: 0.6rem 0.8rem;
  background: #f4f6f8;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.78rem;
  color: #334;
}

.module-card .saved-badge {
  display: inline-block;
  background: var(--success);
  color: white;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.4rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text);
  padding: 0.8rem 1.2rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  font-size: 0.9rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast a { color: var(--primary); }

.skipped-list {
  margin: 0.8rem 0 0 0;
  padding: 0.6rem 0.8rem;
  background: #fff7ed;
  border: 1px solid var(--warning);
  border-radius: 4px;
  font-size: 0.8rem;
}
.skipped-list summary { cursor: pointer; font-weight: 500; color: var(--warning); }
.skipped-list ul { margin: 0.4rem 0 0 1rem; padding: 0; }

/* =====================================================================
   AHV round (30.10.2026): overview groups, nested sections, checked
   state, hints, local banner. Overrides above where noted.
   ===================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* Prose is proofread here: readable proportional font instead of monospace. */
.field-input, textarea.field-input {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.local-banner {
  background: #fff7ed;
  border: 1px solid var(--warning);
  color: #7c2d12;
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.button-link {
  display: inline-block;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--primary);
  background: var(--surface);
  font-size: 0.9rem;
  white-space: nowrap;
}
.button-link:hover { background: var(--primary-tint); }
.login-help { margin-top: 1.5rem !important; font-size: 0.85rem; }
.login-help a { color: var(--primary); }
.error-detail { background: #f0f0f0; padding: 1rem; border-radius: 4px; white-space: pre-wrap; font-size: 0.85rem; }

/* Overview */
.doc-group { margin-top: 2rem; }
.doc-group h2 { font-size: 1.15rem; margin: 0 0 0.2rem 0; color: var(--primary); }
.doc-group .lead { color: var(--text-muted); margin: 0 0 1rem 0; font-size: 0.9rem; }
.topbar .lead { color: var(--text-muted); margin: 0.3rem 0 0 0; }
.topbar h1 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.grid.compact { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid.compact .module-card { padding: 0.8rem 1rem; }
.module-card.done { border-color: var(--success); }
.module-card.done .title::before { content: '✓ '; color: var(--success); }
.module-card .meta { margin: 0.4rem 0 0 0; }
.progress { height: 6px; background: #e8ecf0; border-radius: 999px; overflow: hidden; }
.progress.big { height: 8px; margin: 0 0 0.5rem 0; }
.progress-bar { height: 100%; background: var(--success); border-radius: 999px; transition: width 0.2s; }

/* Editor sidebar */
.shell.editor { grid-template-columns: 300px 1fr; }
.sidebar .doc-title { font-weight: 600; margin: 0 0 0.2rem 0; color: var(--text); }
.sidebar .doc-progress { color: var(--text-muted); font-size: 0.8rem; margin: 0 0 0.8rem 0; }
.sidebar .search { width: 100%; padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.sidebar li a { align-items: baseline; gap: 0.35rem; }
.sidebar li a .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar li a .tick { color: transparent; width: 0.9em; flex-shrink: 0; }
.sidebar li a.checked .tick { color: var(--success); }
.sidebar li a.checked .name { color: var(--text-muted); }
.sidebar li a .changes:empty { display: none; }
.sidebar li.depth-1 a { padding-left: 1.2rem; }
.sidebar li.depth-2 a { padding-left: 2rem; font-size: 0.82rem; }
.sidebar li.depth-3 a { padding-left: 2.8rem; font-size: 0.8rem; }

/* Editor sections */
.section.depth-1 { margin-left: 0.8rem; }
.section.depth-2 { margin-left: 1.6rem; }
.section.depth-3 { margin-left: 2.4rem; }
.section .trail { margin: 0 0 0.2rem 0; font-size: 0.78rem; color: var(--text-muted); }
.section .where {
  margin: -0.4rem 0 0.8rem 0;
  font-size: 0.8rem;
  color: var(--primary);
  background: var(--primary-tint);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  display: inline-block;
}
.section.checked > h2::after { content: ' ✓'; color: var(--success); }
.section-foot { display: flex; justify-content: flex-end; margin-top: -0.2rem; }
.section.checked .check-btn { border-color: var(--success); color: var(--success); background: #f0fdf4; }
.doc-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1rem; border-top: 2px solid var(--border); }
.doc-nav a { color: var(--primary); text-decoration: none; font-weight: 500; }

/* Fields */
.field-label .context { color: var(--text-muted); font-size: 0.8rem; margin-left: 0.5rem; }
.field-label .kind-badge { margin-right: 0; margin-left: 0.4rem; text-transform: none; letter-spacing: 0; }
.field-note {
  margin: 0 0 0.4rem 0;
  font-size: 0.8rem;
  color: #7c2d12;
  background: #fff7ed;
  border-left: 3px solid var(--warning);
  padding: 0.25rem 0.5rem;
  border-radius: 0 4px 4px 0;
}
.field .bad-msg { display: none; color: var(--error); font-size: 0.8rem; }
.field.bad { border-color: var(--error); background: #fef2f2; }
.field.bad .bad-msg { display: inline; }
.field-foot:empty { display: none; }
.field-foot { justify-content: space-between; }

@media (max-width: 760px) {
  .shell.editor { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
  .main { padding: 1rem 1rem 5rem 1rem; }
  .main header { flex-direction: column; }
  .section.depth-1, .section.depth-2, .section.depth-3 { margin-left: 0; }
}
.doc-group h2 .section-meta { font-size: 0.85rem; color: var(--text-muted); margin-left: 0.6rem; font-weight: normal; }
