/* ═══════════════════════════════════════
   modals.css — Modals, sheets, overlays
   ═══════════════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.show { display: flex; animation: mIn 0.2s ease; }
@keyframes mIn { from{opacity:0} to{opacity:1} }

.modal-box {
  width: 100%; max-width: 440px; overflow: hidden;
  background: rgba(14,14,14,0.98); border: 1px solid var(--border2);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,0.8);
  position: relative;
}
/* Top accent line */
.modal-box::before {
  content: ''; position: absolute; top:0; left:0; right:0; height:1px;
  background: linear-gradient(90deg, transparent, var(--border3), transparent);
}

.modal-inner { padding: 20px; overflow-y: auto; max-height: calc(88vh - 2px); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text2);
}
.modal-close:hover { background: rgba(248,113,113,0.1); border-color: var(--red); color: var(--red); }
.modal-close svg { width: 14px; height: 14px; }

/* Credits modal */
.credits-balance-card {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r-lg); padding: 18px; text-align: center; margin-bottom: 14px;
}
.credits-balance-number { font-size: 44px; font-weight: 800; line-height: 1; }
.credits-balance-label  { font-size: 11px; color: var(--text3); margin-top: 4px; }
.credits-earn-btn {
  width: 100%; padding: 12px; border-radius: var(--r-md);
  background: var(--surface2); border: 1px solid var(--border2);
  font-size: 13px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-bottom: 14px; transition: background var(--t-fast);
}
.credits-earn-btn:hover { background: var(--surface3); }
.credits-earn-btn svg { width: 15px; height: 15px; }

/* History items */
.hist-item { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid var(--border); }
.hist-item:last-child { border-bottom:none; }
.hist-amount { font-size:13px; font-weight:700; min-width:36px; }
.hist-amount.earn  { color: var(--green); }
.hist-amount.spend { color: var(--red); }
.hist-reason { font-size:12px; flex:1; color:var(--text2); }
.hist-time   { font-size:10px; color:var(--text3); }

/* Settings form elements */
.s-group { margin-bottom: 16px; }
.s-label {
  display: block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text3); margin-bottom: 7px;
}
.s-input {
  width: 100%; padding: 9px 11px; border-radius: var(--r-md);
  font-size: 13px; background: var(--surface); border: 1px solid var(--border2); color: var(--text);
}
.s-input:focus { border-color: var(--border3); }
.s-select { width:100%; padding:9px 11px; border-radius:var(--r-md); font-size:13px; background:var(--surface); border:1px solid var(--border2); color:var(--text); }
.s-section { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.1em; color:var(--text3); margin:14px 0 10px; display:flex; align-items:center; gap:7px; }
.s-section::after { content:''; flex:1; height:1px; background:var(--border); }
.s-divider { height:1px; background:var(--border); margin:14px 0; }
.s-save-btn {
  width:100%; padding:11px; border-radius:var(--r-md);
  background:var(--text); color:var(--bg);
  font-size:13px; font-weight:700; border:none;
  margin-bottom:8px;
}
.s-save-btn:hover { opacity:0.9; }
.s-link { font-size:11px; color:var(--text2); text-decoration:underline; }

/* Diagram lightbox */
#diagram-lightbox .modal-box { max-width:560px; }
#lb-content { overflow:auto; max-height:60vh; margin-top:8px; }

/* Preview modal */
#preview-modal .modal-box { max-width:680px; }
#preview-content { overflow-y:auto; max-height:66vh; padding-top:8px; }
