*{box-sizing:border-box}
:root{
  --bg:#0f0f11;
  --panel:#16171a;
  --muted:#ffffff;
  --text:#a5a5a5;
  --primary:#e21818; /* rouge Sonomix */
  --primary-2:#ef4a60;
  --outline:#2a2e34;
  --danger:#c0392b;
  --ok:#1b8f5a;
  --shadow:0 6px 18px rgba(0,0,0,.35);
}
html,body{height:100%;margin:0;background:var(--bg);color:var(--text);font:15px/1.5 system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif}
main{max-width:1200px;margin:24px auto;padding:0 16px}
h1{margin:0;font-weight:700;font-size:20px}
h2{margin:0 0 12px 0;font-size:18px}
.muted{color:var(--muted)}
.grow{flex:75%}
.row{display:flex;align-items:center}
.wrap{flex-wrap:wrap}
.gap{gap:10px}
.mt-6{margin-top:6px}
.mt-8{margin-top:8px}
.mt-10{margin-top:10px}
.between{justify-content:space-between}
.panel{background:var(--panel);border:1px solid var(--outline);border-radius:14px;padding:14px 16px;box-shadow:var(--shadow);margin-bottom:16px}

.pinned-menu {
  position: fixed;
  bottom: 32px;
  right: 32px;
  top:auto;
  left:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
  background:var(--panel);
  border:1px solid var(--outline);
  border-radius:14px;
  padding:40px 16px;
  box-shadow:var(--shadow);
  width:260px;
  max-width:calc(100vw - 64px);
  z-index:6;
  opacity:1;
  visibility:visible;
  pointer-events:auto;
  transform:translateY(0);
  transition:opacity .3s ease, transform .3s ease, visibility .3s;
}

.pinned-menu-title{
  font-weight:600;
  color:white;
  text-transform:uppercase;
  font-size:12px;
  letter-spacing:0.04em;
}

.pinned-menu-timer{
  display:grid;
  grid-template-columns:auto 1fr auto;
  grid-template-areas:"label actions timer";
  column-gap:12px;
  align-items:center;
  font-family:ui-monospace,Consolas,Menlo,monospace;
}

.pinned-timer-label{
  grid-area:label;
}

.pinned-timer-actions{
  grid-area:actions;
  display:flex;
  gap:8px;
}

.pinned-menu .pinned-timer-display{
  grid-area:timer;
  justify-self:end;
}

.pinned-menu-timer-btn{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  width:100%;
  border-radius:12px;
  background:var(--primary);
  color:#fff;
  border:1px solid var(--primary);

  cursor:pointer;
  transition:background .2s ease, transform .2s ease;
}

.pinned-menu-timer-btn:hover{
  background:var(--primary-2);
  transform:translateY(-1px);
}

.pinned-menu-timer-btn:disabled{
  opacity:0.6;
  cursor:not-allowed;
  transform:none;
}

.pinned-menu-timer-btn-outline{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  width:100%;
  border-radius:12px;
  background:transparent;
  color:#fff;
  border:1px solid var(--outline);
  font-weight:600;
  cursor:pointer;
  transition:border-color .2s ease, color .2s ease, transform .2s ease;
}

.pinned-menu-timer-btn-outline:hover{
  border-color:var(--primary);
  color:var(--primary);
  transform:translateY(-1px);
}

.pinned-menu-timer-btn-outline:disabled{
  opacity:0.6;
  cursor:not-allowed;
  transform:none;
}

.pinned-menu-timer-btn,
.pinned-menu-timer-btn-outline{
  width:100%;
  box-sizing:border-box;
  min-height:42px;
  max-height:48px;
  line-height:1.2;
}

.pinned-menu .pinned-menu-timer-btn,
.pinned-menu .pinned-menu-timer-btn-outline{
  padding:0;
  width:100%;
  flex:1 1 0;
  min-height:34px;
  font-size:12px;
  line-height:1;
}

.pinned-menu-timer-btn-outline{
  color:var(--text);
}
.pinned-timer-display{
  font-size:18px;
  color:white;
}

.pinned-button{
  width:100%;
  text-align:center;
}

.pinned-menu.visible{
  opacity:1;
  visibility:visible;
  pointer-events:auto;
  transform:translateY(0);
}

.app-header{position:sticky;top:0;z-index:5;background:linear-gradient(180deg,rgba(15,15,17,.95),rgba(15,15,17,.85));backdrop-filter:saturate(1.2) blur(6px);border-bottom:1px solid var(--outline);padding:10px 16px;display:grid;grid-template-columns:1fr auto auto;gap:12px;align-items:center}
.brand{display:flex;align-items:center;gap:12px}
.logo{width:36px;height:36px;border-radius:10px;background:var(--primary);color:white;display:grid;place-items:center;font-weight:900;box-shadow:var(--shadow)}
.subtitle{margin:0;color:var(--muted);font-size:12px}
.tabs{display:flex;gap:8px}
.tab{background:transparent;color:var(--text);border:1px solid var(--outline);padding:8px 12px;border-radius:10px;cursor:pointer}
.tab.active{border-color:var(--primary);color:white}
.export-actions{margin-top:12px}
.tab-link {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background-color 0.2s;
}

.tab-link:hover {
  background-color: var(--outline);
}
.header-actions{justify-self:end}

button{cursor:pointer;border:1px solid var(--outline);background:#1e2024;color:var(--text);padding:8px 12px;border-radius:10px}
button.primary{background:var(--primary);border-color:var(--primary);color:white}
button.primary:hover{background:var(--primary-2)}

.shortcuts-card{
  margin-top:16px;
  padding:12px 14px;
  border:1px solid var(--outline);
  border-radius:12px;
  background:rgba(255,255,255,0.04);
  display:flex;
  flex-direction:column;
  gap:10px;
}

.shortcuts-floating{
  position:fixed;
  bottom:32px;
  left:32px;
  width:260px;
  max-width:calc(100vw - 64px);
  margin-top:0;
  box-shadow:var(--shadow);
  z-index:6;
}

.shortcuts-title{
  font-weight:600;
  text-transform:uppercase;
  font-size:12px;
  letter-spacing:0.06em;
  color:var(--muted);
}

.shortcuts-list{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.shortcuts-list li{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  color:var(--text);
  flex-wrap:wrap;
  padding:6px 8px;
  border-radius:10px;
  transition:background .18s ease, box-shadow .18s ease;
}

.shortcut-keys{
  display:flex;
  align-items:center;
  gap:8px;
  font-family:ui-monospace,Consolas,Menlo,monospace;
}

.shortcut-plus{
  color:var(--primary-2);
  font-weight:700;
}

.shortcuts-card kbd{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:38px;
  padding:6px 10px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.2);
  background:rgba(20,20,22,0.8);
  box-shadow:inset 0 -2px 0 rgba(0,0,0,0.4);
  color:var(--muted);
  font-weight:600;
  font-size:13px;
  text-transform:uppercase;
  transition:background .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.shortcut-label{
  flex:1;
  min-width:180px;
}

@media (max-width:720px){
  .shortcuts-floating{
    display:none;
  }
}

.shortcuts-card kbd.is-pressed{
  background:var(--primary);
  color:white;
  transform:translateY(-1px);
  box-shadow:0 0 18px 6px rgba(226,24,24,0.35), inset 0 -2px 0 rgba(0,0,0,0.35);
  border-color:rgba(226,24,24,0.7);
  text-shadow:0 0 6px rgba(255,255,255,0.85);
}

.shortcuts-list li.shortcut-active{
  background:rgba(226,24,24,0.16);
  box-shadow:0 0 22px rgba(226,24,24,0.28), 0 0 0 1px rgba(226,24,24,0.35);
}
button.outline:hover{border-color:var(--primary)}
button.danger{background:#6e1511;border-color:#7a1813;color:#fff}
button:disabled{opacity:.5;pointer-events:none}

/* ✅ CORRECTIF : Forcer la réactivation des éléments enabled */
input[type=text]:enabled,
button:enabled {
  pointer-events: auto !important;
  opacity: 1 !important;
}

/* ✅ CORRECTIF SPÉCIFIQUE : Champs du nouveau parser - VERSION CORRIGÉE */
#newParserName:enabled,
#newParserDisplay:enabled {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: text !important;
}

#createParserBtn:enabled {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
}

input[type=file]{border:1px dashed var(--outline);padding:6px;border-radius:10px;background:#1b1c20;color:var(--muted)}
#fileInput,#xmlInput{display:none}
select{
  background:#1b1c20;
  border:1px solid var(--outline);
  color:var(--text);
  padding:8px 10px;
  border-radius:10px
}

/* AJOUT : Amélioration de la visibilité des options du select */
select option {
  background: var(--panel);
  color: white;
  padding: 8px;
}

select option:hover,
select option:focus {
  background: var(--primary);
  color: white;
}

select option:disabled {
  color: var(--muted);
  background: var(--bg);
}

/* Amélioration spécifique pour le select des parsers */
#parserSelect {
  flex: 1;
  min-width: 200px;
  color: white; /* Forcer le texte en blanc */
}

#parserSelect option {
  background: var(--panel);
  color: white;
  padding: 10px;
}

.timer{font:700 42px/1 ui-monospace,Consolas,Menlo,monospace}
.offset-controls{
  align-items:center;
  justify-content:center;
  width:100%;
}
.offset-settings{
  min-width:260px;
  background:rgba(18,19,22,0.6);
  border:1px solid var(--outline);
  border-radius:14px;
  padding:16px 18px;
  display:flex;
  flex-direction:column;
  gap:14px;
  box-shadow:var(--shadow);
  text-align:center;
}
.offset-label{
  text-align:center;
  font-weight:600;
}
.offset-slider-wrapper{
  display:grid;
  grid-template-columns:auto 1fr auto;
  align-items:center;
  gap:12px;
  justify-items:center;
}
.offset-slider{
  width:100%;
  appearance:none;
  height:6px;
  border-radius:999px;
  background:linear-gradient(90deg,rgba(226,24,24,0.35),rgba(226,24,24,0.8));
  outline:none;
  position:relative;
}
.offset-slider::-webkit-slider-thumb{
  appearance:none;
  width:18px;
  height:18px;
  border-radius:50%;
  background:#fff;
  border:2px solid var(--primary);
  box-shadow:0 0 8px rgba(226,24,24,0.45);
  cursor:pointer;
}
.offset-slider::-moz-range-thumb{
  width:18px;
  height:18px;
  border-radius:50%;
  background:#fff;
  border:2px solid var(--primary);
  box-shadow:0 0 8px rgba(226,24,24,0.45);
  cursor:pointer;
}
.offset-slider-min,
.offset-slider-max{
  font-size:12px;
  font-weight:600;
  text-align:center;
}
.offset-preview-badge{
  display:flex;
  justify-content:center;
  align-items:center;
}
.offset-preview-badge span{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:80px;
  padding:6px 12px;
  border-radius:999px;
  background:rgba(226,24,24,0.12);
  border:1px solid rgba(226,24,24,0.35);
  color:white;
  font-weight:600;
  font-size:14px;
  text-align:center;
}
.offset-manual{
  align-items:center;
  justify-content:center;
}
.offset-seconds{
  max-width:160px;
  text-align:center;
  background:#1b1c20;
  border:1px solid var(--outline);
  border-radius:10px;
  padding:8px 10px;
  color:white;
  font-weight:600;
}
.offset-manual button{
  min-width:120px;
}
.offset-hint{
  display:block;
  text-align:center;
  font-size:12px;
}

.list{display:flex;flex-direction:column;gap:8px}
.line{border:1px solid var(--outline);border-radius:10px;padding:10px 12px;background:#1a1b1f}
.line .meta{color:var(--muted);font:12px ui-monospace,monospace}
.line .controls{margin-top:8px}
.line .title {
  white-space: pre-wrap;
  word-break: break-word;
}
.line .title a{
  color: var(--primary);
  text-decoration: underline;
}
.line .title a:hover{
  color: var(--primary-2);
}
.inline-edit textarea{width:100%;min-height:96px}

#logPanel{position:fixed;left:0;right:0;bottom:0;height:240px;background:#0b0b0c;border-top:1px solid var(--outline);box-shadow:0 -6px 18px rgba(0,0,0,.45);padding:8px 10px;z-index:9999}
#logPanel.hidden{display:none}
#logPanel .toolbar{display:flex;gap:8px;align-items:center;margin-bottom:6px}
#logInner{height:180px;overflow:auto;font:12px ui-monospace,monospace;white-space:pre-wrap;color:#b8f5b8}

.page{display:none}
.page.active{display:block}
@media (max-width:720px){
  .timer{font-size:32px}
}

@media (max-width:960px){
  main{padding:0 12px}
  .app-header{grid-template-columns:1fr auto;grid-template-rows:auto auto;row-gap:10px}
  .header-actions{justify-self:flex-end}
}

@media (max-width:720px){
  html,body{font-size:14px}
  main{margin:16px auto}
  .app-header{grid-template-columns:1fr;grid-template-rows:auto auto auto;text-align:center}
  .brand{justify-content:center}
  .tabs{flex-wrap:wrap;justify-content:center}
  .header-actions{justify-self:stretch;display:flex;gap:8px}
  .header-actions button{flex:1}
  .timer{font-size:28px}
  .panel{padding:12px 14px}
  .panel .row{flex-direction:column;align-items:stretch}
  .panel .row.gap>*{width:100%}
  .panel .row.gap.wrap{flex-direction:column}
  .offset-controls{
    align-items:center;
    justify-content:center;
  }
  .offset-settings{min-width:0;width:100%}
  .offset-seconds{max-width:none}
  .export-actions{flex-direction:column;align-items:stretch}
  .export-actions button{width:100%}
  textarea,select,input,button{font-size:0.85rem;padding:8px 10px}
  .tabs .tab,.tabs .tab-link{flex:1 1 100%;text-align:center}
  .history-card{left:16px;right:16px;width:auto}
  .line .controls.row{flex-direction:column;align-items:stretch}
  .line .controls.row button{width:100%}
  #logPanel{height:220px}
  .pinned-menu{
    top:calc(66px + env(safe-area-inset-top, 0px));
    bottom:auto;
    right:16px;
    left:16px;
    width:calc(100vw - 32px);
    max-width:none;
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transform:translateY(-20px);
  }
  .pinned-menu.visible{
    opacity:1;
    visibility:visible;
    pointer-events:auto;
    transform:translateY(0);
  }
  .pinned-menu-bottom{
    position:fixed;
    bottom:calc(16px + env(safe-area-inset-bottom, 0px));
    left:16px;
    right:16px;
    width:calc(100vw - 32px);
    max-width:none;
    display:flex;
    flex-direction:column;
    gap:10px;
    background:var(--panel);
    border:1px solid var(--outline);
    border-radius:14px;
    padding:14px;
    box-shadow:var(--shadow);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transform:translateY(20px);
    transition:opacity .3s ease, transform .3s ease, visibility .3s ease;
    z-index:7;
  }
  .pinned-menu-bottom .pinned-button,
  .pinned-menu-bottom button{
    width:100%;
    min-height:46px;
  }
  .pinned-menu-bottom.visible{
    opacity:1;
    visibility:visible;
    pointer-events:auto;
    transform:translateY(0);
  }
  main{
    padding-bottom:calc(160px + env(safe-area-inset-bottom, 0px));
  }
}

.hidden {
  display: none !important;
}

#prepInput {
  overflow-y: hidden;
  resize: none;
}

#liveInput {
  min-height: 48px;
  resize: vertical;
}

#sourceMode {
  min-width: 220px;
  flex: 1 1 220px;
}

#sourceMode,
#docType {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: var(--panel);
  border: 1px solid var(--outline);
  color: white;
  padding: 8px 42px 8px 12px;
  border-radius: 10px;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M1 1.5l5 5 5-5' stroke='%23ffffff' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
}

#sourceMode:focus,
#docType:focus {
  border-color: #ffffff99;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
  outline: none;
}

#sourceMode option,
#docType option {
  background: var(--panel);
  color: white;
}

#sourceMode::-ms-expand,
#docType::-ms-expand {
  display: none;
}

#webControls small {
  display: block;
  line-height: 1.4;
}

#scrapeStatus {
  white-space: pre-line;
}

.conversion-stats{margin-bottom:10px;font-weight:700;color:#999}
.conversion-output{
  background:#0f1115;
  padding:14px;
  border-radius:10px;
  max-height:500px;
  overflow:auto;
  min-height:120px;
  border:1px solid var(--outline);
  white-space:pre-wrap;
  font-family:ui-monospace,Consolas,Menlo,monospace;
  font-size:13px;
  color:#e5e5e5;
}

/* Styles pour le modal */
.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--outline);
  border-radius: 14px;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--outline);
}

.modal-header h2 {
  margin: 0;
  color: white;
}

.modal-body {
  padding: 20px;
}

.close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
  padding: 5px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close:hover {
  color: white;
  background: var(--outline);
}

/* Section Nouveau Parser */
.modal-body > div:first-child {
  background: var(--bg);
  border: 1px solid var(--outline);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 24px;
}

.modal-body h3 {
  margin-top: 0;
  margin-bottom: 16px;
  color: white;
  font-size: 16px;
}

/* Amélioration des lignes du modal */
.modal-body .row {
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.modal-body label {
  font-weight: bold;
  color: white;
  min-width: 140px;
  flex-shrink: 0;
}

/* Amélioration du select des parsers */
#parserSelect {
  flex: 1;
  min-width: 200px;
  color: white; /* Forcer le texte en blanc */
}

#parserSelect option {
  background: var(--panel);
  color: white;
  padding: 10px;
}

/* Zone de code */
#parserCode {
  width: 100%;
  height: 400px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
  font-size: 13px;
  line-height: 1.4;
  background: var(--bg);
  border: 1px solid var(--outline);
  color: var(--text);
  padding: 12px;
  border-radius: 10px;
  resize: vertical;
  tab-size: 4;
}

#parserCode:focus {
  outline: none;
  border-color: var(--primary);
}

/* Zone de statut */
#parserStatus {
  border-radius: 10px;
  padding: 12px;
  margin-top: 16px;
  font-weight: 500;
  border: 1px solid transparent;
}

/* Inputs du nouveau parser */
#newParserName, #newParserDisplay {
  flex: 1;
  min-width: 180px;
}

/* Message d'aide */
.modal-body small {
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-top: 8px;
}

/* Responsive pour le modal */
@media (max-width:768px){
  .modal-content{width:95%;max-height:95vh}
  .modal-body .row{flex-direction:column;align-items:stretch}
  .modal-body label{min-width:auto;margin-bottom:4px}
  #parserCode{height:300px}
}

/* Correctifs d'interaction */
input:enabled,
textarea:enabled,
select:enabled,
button:enabled{pointer-events:auto !important;opacity:1 !important;cursor:auto}

button:enabled{cursor:pointer}

/* Carte flottante Historique */
.history-card{position:fixed;top:70px;right:30px;width:340px;background:var(--panel);border:1px solid var(--outline);border-radius:14px;box-shadow:var(--shadow);z-index:2000;padding:0;display:flex;flex-direction:column;animation:fadeIn .2s}
.history-card.hidden{display:none !important}
.history-card-header{display:flex;justify-content:space-between;align-items:center;padding:14px 18px 8px 18px;border-bottom:1px solid var(--outline);font-weight:bold;color:white}
.history-card .close{background:none;border:none;font-size:22px;cursor:pointer;color:var(--text);padding:2px 8px;border-radius:50%}
.history-card .close:hover{background:var(--outline);color:white}
#exportHistory{padding:12px 18px 18px 18px;font-size:14px}
#exportHistory .history-row{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;gap:10px}
#exportHistory .history-row:last-child{margin-bottom:0}
.history-download{white-space:nowrap}
.history-date{color:#888;font-size:12px;margin-left:4px}

/* Toast notifications */
.toast{position:fixed;top:30px;left:50%;transform:translate(-50%,0);background:var(--panel);color:#fff;padding:16px 32px;border-radius:12px;font-size:1.1em;z-index:3000;box-shadow:0 2px 12px rgba(0,0,0,.3);pointer-events:none;animation:fadeIn .2s ease-out forwards}
.toast--success{background:#2ecc40}
.toast--danger{background:#e74c3c}
.toast--info{background:var(--primary)}

@keyframes fadeIn{
  from{opacity:0;transform:translate(-50%,-10px)}
  to{opacity:1;transform:translate(-50%,0)}
}
.btn-add-now{
  border-color:rgba(27,143,90,.7);
  color:#7fffa9;
}

.btn-add-now:hover{
  border-color:rgba(27,143,90,1);
  color:#b9ffd1;
  background:rgba(27,143,90,.1);
}
/* --- POPUP VIDÉO  --- */
.video-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(3px);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.video-popup {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.video-popup-inner {
  width: 90%;
  max-width: 900px;
  background: var(--panel);
  border: 1px solid var(--outline);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ✅ Apparition */
.video-popup.active,
.video-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ✅ Masquage */
.hidden {
  display: none !important;
}
