:root {
  --orange: #E36414;
  --orange-dark: #C24F0B;
  --orange-deep: #9A3412;
  --orange-soft: #FDEDE3;
  --ink: #1C1917;
  --ink-soft: #44403C;
  --muted: #78716C;
  --line: #E7E2DC;
  --paper: #FFFFFF;
  --bg: #FAF8F6;
  --serif: Georgia, 'Times New Roman', 'Liberation Serif', serif;
  --sans: 'Gill Sans', 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

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

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

/* ---------- Header ---------- */

.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(28, 25, 23, 0.04);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 40px;
  height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: none;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: bold;
  border-radius: 4px;
}

.brand-name {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 0.01em;
}

.main-nav {
  display: flex;
  gap: 28px;
  margin-right: auto;
}

.main-nav a {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.main-nav a:hover {
  color: var(--orange-dark);
  border-bottom-color: var(--orange);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 26px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.btn-sm {
  padding: 10px 18px;
  font-size: 12px;
}

.btn-primary {
  background: var(--orange);
  color: var(--paper);
  box-shadow: 0 2px 6px rgba(227, 100, 20, 0.25);
}

.btn-primary:hover {
  background: var(--orange-dark);
  box-shadow: 0 4px 12px rgba(227, 100, 20, 0.3);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn-outline:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn-outline-orange {
  background: transparent;
  color: var(--orange-dark);
  border-color: var(--orange);
}

.btn-outline-orange:hover {
  background: var(--orange);
  color: var(--paper);
  box-shadow: 0 2px 8px rgba(227, 100, 20, 0.25);
}

/* ---------- Hero ---------- */

.hero {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 84px 0 64px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--orange-dark);
  margin-bottom: 18px;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.12;
  font-weight: bold;
  max-width: 720px;
  margin-bottom: 22px;
}

.hero h1 .accent {
  color: var(--orange);
}

.lead {
  font-size: 18px;
  color: var(--muted);
  max-width: 640px;
  margin-bottom: 36px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  height: 54px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(28, 25, 23, 0.04);
}

.search-bar:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
}

.search-bar svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex-shrink: 0;
}

.search-bar input {
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  width: 100%;
  height: 100%;
}

.search-bar input::placeholder {
  color: var(--muted);
}

.hero-stats {
  display: flex;
  gap: 0;
  margin-top: 52px;
}

.stat {
  padding: 0 40px;
  border-left: 1px solid var(--line);
}

.stat:first-child {
  padding-left: 0;
  border-left: none;
}

.stat-value {
  display: block;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: bold;
  color: var(--ink);
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Sections ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 64px 0 28px;
}

.section-head h2 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: bold;
}

.section-head .rule {
  flex: 1;
  height: 1px;
  background: var(--line);
  transform: translateY(-6px);
}

.doc-count {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Category sections ---------- */

.cat-sections {
  margin-bottom: 24px;
}

.cat-section {
  margin-bottom: 44px;
}

.cat-section:last-child {
  margin-bottom: 0;
}

.cat-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.cat-flag {
  width: 5px;
  height: 24px;
  border-radius: 3px;
  background: var(--orange);
  flex-shrink: 0;
}

.cat-section[data-cat='brevet'] .cat-flag {
  background: var(--orange-deep);
}

.cat-section[data-cat='classe'] .cat-flag {
  background: var(--muted);
}

.cat-head h3 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: bold;
  white-space: nowrap;
}

.cat-rule {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.cat-count {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Document cards ---------- */

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.doc-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 20px 18px 24px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.doc-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--orange);
  border-radius: 10px 0 0 10px;
}

.doc-card[data-cat='brevet']::before {
  background: var(--orange-deep);
}

.doc-card[data-cat='classe']::before {
  background: var(--muted);
}

.doc-card:hover,
.doc-card:focus-visible {
  border-color: #D9D2CB;
  box-shadow: 0 10px 26px rgba(28, 25, 23, 0.12);
  transform: translateY(-3px);
}

.doc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-icon {
  width: 22px;
  height: 22px;
  color: var(--orange);
}

.doc-year {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: bold;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 8px;
}

.doc-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: bold;
  line-height: 1.35;
}

.doc-card:hover .doc-title {
  color: var(--orange-dark);
}

.doc-subject {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--orange-dark);
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 13px;
  color: var(--muted);
}

.doc-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.doc-meta span::before {
  content: '';
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line);
}

.doc-meta span:first-child::before {
  display: none;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--paper);
}

/* ---------- About ---------- */

.about {
  background: var(--paper);
  border-top: 1px solid var(--line);
  margin-top: 72px;
  padding-bottom: 24px;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}

.about-item h3 {
  font-family: var(--serif);
  font-size: 19px;
  margin-bottom: 10px;
}

.about-item h3::before {
  content: '';
  display: block;
  width: 32px;
  height: 3px;
  background: var(--orange);
  margin-bottom: 14px;
}

.about-item p {
  font-size: 15px;
  color: var(--muted);
}

/* ---------- Footer ---------- */

.site-footer {
  background: var(--ink);
  color: #D6D3D1;
  margin-top: 72px;
  border-top: 3px solid var(--orange);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 48px;
  padding: 56px 24px 40px;
}

.footer-brand p {
  font-size: 14px;
  color: #A8A29E;
  margin-top: 18px;
  max-width: 320px;
}

.brand-light .brand-name {
  color: var(--paper);
}

.brand-light .brand-mark {
  color: var(--paper);
}

.footer-col h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 16px;
}

.footer-col a {
  display: block;
  font-size: 14px;
  color: #D6D3D1;
  padding: 5px 0;
  transition: color 0.15s ease;
}

.footer-col a:hover {
  color: var(--orange);
}

.footer-bottom {
  border-top: 1px solid #44403C;
  padding: 20px 0;
  font-size: 13px;
  color: #A8A29E;
}

/* ---------- Admin ---------- */

.admin-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.admin-header .header-inner {
  height: 64px;
}

.admin-header .btn-sm {
  margin-left: auto;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
  font-size: 14px;
  color: var(--muted);
}

.admin-user .btn-sm {
  margin-left: 0;
}

.admin-main {
  flex: 1;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 48px 24px 72px;
}

.admin-main h1 {
  font-family: var(--serif);
  font-size: 32px;
  margin-bottom: 32px;
}

.panel-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 48px;
}

.panel-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px 24px;
  box-shadow: 0 2px 8px rgba(28, 25, 23, 0.04);
}

.panel-card .stat-value {
  font-size: 34px;
}

.panel-card .stat-label {
  margin-top: 2px;
}

.panel-section {
  margin-bottom: 48px;
}

.panel-section h2 {
  font-family: var(--serif);
  font-size: 22px;
  margin-bottom: 18px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.admin-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  white-space: nowrap;
}

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

.admin-table td.td-title {
  font-family: var(--serif);
  font-weight: bold;
  color: var(--ink);
  white-space: normal;
  min-width: 220px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 3px 9px;
}

.badge-bac {
  background: var(--orange);
  color: var(--paper);
}

.badge-brevet {
  background: var(--orange-deep);
  color: var(--paper);
}

.badge-classe {
  background: #E7E2DC;
  color: var(--ink-soft);
}

.export-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 2px 8px rgba(28, 25, 23, 0.04);
}

.export-card p {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 18px;
  max-width: 560px;
}

.export-output {
  display: none;
  background: var(--ink);
  color: #E7E5E4;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  border-radius: 4px;
  border-left: 4px solid var(--orange);
  padding: 18px 20px;
  margin-top: 22px;
  max-height: 380px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.export-output.visible {
  display: block;
}

/* Login */

.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--orange);
  border-radius: 8px;
  padding: 40px 36px 36px;
  box-shadow: 0 4px 18px rgba(28, 25, 23, 0.06);
}

.login-card .brand {
  margin-bottom: 28px;
}

.login-card h1 {
  font-family: var(--serif);
  font-size: 26px;
  margin-bottom: 6px;
}

.login-card .login-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  height: 48px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
}

.login-card .btn {
  width: 100%;
  margin-top: 8px;
}

.form-error {
  display: none;
  font-size: 13px;
  color: #B91C1C;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 18px;
}

.form-error.visible {
  display: block;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .main-nav {
    display: none;
  }

  .hero-stats {
    flex-wrap: wrap;
    gap: 24px 0;
  }

  .stat {
    padding: 0 24px;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }

  .panel-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .header-inner {
    gap: 16px;
  }

  .hero {
    padding: 56px 0 48px;
  }

  .stat {
    padding: 0 16px;
  }

  .stat-value {
    font-size: 24px;
  }

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

  .panel-stats {
    grid-template-columns: 1fr;
  }

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

  .cat-head h3 {
    font-size: 20px;
  }

  .cat-count {
    display: none;
  }
}

/* ---------- Reactions ---------- */

.reaction-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.reaction-btn svg {
  width: 15px;
  height: 15px;
}

.reaction-btn:hover {
  border-color: var(--orange);
  color: var(--orange-dark);
}

.reaction-btn.liked {
  border-color: var(--orange);
  color: var(--orange-dark);
  background: var(--orange-soft);
  box-shadow: 0 2px 8px rgba(227, 100, 20, 0.15);
}


/* ---------- Brand mark (paper icon) ---------- */

.brand-mark {
  color: var(--orange);
  background: none;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

/* ---------- Card social row ---------- */

.doc-social {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: auto;
  padding-top: 4px;
}

.doc-social-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.doc-social-item svg {
  width: 15px;
  height: 15px;
  color: var(--orange);
}

/* ---------- Document page ---------- */

.doc-page {
  padding-top: 32px;
  padding-bottom: 72px;
}

.back-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 24px;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--orange-dark);
}

.doc-hero {
  margin-bottom: 56px;
}

.doc-info-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px 34px;
  box-shadow: 0 2px 8px rgba(28, 25, 23, 0.04);
}

.doc-info-panel h1 {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.2;
  margin: 14px 0 8px;
}

.doc-info-panel .doc-subject {
  margin-bottom: 14px;
}

.doc-info-panel .doc-meta {
  margin-bottom: 24px;
}

.doc-hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.doc-hero-actions .reaction-btn {
  margin-bottom: 0;
}

.comments-section {
  padding-top: 8px;
  margin-bottom: 56px;
}

.comments-section .section-head {
  margin: 0 0 12px;
}

.comments-section .comment-form {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 24px;
}

.comments-section .comment-form input,
.comments-section .comment-form textarea {
  background: var(--paper);
}

.td-content {
  white-space: normal;
  min-width: 260px;
  max-width: 420px;
}

/* ---------- Comment items ---------- */

.comment-item {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--orange-soft);
  flex-shrink: 0;
}

.comment-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.comment-pseudo {
  font-size: 13px;
  font-weight: 700;
  color: var(--orange-dark);
}

.comment-date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.comment-content {
  font-size: 14px;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.comments-empty {
  padding: 22px 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

.comment-form-row {
  margin-bottom: 12px;
}

.comment-form input,
.comment-form textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-form input:focus,
.comment-form textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
}

.comment-form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.comment-form .form-error {
  margin: 0;
}

/* ---------- Responsive: document page ---------- */

@media (max-width: 900px) {
  .doc-hero {
    margin-bottom: 40px;
  }
}

@media (max-width: 560px) {
  .doc-info-panel {
    padding: 22px 20px;
  }

  .comment-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}

/* ---------- Utility classes ---------- */

.push-right {
  margin-left: auto;
}

.admin-tag {
  margin-left: 16px;
}

.btn-icon {
  width: 14px;
  height: 14px;
}

.td-strong {
  font-weight: 700;
}
