:root{
  --bg:#000;
  --text:#fff;
  --fg: var(--text);
  --muted: rgba(255,255,255,0.7);
  --line: rgba(255,255,255,0.18);

  --panel:#111;
  --panel2:#181818;

  --btn:#555;
  --btn2:#2a2a2a;

  --border: var(--line);
  --accent:#e67e23;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

body{
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === APP === */

#app{
  display:flex;
  flex-direction:column;
  flex: 1 0 auto;
}

#topbar{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:14px;
  border-bottom:1px solid var(--border);
  background: var(--panel);
}

#status{
  display:flex;
  flex-wrap:wrap;
  gap:14px;
  color: var(--muted);
  font-size: 15.5px;
}

#status strong{
  color: var(--text);
  font-weight: 700;
}

#controls{
  display:flex;
  gap:10px;
  flex-wrap: wrap;
}

button{
  background: var(--btn);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor:pointer;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display:flex;
  align-items:center;
  justify-content:center;
}

button:hover{ background: var(--btn2); }

button.is-running{
  background: var(--accent);
  color: #111;
  border-color: rgba(0,0,0,0.25);
  font-weight: 700;
}

#letter{
  flex: 1 1 auto;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  line-height: 1;
  user-select:none;
  color: var(--accent);
  font-size: clamp(140px, 28vh, 320px);
  padding: 10px 0;
}

/* === GENERATOR OUTPUT === */

.generator-output{
  width: min(96vw, 1100px);
  max-height: 100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 0.08em;
  color: var(--accent);
}

.generator-line{
  color: var(--accent);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: 0.08em;
  white-space: nowrap;
  font-size: clamp(42px, 5vh, 88px);
}

/* === MODAL LAYER FIX DEFINITIF === */

.hidden{ display:none !important; }

#modalBackdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 9998;
}

#modal{
  position: fixed;
  left:50%;
  top:50%;
  transform: translate(-50%,-50%);
  width:min(920px, 94vw);
  max-height: 90vh;
  overflow:auto;
  background: var(--panel2);
  border:1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  z-index: 9999;   /* ABOVE EVERYTHING */
}

/* Prevent footer from floating above */
.section{
  position: relative;
  z-index: 1;
}

/* === MODAL HEADER === */

#modalHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding-bottom:8px;
  border-bottom:1px solid var(--border);
}

.modal-header-actions{
  display:flex;
  gap:10px;
}

.modal-header-actions button{
  min-height: 38px;   /* uniform height */
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
}

.btn-save{
  background: var(--accent);
  color:#111;
}

.btn-cancel{
  background:#3a3a3a;
}

.btn-reset{
  background:#1f1f1f;
}

/* === ROWS === */

.row{
  margin-top: 14px;
  padding: 12px;
  border:1px solid var(--border);
  border-radius: 12px;
  background:#141414;
}

.row label{
  display:block;
  font-weight:700;
  margin-bottom:8px;
}

.seg{
  display:flex;
  gap:18px;
  flex-wrap:wrap;
  color: var(--muted);
}

.quick{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

#grid{
  display:grid;
  grid-template-columns: repeat(13, 1fr);
  gap:8px;
}

.grid-item{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#101010;
}

/* === SHORTCUTS === */

.shortcuts-box {
  max-width:900px;
  margin:0 auto;
  padding:12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:rgba(255,255,255,0.03);
}

.shortcuts-hr{
  border:0;
  height:1px;
  background:var(--line);
  margin:10px 0;
}

.release-link{
  color: var(--accent);
  text-decoration:none;
}

.release-link:hover{
  text-decoration:underline;
}

/* === PRINT === */

@media print{
  html, body{
    height: auto;
    background: #fff !important;
    color: #000 !important;
  }

  #topbar,
  #sec-shortcuts,
  #modal,
  #modalBackdrop{
    display:none !important;
  }

  #app{
    display:block;
  }

  #letter{
    display:block;
    padding: 12mm 10mm;
    font-size: initial;
    color: var(--accent) !important;
    text-align:center;
  }

  .generator-output{
    display:block;
    width:100%;
    max-height:none;
    text-align:center;
    color: var(--accent) !important;
  }

  .generator-line{
    color: var(--accent) !important;
    font-size: 22pt;
    line-height: 1.08;
    letter-spacing: 0.08em;
    margin: 0 0 3mm 0;
    white-space: nowrap;
  }
}

/* === RESPONSIVE === */

@media (max-width: 900px){
  #grid{
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (max-width: 640px){
  #grid{
    grid-template-columns: repeat(6, 1fr);
  }

  .generator-line{
    font-size: clamp(30px, 4.6vh, 52px);
    letter-spacing: 0.06em;
    line-height: 0.95;
  }
}
