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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --text: #e8e4d9;
  --text-muted: #7a7570;
  --accent: #c8a84b;
  --accent-green: #4a9b6f;
  --danger: #c0392b;
}

:root[data-theme="light"] {
  --bg: #f5f2eb;
  --surface: #ede9e0;
  --border: #d4cfc4;
  --text: #1a1a1a;
  --text-muted: #6b6560;
  --accent: #b8941e;
  --accent-green: #3d8a5f;
  --danger: #c0392b;
}

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'Source Code Pro', monospace;
  font-size: 12px;
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  letter-spacing: 0.05em;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Source Code Pro', monospace;
  font-size: 15px;
  line-height: 1.7;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
}

/* GRAIN TEXTURE */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* HERO */
.hero {
  position: relative;
  padding: 80px 0 60px;
  border-bottom: 1px solid var(--border);
}

.site-header {
  margin-bottom: 56px;
}

.logo {
  font-family: 'Playfair Display', serif;
  font-size: clamp(48px, 8vw, 88px);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 16px;
}

.tagline {
  font-size: 16px;
  color: var(--text-muted);
  font-style: italic;
  border-left: 2px solid var(--accent-green);
  padding-left: 14px;
  margin-left: 2px;
}

.about-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 20px 24px;
  margin-bottom: 40px;
  font-size: 14px;
  color: var(--text-muted);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 40px;
}

@media (max-width: 620px) {
  .info-grid { grid-template-columns: 1fr; }
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 24px;
}

.info-card h3 {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 12px;
}

.info-card p { margin-bottom: 12px; }
.info-card p:last-child { margin-bottom: 0; }

.muted { color: var(--text-muted); font-size: 13px; }

.contact-block {
  border: 1px dashed var(--border);
  padding: 20px 24px;
  margin-bottom: 48px;
  font-size: 14px;
  color: var(--text-muted);
}

.mail-link {
  color: var(--accent-green);
  text-decoration: none;
}
.mail-link:hover { text-decoration: underline; }

.cta-wrap { text-align: center; }

.btn-cta {
  display: inline-block;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: 'Source Code Pro', monospace;
  font-size: 15px;
  padding: 14px 36px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  letter-spacing: 0.05em;
}
.btn-cta:hover {
  background: var(--accent);
  color: var(--bg);
}

/* FORM SECTION */
.form-section {
  position: relative;
  padding: 80px 0 100px;
}

.page-nav {
  margin-bottom: 40px;
}

.back-link {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }

.form-title {
  font-family: 'Playfair Display', serif;
  font-size: 36px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 48px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
}

.field-group {
  margin-bottom: 32px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.required { color: var(--accent); }
.optional { color: var(--text-muted); font-style: italic; text-transform: none; letter-spacing: 0; }

/* FILE DROP */
.file-drop {
  position: relative;
  border: 1px dashed var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s;
}
.file-drop:hover, .file-drop.drag-over {
  border-color: var(--accent);
}
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.file-drop-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 8px;
  pointer-events: none;
}
.file-drop-ui--compact {
  flex-direction: row;
  padding: 14px 24px;
  gap: 10px;
}
.file-drop-ui--compact .file-icon { font-size: 16px; }
.file-drop-ui--compact .file-text { font-size: 13px; }
.file-icon {
  font-size: 28px;
  color: var(--accent);
}
.file-text {
  font-size: 14px;
  color: var(--text-muted);
}
.file-text u { color: var(--accent); }
.file-types {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.files-list {
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--border);
}
.file-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-left: 3px solid transparent;
  transition: border-color 0.15s;
}
.file-item.active { border-left-color: var(--accent); }

.file-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.file-item-name {
  flex: 1;
  color: var(--accent-green);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item-size {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.file-item-actions { display: flex; gap: 8px; flex-shrink: 0; }

.file-item-options {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.file-opt-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.file-opt-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.file-opt-btns { display: flex; gap: 6px; }
.file-opt-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-family: 'Source Code Pro', monospace;
  font-size: 13px;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.file-opt-btn:hover { border-color: var(--accent); color: var(--text); }
.file-opt-btn input[type=radio] { display: none; }
.file-opt-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.file-opt-btn:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent);
  background: #221e12;
}
[data-theme="light"] .file-opt-btn:has(input:checked) { background: #efe5c8; }

.btn-preview-reopen {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'Source Code Pro', monospace;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: border-color 0.2s, color 0.2s;
}
.btn-preview-reopen:hover { border-color: var(--accent); color: var(--accent); }

.file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}
.file-remove:hover { color: var(--danger); }

.files-list.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* RADIO */
.radio-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 18px;
  transition: border-color 0.2s;
}
.radio-option:hover { border-color: var(--accent); }
.radio-option input[type="radio"] { accent-color: var(--accent); }
.radio-option:has(input:checked) {
  border-color: var(--accent);
  background: #221e12;
}
[data-theme="light"] .radio-option:has(input:checked) {
  background: #efe5c8;
}

/* INPUTS */
.input-text, .input-select, .input-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Source Code Pro', monospace;
  font-size: 15px;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.input-text:focus, .input-select:focus, .input-textarea:focus {
  border-color: var(--accent);
}
.input-textarea { resize: vertical; }
.input-select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23c8a84b' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

.fields-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.fields-row .field-group { margin-bottom: 0; }

/* ERRORS */
.field-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
  min-height: 18px;
}

/* TARIF */
.tarif-box {
  background: var(--surface);
  border: 1px solid var(--accent);
  padding: 24px 28px;
  margin-bottom: 32px;
}

.tarif-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 18px;
  font-weight: 400;
}

.tarif-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tarif-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
}

.tarif-label { color: var(--text-muted); }
.tarif-value { color: var(--text); font-variant-numeric: tabular-nums; }

.tarif-separator {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.tarif-total .tarif-label {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 13px;
}

.tarif-total .tarif-value {
  color: var(--accent);
  font-size: 20px;
  font-weight: 600;
}

/* SUBMIT */
.submit-wrap {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.btn-submit {
  background: var(--accent);
  color: var(--bg);
  border: none;
  font-family: 'Source Code Pro', monospace;
  font-size: 15px;
  font-weight: 600;
  padding: 16px 40px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: opacity 0.2s;
}
.btn-submit:hover { opacity: 0.85; }
.btn-submit:active { opacity: 0.7; }

.submit-note {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* PREVIEW */
.preview-wrap {
  margin-top: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: none;
}
.preview-wrap.visible { display: block; }

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.preview-filename {
  color: var(--accent);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.preview-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'Source Code Pro', monospace;
  font-size: 12px;
  padding: 0;
  transition: color 0.2s;
}
.preview-close:hover { color: var(--danger); }

.preview-body {
  padding: 0;
  position: relative;
}
.preview-section { border-bottom: 1px solid var(--border); }
.preview-section:last-child { border-bottom: none; }
.preview-section-label {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.04em;
}
.preview-section img {
  display: block;
  max-width: 100%;
  max-height: 500px;
  margin: 0 auto;
  object-fit: contain;
}
.preview-unavailable {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-style: italic;
}

/* SHEET MODE */
.sheet-panel {
  margin-top: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 16px;
}
.btn-sheet-mode {
  width: 100%;
  background: transparent;
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
  font-family: 'Source Code Pro', monospace;
  font-size: 13px;
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.2s, color 0.2s;
}
.btn-sheet-mode:hover { background: var(--accent-green); color: var(--bg); }

.sheet-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sheet-panel-title {
  font-size: 12px;
  color: var(--accent-green);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.btn-sheet-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Source Code Pro', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s;
  padding: 0;
}
.btn-sheet-cancel:hover { color: var(--danger); }

.sheet-panel-opts {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

/* SHEET PREVIEW */
.sheet-content { display: flex; flex-direction: column; }
.sheet-content--split { flex-direction: row; }

.sheet-page {
  flex: 1;
  border-right: 1px solid var(--border);
}
.sheet-page:last-child { border-right: none; }

.sheet-page-label {
  padding: 5px 12px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}


.pdf-canvas-wrap {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 8px 26px;
  gap: 12px;
}

.pdf-page-frame {
  position: relative;
  border: 1px solid var(--text-muted);
  box-shadow: 3px 3px 10px rgba(0,0,0,0.18);
  background: #fff;
  width: 100%;
  aspect-ratio: 210 / 297;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-page-frame > canvas,
.pdf-page-frame > img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.pdf-page-lbl {
  position: absolute;
  bottom: -18px;
  right: 0;
  font-family: 'Source Code Pro', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  line-height: 1;
}

/* RECTO-VERSO */
.rv-sheet {
  padding: 16px 8px 24px;
  border-bottom: 1px solid var(--border);
}
.rv-sheet:last-child { border-bottom: none; }

.rv-sheet-lbl {
  font-family: 'Source Code Pro', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.rv-pages {
  display: flex;
  gap: 16px;
}

.rv-page {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rv-page-lbl {
  font-family: 'Source Code Pro', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

.rv-blank-txt {
  font-family: 'Source Code Pro', monospace;
  font-size: 11px;
  color: #ccc;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: auto;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }
