:root {
  color-scheme: light;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Times New Roman", Times, Georgia, serif;
  
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  
  --canvas: #f8fafc;
  --paper: #ffffff;
  --card-bg: #ffffff;
  --card-subtle: #f8fafc;
  
  --line: #e2e8f0;
  --line-dark: #cbd5e1;
  --line-focus: #3b82f6;
  
  --blue: #1d4ed8;
  --blue-hover: #1e40af;
  --blue-dark: #1e3a8a;
  --blue-soft: #eff6ff;
  --blue-border: #bfdbfe;
  
  --navy: #0f172a;
  --navy-hover: #1e293b;
  
  --success: #059669;
  --success-soft: #ecfdf5;
  --success-border: #a7f3d0;
  --success-dark: #065f46;
  
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;
  --amber-dark: #92400e;
  
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
  --shadow-sticky: 0 10px 30px -5px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; }
button, a, label.file-button { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
textarea {
  field-sizing: content;
  min-height: 78px;
  resize: vertical;
}

.app-shell {
  width: min(1740px, 100%);
  margin: auto;
  padding: 24px 28px 70px;
}

/* =========================================================
   INTRO & HEADER BANNER
   ========================================================= */
.intro {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: center;
  margin: 0 auto 20px;
}
.intro > div:first-child { max-width: 860px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid var(--blue-border);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

h1 {
  max-width: 820px;
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(28px, 3.5vw, 42px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.intro-copy {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.privacy-note {
  display: flex;
  gap: 12px;
  width: min(380px, 100%);
  border: 1px solid var(--success-border);
  border-radius: 14px;
  background: var(--success-soft);
  padding: 14px 16px;
  color: var(--success-dark);
  box-shadow: var(--shadow-xs);
}
.privacy-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 9999px;
  background: #d1fae5;
  color: var(--success);
  font-weight: 900;
  font-size: 13px;
}
.privacy-note strong, .privacy-note small { display: block; }
.privacy-note strong { font-size: 13px; font-weight: 700; color: #064e3b; }
.privacy-note small { margin-top: 3px; color: #047857; font-size: 11px; line-height: 1.45; }
.privacy-link {
  margin: 8px 0 0;
  border: 0;
  background: transparent;
  padding: 0;
  color: #047857;
  font-size: 11px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.privacy-link:hover { color: #064e3b; }

/* Privacy Modal */
.privacy-dialog {
  width: min(640px, calc(100% - 32px));
  max-height: min(780px, calc(100dvh - 32px));
  margin: auto;
  border: 0;
  border-radius: 20px;
  background: #fff;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
}
.privacy-dialog::backdrop {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}
.privacy-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding: 20px 24px;
}
.privacy-dialog-heading h2 { margin: 0; font-size: 20px; font-weight: 750; }
.privacy-dialog-body { overflow: auto; padding: 20px 24px 12px; color: var(--ink-secondary); font-size: 13.5px; line-height: 1.65; }
.privacy-dialog-body p { margin: 0 0 12px; }
.privacy-dialog-body ul { display: grid; gap: 8px; margin: 0 0 16px; padding-left: 20px; }
.privacy-dialog-footnote {
  border: 1px solid var(--success-border);
  border-radius: 12px;
  background: var(--success-soft);
  padding: 12px 14px;
  color: var(--success-dark);
  font-size: 12px;
}
.privacy-dialog-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 16px 24px;
}

/* =========================================================
   ACTION BAR (STICKY HEADER TOOLBAR)
   ========================================================= */
.action-bar {
  position: sticky;
  top: 12px;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  padding: 10px 16px;
  box-shadow: var(--shadow-sticky);
  backdrop-filter: blur(16px);
}
.action-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.mobile-export-dock { display: none; }

.button-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 9999px;
  background: var(--blue-soft);
  padding: 0 6px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 750;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 14px;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}
.button:hover {
  border-color: var(--line-dark);
  background: #f8fafc;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.button:active {
  transform: translateY(0);
}
.button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}
.button.is-loading::before {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 9999px;
  content: "";
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.button:focus-visible, .icon-button:focus-visible, .zoom-controls button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

.button-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.25);
}
.button-primary:hover {
  border-color: var(--blue-hover);
  background: var(--blue-hover);
  color: #fff;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.35);
}
.button-primary span {
  font-size: 9px;
  color: #86efac;
}

.button-dark {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}
.button-dark:hover {
  background: var(--navy-hover);
  color: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.3);
}

.button-compact {
  align-self: flex-start;
  min-width: max-content;
  min-height: 34px;
  padding: 6px 12px;
  color: var(--blue);
  border-color: var(--blue-border);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 700;
}
.button-compact:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: var(--blue-hover);
}

.file-button { cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Panels (Archive, Check, Dashboard) */
.document-manager,
.check-panel,
.dashboard-panel {
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 22px 26px;
  box-shadow: var(--shadow-md);
  scroll-margin-top: 90px;
}
.document-manager[hidden],
.check-panel[hidden],
.dashboard-panel[hidden] { display: none; }

.manager-heading,
.check-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.manager-heading h2,
.check-heading h2 { margin: 0; font-size: 20px; font-weight: 750; }

.manager-tools {
  display: grid;
  grid-template-columns: minmax(260px, 440px) 1fr;
  gap: 18px;
  align-items: end;
  margin: 18px 0;
}
.manager-tools p { margin: 0 0 9px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.archive-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.archive-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-subtle);
  padding: 14px;
  transition: all 0.15s ease;
}
.archive-card:hover {
  border-color: var(--line-dark);
  background: #fff;
  box-shadow: var(--shadow-xs);
}
.archive-card.is-active {
  border-color: var(--blue-border);
  background: var(--blue-soft);
}
.archive-card > div:first-child { display: grid; min-width: 0; gap: 3px; }
.archive-card strong,
.archive-card span,
.archive-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-card strong { font-size: 13px; font-weight: 700; color: var(--ink); }
.archive-card span { color: var(--muted); font-size: 11px; }
.archive-card small { color: var(--muted-light); font-size: 10px; }
.archive-card > div:last-child { display: flex; flex: 0 0 auto; gap: 6px; align-items: center; }

.archive-empty {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px dashed var(--line-dark);
  border-radius: 12px;
  padding: 22px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.check-summary {
  margin: 16px 0 14px;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 600;
}
.check-summary.success {
  border: 1px solid var(--success-border);
  background: var(--success-soft);
  color: var(--success-dark);
}
.check-summary.warning {
  border: 1px solid var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber-dark);
}

.check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 11px 13px;
  color: var(--ink-secondary);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  transition: all 0.15s ease;
}
.check-item:hover {
  border-color: var(--blue-border);
  background: var(--blue-soft);
  transform: translateY(-1px);
}
.check-item span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 9999px;
  font-weight: 850;
  font-size: 11px;
}
.check-item.error span { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.check-item.warning span { background: var(--amber-soft); color: var(--amber-dark); border: 1px solid var(--amber-border); }

.validation-focus {
  outline: 3px solid rgba(220, 38, 38, 0.4) !important;
  outline-offset: 4px;
  animation: validationPulse 1s ease 2;
}
@keyframes validationPulse {
  50% { outline-color: rgba(220, 38, 38, 0.7); }
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.dashboard-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card-subtle);
  padding: 14px 16px;
}
.dashboard-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dashboard-card strong {
  display: block;
  margin-top: 6px;
  color: var(--blue);
  font-size: 26px;
  font-weight: 800;
}
.dashboard-card.is-danger strong { color: var(--danger); }
.dashboard-card.is-success strong { color: var(--success); }

.dashboard-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.dashboard-toolbar .field { width: min(320px, 100%); }
.dashboard-list { display: grid; gap: 8px; }
.dashboard-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 120px 110px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
}
.dashboard-row.is-overdue { border-color: var(--danger-border); background: #fffdfd; }
.dashboard-row.is-completed { background: #fafdfb; border-color: var(--success-border); }
.dashboard-row time { color: var(--ink); font-size: 11px; font-weight: 700; }
.dashboard-row strong { display: block; overflow: hidden; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-row small { display: block; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.status-badge {
  display: inline-flex;
  justify-content: center;
  border-radius: 9999px;
  background: #f1f5f9;
  padding: 4px 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-align: center;
}
.status-badge.overdue { background: var(--danger-soft); color: var(--danger); }
.status-badge.today { background: var(--amber-soft); color: var(--amber-dark); }
.status-badge.upcoming { background: var(--blue-soft); color: var(--blue); }
.status-badge.completed { background: var(--success-soft); color: var(--success); }

/* =========================================================
   MAIN WORKSPACE LAYOUT
   ========================================================= */
.workspace {
  display: grid;
  grid-template-columns: 180px minmax(560px, 1fr) minmax(460px, 660px);
  gap: 24px;
  align-items: start;
}

/* Sidebar Step Nav */
.step-nav {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 5px;
}
.step-nav-title {
  margin: 0 0 10px 10px;
  color: var(--muted-light);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.step-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--ink-secondary);
  font-size: 12.5px;
  font-weight: 650;
  text-decoration: none;
  transition: all 0.15s ease;
}
.step-nav a:hover {
  background: #e2e8f0;
  color: var(--blue);
}
.step-nav a span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #e2e8f0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}
.step-nav a:hover span {
  background: var(--blue-soft);
  color: var(--blue);
}

.progress-card {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
  box-shadow: var(--shadow-xs);
}
.progress-card > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.progress-card strong { color: var(--blue); font-size: 13px; font-weight: 800; }
.progress-track {
  height: 6px;
  margin: 9px 0;
  overflow: hidden;
  border-radius: 9999px;
  background: #e2e8f0;
}
.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-card small { color: var(--muted-light); font-size: 10px; }

/* Editor Main Column */
.editor {
  display: grid;
  gap: 20px;
  min-width: 0;
}

/* Mode Switcher */
.minutes-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.minutes-mode-card {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 16px 18px;
  color: var(--ink-secondary);
  text-align: left;
  box-shadow: var(--shadow-xs);
  transition: all 0.16s ease;
}
.minutes-mode-card:hover {
  border-color: var(--line-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.minutes-mode-card strong, .minutes-mode-card span { display: block; }
.minutes-mode-card strong { color: var(--ink); font-size: 14.5px; font-weight: 750; }
.minutes-mode-card span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.minutes-mode-card.is-active {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15);
}
.minutes-mode-card.is-active strong { color: var(--blue-dark); }

.simple-mode-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--blue-border);
  border-radius: 14px;
  background: #f0f7ff;
  padding: 14px 18px;
  color: var(--blue-dark);
}
.simple-mode-note strong { margin-bottom: 3px; color: var(--blue-dark); font-size: 13.5px; font-weight: 750; }
.simple-mode-note span { font-size: 12px; line-height: 1.45; color: #1e40af; }
.simple-mode-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.quick-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.quick-options > div:first-child { grid-column: 1 / -1; }
.quick-options > div strong { font-size: 14px; font-weight: 750; color: var(--ink); }
.quick-options > div small, .quick-help { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.quick-options label { font-size: 12.5px; font-weight: 650; color: var(--ink-secondary); }
.quick-options select { width: 100%; margin-top: 5px; }
.quick-options .check-option { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.quick-options .check-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.quick-help { grid-column: 1 / -1; margin: 0; }

body:not(.advanced-mode) .optional-previous-section:not(.is-requested) { display: none !important; }
body:not(.advanced-mode) .advanced-section.optional-previous-section.is-requested { display: block !important; }
body:not(.advanced-mode) .advanced-field,
body:not(.advanced-mode) .advanced-block,
body:not(.advanced-mode) .advanced-section,
body:not(.advanced-mode) .advanced-nav-link { display: none !important; }
body.advanced-mode .simple-mode-note { display: none; }

/* =========================================================
   FORM SECTIONS & FIELD STYLING
   ========================================================= */
.form-section {
  min-width: 0;
  scroll-margin-top: 96px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-section:hover {
  border-color: var(--line-dark);
  box-shadow: var(--shadow-md);
}

.section-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.section-heading-action { align-items: flex-start; }
.section-heading-action > div { flex: 1; }
.section-heading > div, .form-grid > * { min-width: 0; }
.section-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.section-heading p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.accordion-toggle { display: none; }
.step-number {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(29, 78, 216, 0.25);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  display: grid;
  align-content: start;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 650;
}
.field > span, .field > label { min-height: 16px; }
.field b { color: var(--danger); }
.field-wide { grid-column: 1 / -1; }

.profile-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-top: 4px;
}
.profile-controls small {
  flex: 1 1 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
  text-align: right;
}
.profile-controls small.is-mismatch { color: var(--amber-dark); }
.profile-controls .button { flex: 0 1 auto; min-width: 0; width: auto; white-space: normal; }

.manual-subject-field {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 650;
}
.manual-subject-field[hidden] { display: none !important; }

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
}
.board-type-help { color: #475569; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-size: 13.5px;
}
input, select { min-height: 40px; }
textarea {
  min-height: 78px;
  line-height: 1.55;
}
input::placeholder, textarea::placeholder { color: var(--muted-light); }
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}
input:invalid:not(:placeholder-shown) { border-color: var(--danger); }

/* Dynamic list items */
.dynamic-list { display: grid; gap: 10px; }
.dynamic-item {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-subtle);
  padding: 14px;
  transition: all 0.15s ease;
}
.dynamic-item:hover {
  border-color: var(--line-dark);
  background: #fff;
}
.dynamic-item:focus-within {
  border-color: var(--blue-border);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.item-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}
.agenda-item textarea { min-height: 56px; }

.item-actions { display: flex; gap: 4px; }
.icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  transition: all 0.15s ease;
}
.icon-button:hover {
  border-color: var(--line-dark);
  color: var(--blue);
  background: var(--blue-soft);
}
.icon-button:disabled { cursor: not-allowed; opacity: 0.35; }
.icon-button.danger:hover {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}
.button-danger { border-color: var(--danger-border) !important; background: var(--danger-soft) !important; color: var(--danger) !important; }
.button-danger:hover { border-color: var(--danger) !important; background: #fee2e2 !important; }

.decision-fields, .previous-decision-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.participant-fields {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr 0.72fr;
  gap: 10px;
}

.participant-tools, .annual-plan-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  padding: 12px 16px;
}
.participant-tools small, .annual-plan-tools small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.annual-plan-fields {
  display: grid;
  grid-template-columns: 0.7fr 1fr 1fr;
  gap: 10px;
}
.annual-plan-fields .field-wide { grid-column: 1 / -1; }
.annual-plan-note { margin-top: 14px; }
.quorum-field { margin-top: 14px; }

.reminder-box {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  border: 1px solid var(--blue-border);
  border-radius: 12px;
  background: #f8fbff;
  padding: 15px;
}
.reminder-box > div:first-child strong { color: var(--blue-dark); font-size: 12.5px; font-weight: 750; }
.reminder-box > div:first-child small { margin-top: 3px; color: var(--muted); font-size: 10.5px; }

.previous-import-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-subtle);
  padding: 14px;
}

.form-end-note {
  border: 1px solid var(--amber-border);
  border-radius: 14px;
  background: var(--amber-soft);
  padding: 16px 20px;
  color: var(--amber-dark);
  font-size: 11.5px;
  line-height: 1.55;
}
.form-end-note strong { display: block; margin-bottom: 4px; font-size: 12.5px; }
.form-end-note p { margin: 0; }

/* =========================================================
   DOCUMENT PREVIEW PANEL & REALISTIC PAPER
   ========================================================= */
.preview-panel {
  position: sticky;
  top: 86px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #e2e8f0;
  box-shadow: var(--shadow-lg);
}
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  background: #0f172a;
  padding: 10px 16px;
  color: #fff;
  font-size: 12.5px;
}
.preview-toolbar > div { display: flex; align-items: center; gap: 8px; }

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}
.preview-hint { color: #94a3b8; font-size: 11px; }

.zoom-controls {
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  overflow: hidden;
}
.zoom-controls button {
  width: 28px;
  height: 26px;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transition: background 0.15s ease;
}
.zoom-controls button:hover { background: rgba(255, 255, 255, 0.2); }
.zoom-controls span { min-width: 40px; text-align: center; color: #cbd5e1; font-size: 10.5px; font-weight: 700; }

.paper-stage {
  max-height: calc(100vh - 158px);
  overflow: auto;
  overflow-anchor: none;
  padding: 24px;
  scrollbar-gutter: stable;
  overscroll-behavior-x: contain;
}

.paper {
  --paper-zoom: 0.85;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: var(--paper);
  padding: 18mm 17mm 17mm;
  color: #111;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  font-family: var(--font-serif);
  transform: scale(var(--paper-zoom));
  transform-origin: top left;
  margin-bottom: calc((var(--paper-zoom) - 1) * 297mm);
}

.doc-ministry, .doc-location, .doc-school, .doc-title { text-align: center; }
.doc-ministry { margin: 0 0 2px; font-size: 11pt; font-weight: 700; }
.doc-location { margin: 0; color: #111827; font-size: 10.5pt; font-weight: 700; letter-spacing: 0.01em; }
.doc-school { margin: 2px 0 8px; font-size: 12pt; text-transform: uppercase; }
.doc-title { margin: 0; font-size: 12pt; line-height: 1.4; text-transform: uppercase; }
.doc-rule { margin: 12px 0 14px; border: 0; border-top: 1.5px solid #111; }
.doc-info { width: 100%; margin: 0 0 13px; border-collapse: collapse; font-size: 9.5pt; }
.doc-info th, .doc-info td { border: 1px solid #333; padding: 5px 6px; text-align: left; vertical-align: top; }
.doc-info th { width: 19%; background: #f1f1f1; font-weight: 700; }
.doc-basis { margin: 8px 0 13px; font-size: 9.5pt; line-height: 1.45; text-align: justify; }
.doc-section-title { margin: 15px 0 7px; font-size: 10.5pt; font-weight: 700; text-align: center; text-decoration: underline; text-underline-offset: 2px; }
.doc-agenda { margin: 0; padding-left: 20px; }
.doc-agenda li, .doc-paragraph { font-size: 10pt; line-height: 1.5; text-align: justify; }
.doc-agenda li { margin: 0 0 3px; padding-left: 2px; }
.doc-subtitle { margin: 10px 0 3px; font-size: 10pt; font-weight: 700; }
.doc-paragraph { margin: 0 0 7px; text-indent: 1cm; }
.doc-decisions { width: 100%; border-collapse: collapse; font-size: 9pt; }
.doc-decisions th, .doc-decisions td { border: 1px solid #333; padding: 5px; vertical-align: top; }
.doc-decisions th { background: #f1f1f1; text-align: center; }
.doc-decisions .no-col { width: 7%; text-align: center; }
.doc-decisions .owner-col { width: 19%; }
.doc-decisions .date-col { width: 20%; }
.doc-decisions .status-col { width: 16%; text-align: center; }
.doc-decisions small { color: #444; font-size: 8pt; }
.doc-status { display: inline-block; border-radius: 9999px; background: #f1f1f1; padding: 2px 6px; font-size: 8pt; }
.doc-quorum { margin: 10px 0 5px; font-size: 9.5pt; font-style: italic; }
.signature-heading { margin: 22px 0 13px; font-size: 10.5pt; font-weight: 700; text-align: center; }
.doc-signatures.is-separate { break-before: page; page-break-before: always; }
.signature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px 16px; }
.signature-cell { min-height: 69px; text-align: center; font-size: 9pt; break-inside: avoid; }
.signature-cell strong, .signature-cell span, .signature-cell small { display: block; }
.signature-cell small { margin-top: 2px; color: #343b47; font-style: italic; }
.signature-cell strong { margin-bottom: 3px; font-size: 9.5pt; }
.signature-line { width: 70%; margin: 28px auto 0; border-top: 1px dotted #444; }
.approval { width: 42%; min-height: 90px; margin: 26px 0 0 auto; text-align: center; font-size: 9.5pt; break-inside: avoid; }
.approval p { margin: 3px 0; }
.approval-line { width: 80%; margin: 31px auto 0; border-top: 1px dotted #444; }
.doc-annual-plan { break-before: page; page-break-before: always; }
.doc-annual-plan-table { font-size: 8pt; }
.doc-annual-plan-table thead { display: table-header-group; }
.doc-annual-plan-table tr { break-inside: avoid; page-break-inside: avoid; }
.doc-annual-plan-table .period-col { width: 12%; text-align: center; }
.doc-annual-plan-table .annual-owner-col { width: 18%; }
.doc-annual-plan-table .annual-evidence-col { width: 20%; }
.doc-annual-note { margin: 8px 0 0; font-size: 8.5pt; font-style: italic; line-height: 1.4; text-align: justify; }
.doc-rubric-attachment { break-before: page; page-break-before: always; margin-top: 24px; }
.doc-rubric-table { font-size: 8pt; margin-top: 6px; margin-bottom: 12px; width: 100%; border-collapse: collapse; }
.doc-rubric-table thead { display: table-header-group; }
.doc-rubric-table tr { break-inside: avoid; page-break-inside: avoid; }
.doc-rubric-table th, .doc-rubric-table td { padding: 5px 8px; border: 1px solid var(--border, #cbd5e1); }
.doc-rubric-subheading { font-size: 9pt; font-weight: bold; margin: 12px 0 4px; color: var(--text-dark, #1e293b); }
.doc-rubric-subtitle { font-size: 8.5pt; font-style: italic; margin: 2px 0 8px; color: var(--text-muted, #475569); }
.empty-note { border: 1px dashed #aaa; padding: 8px; color: #666; font-size: 9pt; text-align: center; }

.editor-hidden .workspace { grid-template-columns: minmax(0, 1fr); }
.editor-hidden .editor-only { display: none; }
.editor-hidden .preview-panel { position: relative; top: 0; width: 100%; }
.editor-hidden .paper-stage { max-height: none; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: 380px;
  border-radius: 12px;
  background: #0f172a;
  padding: 13px 18px;
  color: #fff;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  font-size: 12.5px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.agenda-fields { min-width: 0; width: 100%; }
.agenda-fields textarea { width: 100%; box-sizing: border-box; }
.agenda-fields details { margin-top: 8px; }
.agenda-fields summary { cursor: pointer; font-size: 0.85rem; color: var(--blue); font-weight: 600; }

.doc-transition-note { margin-top: -6px; color: #1e293b; }
.doc-closing-note { margin: 6px 0 14px; font-size: 9.5pt; font-style: italic; text-align: justify; line-height: 1.45; }
.signature-line.signature-excused, .signature-line.signature-absent { font-style: italic; color: #555; font-size: 8.5pt; margin-top: 20px; padding-top: 3px; }
.doc-attachments { margin-top: 26px; padding-top: 12px; border-top: 1px dashed #777; font-size: 9pt; text-align: left; break-inside: avoid; }
.doc-attachments-title { margin: 0 0 6px; font-size: 9.5pt; font-weight: 700; text-decoration: underline; }
.doc-attachments ol { margin: 0; padding-left: 20px; }
.doc-attachments li { margin-bottom: 3px; line-height: 1.45; }

/* =========================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================= */
@media (max-width: 1380px) {
  .workspace { grid-template-columns: minmax(480px, 1.05fr) minmax(440px, 0.95fr); gap: 20px; }
  .step-nav { display: none; }
  .action-bar { position: relative; top: 0; flex-direction: column; align-items: stretch; }
  .action-group { justify-content: flex-start; }
}

@media (max-width: 1160px) {
  .workspace { grid-template-columns: minmax(440px, 1.05fr) minmax(420px, 0.95fr); }
  .profile-controls { align-items: stretch; flex-direction: column; }
  .profile-controls small { max-width: 100%; text-align: left; }
}

@media (max-width: 900px) {
  .app-shell { padding: 18px 14px 55px; }
  .intro { align-items: stretch; flex-direction: column; gap: 16px; }
  h1 { font-size: 26px; }
  .intro-copy { font-size: 14px; }
  .privacy-note { width: 100%; }
  .action-bar { position: relative; top: 0; }
  .action-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .archive-list, .check-list { grid-template-columns: 1fr; }
  .dashboard-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-row { grid-template-columns: 78px minmax(0, 1fr) 100px; }
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: relative; top: 0; }
  .paper-stage { max-height: min(62dvh, 600px); min-height: 400px; }
  .form-section { padding: 20px; }
}

.close-preview-btn { display: none; }

body.mobile-preview-open {
  overflow: hidden;
}
body.mobile-preview-open .preview-panel {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
  background: #0f172a !important;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom)) !important;
  display: flex !important;
  flex-direction: column !important;
  box-shadow: none !important;
}
body.mobile-preview-open .preview-toolbar {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
  margin-bottom: 8px !important;
}
body.mobile-preview-open .preview-toolbar strong {
  color: #f8fafc !important;
}
body.mobile-preview-open .paper-stage {
  flex: 1 !important;
  max-height: none !important;
  min-height: 0 !important;
  height: 100% !important;
  background: #0b1120 !important;
  border-color: #334155 !important;
}
body.mobile-preview-open .close-preview-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  background: #ef4444 !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  padding: 6px 12px !important;
  border-radius: 8px !important;
  cursor: pointer;
}

@media (max-width: 620px) {
  body { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
  .app-shell { padding: 14px 10px 32px; }
  .action-bar { padding: 10px; }
  .action-group-export { display: none; }
  .mobile-export-dock {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: 45;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    border: 1px solid rgba(203, 213, 225, 0.96);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    padding: 8px;
    box-shadow: 0 14px 38px rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(14px);
  }
  .mobile-export-dock .button { min-height: 40px; font-size: 12.5px; padding: 6px 8px; justify-content: center; }
  .button { width: 100%; }
  .minutes-mode-switch { grid-template-columns: 1fr; }
  .form-grid, .decision-fields, .previous-decision-fields, .participant-fields { grid-template-columns: 1fr; }
  .participant-tools, .annual-plan-tools { align-items: stretch; flex-direction: column; padding: 12px; }
  .participant-tools > *, .annual-plan-tools > * { min-width: 0; width: 100%; }
  .dashboard-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dynamic-item { grid-template-columns: 28px 1fr; }
  .item-actions { grid-column: 2; flex-direction: row !important; justify-content: flex-end; }
  .toast { right: 12px; bottom: calc(118px + env(safe-area-inset-bottom)); left: 12px; max-width: none; }
}

/* =========================================================
   PRINT STYLES
   ========================================================= */
@media print {
  @page { size: A4; margin: 15mm 14mm; }
  html, body { width: auto; background: #fff; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .intro, .action-bar, .mobile-export-dock, .editor-only, .preview-toolbar, .toast, .privacy-dialog { display: none !important; }
  .app-shell { width: auto; margin: 0; padding: 0; }
  .workspace { display: block; }
  .preview-panel, .paper-stage { position: static; width: auto; max-height: none; overflow: visible; border: 0; border-radius: 0; background: #fff; padding: 0; box-shadow: none; }
  .paper { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; transform: none !important; }
  .doc-info, .signature-cell, .approval { break-inside: avoid; }
  .doc-decisions tr { break-inside: avoid; page-break-inside: avoid; }
}
