/* =========================================================
   ✨ Modern Modals (Settings / About) – v0.10.27
   - Rounded card, SVG close, slide-up, drag-to-close, theme-aware
   ========================================================= */
:root{
  --modal-radius: 6px;
  --modal-overlay: rgba(0,0,0,0.45);
  --modal-bg: #e8eef8;
  --modal-border: #cad6e8;
  --modal-title: #1e1e1f;
  --modal-muted: #6b6b6f;
  --modal-shadow: 0 25px 60px rgba(0,0,0,0.25);
  --modal-divider: #d4deec;
}
html[data-theme="dark"]{
  --modal-bg: #131b2a;
  --modal-border: #2a2a2a;
  --modal-title: #f2f2f2;
  --modal-muted: #b7b7b7;
  --modal-divider: #2a2a2a;
  --modal-overlay: rgba(0,0,0,0.6);
  --modal-shadow: 0 30px 70px rgba(0,0,0,0.55);
}

.ep-modal-overlay{
  position:fixed; inset:0; z-index: 90;
  display:none;
  background: var(--modal-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items:center; justify-content:center;
  padding: 12px;
}
.ep-modal-overlay.is-open{ display:flex; animation: epFadeIn 0.16s ease-out; }
@keyframes epFadeIn{ from{opacity:0} to{opacity:1} }

.ep-modal-card{
  width: min(760px, 100%);
  max-height: 82vh;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  overflow:hidden;
  display:flex; flex-direction:column;
  transform: translateY(16px);
  opacity: 0;
  animation: epSlideUp 0.18s ease-out forwards;
  touch-action: manipulation;
}
@keyframes epSlideUp{
  from{ transform: translateY(18px); opacity:0 }
  to{ transform: translateY(0); opacity:1 }
}
.ep-modal-card.is-closing{
  animation: epSlideDown 0.16s ease-in forwards;
}
@keyframes epSlideDown{
  from{ transform: translateY(0); opacity:1 }
  to{ transform: translateY(18px); opacity:0 }
}

.ep-modal-header{
  display:flex; align-items:center; justify-content:space-between;
  gap:12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--modal-divider);
  background: linear-gradient(180deg, rgba(255,255,255,0.70), rgba(255,255,255,0.34));
}
.ep-modal-card{ background: linear-gradient(180deg, rgba(232,238,248,0.98), rgba(225,233,245,0.98)); }
html[data-theme="dark"] .ep-modal-card{ background: linear-gradient(180deg, rgba(19,27,42,0.98), rgba(17,24,38,0.98)); }
html[data-theme="dark"] .ep-modal-header{ background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02)); }
.ep-modal-header-left{
  display:flex; align-items:center; gap:10px; min-width:0;
}
.ep-modal-appicon{ width:42px; height:42px; border-radius: 5px; }
.ep-modal-titles{ display:flex; flex-direction:column; min-width:0; }
.ep-modal-title{
  font-weight: 800;
  font-size: 17px;
  line-height: 1.05;
  color: var(--modal-title);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.ep-modal-subtitle{
  font-size: 11px;
  color: var(--modal-muted);
  margin-top: 2px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

.ep-close-btn{
  width: 38px; height: 38px;
  display:inline-flex; align-items:center; justify-content:center;
  border-radius: 5px;
  border: 1px solid var(--modal-border);
  background: rgba(255,255,255,0.35);
  cursor:pointer;
  color:#444;
  opacity: 0.9;
  transition:
    background 0.25s ease,
    transform 0.2s ease,
    color 0.25s ease,
    opacity 0.15s ease,
    box-shadow 0.25s ease;
}
html[data-theme="dark"] .ep-close-btn{
  background: rgba(255,255,255,0.06);
  color:#ccc;
}

.ep-close-btn svg{
  width:18px; height:18px;
  fill:none;
  stroke: currentColor;
  stroke-width:2.6;
  stroke-linecap:round;
  transition:
    color 0.25s ease,
    transform 0.25s ease;
}

/* 🔴 Hover: red + glow + subtle rotation */
.ep-close-btn:hover{
  background: rgba(255,0,0,0.12);
  color:#ff2d2d;
  box-shadow: 0 0 2px rgba(255,0,0,0.35);
  transform: scale(1.06);
  opacity:1;
}
.ep-close-btn:hover svg{
  transform: rotate(90deg);
}

html[data-theme="dark"] .ep-close-btn:hover{
  background: rgba(255,60,60,0.18);
  color:#ff5252;
  box-shadow: 0 0 14px rgba(255,70,70,0.45);
}

/* 👇 Active press */
.ep-close-btn:active{
  transform: scale(0.90);
}

.ep-close-btn svg path{ stroke: var(--modal-title); stroke-width: 2.6; stroke-linecap: round; }

.ep-modal-body{
  padding: 12px 14px 14px 14px;
  overflow:auto;
  background: linear-gradient(180deg, rgba(236,242,250,0.95), rgba(228,236,248,0.95));
}
html[data-theme="dark"] .ep-modal-body{ background: linear-gradient(180deg, rgba(22,31,48,0.94), rgba(17,24,38,0.94)); }

/* Settings compact 2-column grid */
.ep-settings-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 820px){
  .ep-settings-grid{ grid-template-columns: 1fr; }
}
.ep-card{
  border: 1px solid var(--modal-border);
  border-radius: 6px;
  padding: 10px 11px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(250,252,255,0.88));
  box-shadow: 0 8px 24px rgba(37,99,235,0.08);
}
html[data-theme="dark"] .ep-card{ background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.035)); box-shadow:none; }

.ep-card h3{
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 800;
  color: #24446f;
}
html[data-theme="dark"] .ep-card h3{ color:#bcd4ff; }

/* Make inputs a touch smaller inside modals */
.ep-modal-body input, .ep-modal-body select, .ep-modal-body button{
  height: 28px;
  font-size: 12px;
  border-radius: 5px;
  font: inherit;
  font-family: inherit;
}
.ep-modal-body input[type="checkbox"], .ep-modal-body input[type="radio"]{
  height:auto;
}

.ep-modal-body input.ui-switch{
  appearance:none;
  -webkit-appearance:none;
  width:28px;
  height:15px;
  min-width:28px;
  max-width:28px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,0.14);
  box-shadow:none;
  position:relative;
  cursor:pointer;
  flex:0 0 28px;
}

.ep-modal-body input.ui-switch::after{
  content:"";
  position:absolute;
  top:1px;
  left:1px;
  width:11px;
  height:11px;
  border-radius:999px;
  background:#fff;
  box-shadow:0 1px 4px rgba(15,23,42,0.20);
  transition:transform .16s ease;
}

.ep-header-actions{
  display:flex; gap:8px; align-items:center;
}
.ep-btn{
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  cursor:pointer;
  border-radius: 5px;
  font-weight: 700;
}
.ep-btn.primary{ font-weight: 900; }

.ep-settings-stack{
  display:grid;
  gap:10px;
}

.ep-settings-grid-top{
  align-items:start;
}

.ep-card-tight{
  padding: 10px;
}

.ep-inline-metrics{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:10px;
  justify-items:start;
}

.ep-metric-field{
  display:grid;
  gap:4px;
  font-size:11.5px;
  color:var(--modal-muted);
  width:100%;
}

.ep-metric-field input{
  width:66px;
  min-width:66px;
  max-width:66px;
}

.ep-settings-table{
  display:grid;
  grid-template-columns: minmax(220px, 280px) minmax(136px, 136px);
  gap:8px 10px;
  align-items:center;
  justify-content:start;
  width:fit-content;
  max-width:100%;
}

.ep-check-label{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:11.5px;
  min-width:0;
}

.ep-switch-row{
  justify-content:flex-start;
  gap:8px;
}

.ep-check-label span{
  min-width:0;
}

.ep-settings-table > input{
  width:100%;
}

.ep-value-pair{
  display:grid;
  grid-template-columns: 1fr 56px;
  gap:6px;
  align-items:center;
  font-size:11.5px;
  color:var(--modal-muted);
}

.ep-settings-table > input,
.ep-value-pair input{
  font-size:11.5px;
}

.ep-input-suffix{
  display:grid;
  grid-template-columns: 56px auto;
  align-items:center;
  gap:9px;
  font-size:11.5px;
  color:var(--modal-muted);
}

.ep-input-suffix input{
  width:56px;
  min-width:56px;
  max-width:56px;
}

.ep-input-suffix span{
  white-space:nowrap;
}


.ep-settings-note{
  margin-top:8px;
  font-size:11.5px;
  line-height:1.4;
  color:var(--modal-muted);
}

.ep-section{
  padding:0;
  overflow:hidden;
}

.ep-section summary{
  list-style:none;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 11px;
  cursor:pointer;
  user-select:none;
  font-size:13px;
  font-weight:800;
  color:var(--modal-title);
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,255,255,0.60));
}
html[data-theme="dark"] .ep-section summary{ background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)); }

.ep-section summary::-webkit-details-marker{
  display:none;
}

.ep-section[open] summary{
  border-bottom:1px solid var(--modal-divider);
}

.ep-section-hint{
  display:inline-flex;
  align-items:center;
  gap:7px;
  padding:3px 7px;
  border-radius:999px;
  font-size:11px;
  font-weight:700;
  color:var(--modal-muted);
  background:rgba(36,68,111,0.08);
  border:1px solid rgba(36,68,111,0.10);
}
.ep-section-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:16px;
  height:16px;
  border-radius:999px;
  font-size:10px;
  line-height:1;
  color:#fff;
  background:linear-gradient(180deg, #3b82f6, #2563eb);
  box-shadow:0 4px 10px rgba(37,99,235,0.22);
}
.ep-section-range summary > span:first-child{ color:#1f5fbf; }
.ep-section-display summary > span:first-child{ color:#3b4f8a; }
.ep-section-compare summary > span:first-child{ color:#915b14; }
.ep-section-details summary > span:first-child{ color:#48606f; }

.ep-section-range .ep-section-hint{
  color:#1f5fbf;
  background:rgba(59,130,246,0.10);
  border-color:rgba(59,130,246,0.16);
}
.ep-section-range .ep-section-icon{ background:linear-gradient(180deg, #60a5fa, #2563eb); }

.ep-section-display .ep-section-hint{
  color:#4f46e5;
  background:rgba(99,102,241,0.10);
  border-color:rgba(99,102,241,0.16);
}
.ep-section-display .ep-section-icon{ background:linear-gradient(180deg, #818cf8, #4f46e5); }

.ep-section-compare .ep-section-hint{
  color:#b45309;
  background:rgba(245,158,11,0.12);
  border-color:rgba(245,158,11,0.18);
}
.ep-section-compare .ep-section-icon{ background:linear-gradient(180deg, #f59e0b, #d97706); }

.ep-section-details .ep-section-hint{
  color:#0f766e;
  background:rgba(20,184,166,0.12);
  border-color:rgba(20,184,166,0.18);
}
.ep-section-details .ep-section-icon{ background:linear-gradient(180deg, #14b8a6, #0f766e); }

.ep-section-body{
  display:grid;
  gap:12px;
  padding:10px 11px 11px 11px;
}

.ep-form-grid{
  display:grid;
  gap:8px 10px;
}

.ep-form-grid-2{
  grid-template-columns: 1fr 1fr;
}

.ep-form-grid-3{
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ep-block{
  display:grid;
  gap:8px;
}

.ep-subheading{
  font-size:11px;
  font-weight:800;
  letter-spacing:0.02em;
  text-transform:uppercase;
  color:var(--modal-muted);
}

.ep-option-list{
  display:grid;
  gap:7px;
}

.ep-radio-row,
.ep-field-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  font-size:12px;
}

.ep-field-row span{
  color:var(--modal-muted);
}

.ep-field-row input,
.ep-field-row select{
  width:110px;
  max-width:48%;
}

.ep-field-row-inline{
  justify-content:flex-start;
}

.ep-field-row-inline input,
.ep-field-row-inline select{
  width:72px;
  max-width:none;
}

.ep-section-range .ep-form-grid-2{
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 330px);
  align-items:start;
}

.ep-section-range .ep-block{
  align-content:start;
}

.ep-section-range .ep-option-list{
  gap:9px;
}

.ep-section-range .ep-radio-row{
  justify-content:flex-start;
  gap:12px;
  min-height:38px;
}

.ep-section-range .ep-field-row{
  display:grid;
  grid-template-columns: minmax(132px, 1fr) auto;
  align-items:center;
  gap:10px 12px;
}

.ep-section-range .ep-field-row input,
.ep-section-range .ep-field-row select{
  width:110px;
  max-width:none;
}

.ep-section-range .ep-preset-row{
  padding-top:2px;
}

.ep-preset-row{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
  font-size:11.5px;
  color:var(--modal-muted);
}

.ep-preset-row .preset-btn{
  height:24px;
  min-width:34px;
  padding:0 8px;
}

.ep-display-mode{
  display:grid;
  gap:8px;
}

.ep-radio-chip,
.ep-check-chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:26px;
  padding:4px 8px;
  border:1px solid var(--modal-border);
  border-radius:4px;
  background:rgba(255,255,255,0.18);
  font-size:12px;
}

html[data-theme="dark"] .ep-radio-chip,
html[data-theme="dark"] .ep-check-chip{
  background:rgba(255,255,255,0.03);
}

.ep-inline-note{
  font-size:11.5px;
  color:var(--modal-muted);
}

.ep-chip-grid{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.ep-inline-group{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px 10px;
  font-size:12px;
  color:var(--modal-muted);
}

.ep-area-grid{
  display:grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap:8px 12px;
  font-size:12px;
}

.ep-area-grid label{
  display:flex;
  align-items:center;
  gap:7px;
}

.ep-check-chip .ui-switch,
.ep-switch-row .ui-switch,
.ep-area-grid .ui-switch{
  margin:0;
  flex:0 0 auto;
}

@media (max-width: 820px){
  .ep-form-grid-2,
  .ep-form-grid-3{
    grid-template-columns: 1fr 1fr;
  }

  .ep-section-range .ep-form-grid-2{
    grid-template-columns: 1fr 1fr;
  }

  .ep-area-grid{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px){
  .ep-modal-card{
    width:min(100%, 640px);
    max-height: 88vh;
  }

  .ep-modal-header{
    align-items:flex-start;
  }

  .ep-modal-subtitle{
    white-space:normal;
    overflow:visible;
  }

  .ep-header-actions{
    flex-wrap:wrap;
    justify-content:flex-end;
  }

  .ep-form-grid-2,
  .ep-form-grid-3{
    grid-template-columns: 1fr;
  }

  .ep-section-range .ep-form-grid-2{
    grid-template-columns: 1fr;
  }

  .ep-section-range .ep-form-grid-2 > .ep-block{
    min-width:0;
  }

  .ep-section-range .ep-form-grid-2 > .ep-block:last-child .ep-option-list{
    display:grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap:10px 12px;
    align-items:start;
  }

  .ep-section-range .ep-form-grid-2 > .ep-block:last-child .ep-field-row{
    display:grid;
    grid-template-columns: 1fr;
    justify-items:start;
    align-items:start;
    gap:4px;
  }

  .ep-section-range .ep-form-grid-2 > .ep-block:last-child .ep-field-row span{
    width:100%;
    text-align:left;
  }

  .ep-section-range .ep-form-grid-2 > .ep-block:last-child .ep-field-row input,
  .ep-section-range .ep-form-grid-2 > .ep-block:last-child .ep-field-row select{
    width:100%;
    min-width:0;
    max-width:none;
  }

  .ep-section-range .ep-form-grid-2 > .ep-block:last-child .ep-preset-row,
  .ep-section-range .ep-form-grid-2 > .ep-block:last-child .ep-inline-note{
    grid-column:1 / -1;
  }

  .ep-inline-metrics{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ep-settings-table{
    grid-template-columns: minmax(180px, 1fr) minmax(136px, 136px);
    gap:8px 10px;
    align-items:center;
  }

  .ep-area-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ep-value-pair,
  .ep-field-row{
    grid-template-columns: none;
  }

  .ep-field-row{
    flex-direction:column;
    align-items:flex-start;
  }

  .ep-section-range .ep-radio-row,
  .ep-section-range .ep-field-row{
    min-height:auto;
  }

  .ep-section-range .ep-field-row{
    display:flex;
    gap:8px;
  }

  .ep-field-row input,
  .ep-field-row select,
  .ep-field-row-inline input,
  .ep-field-row-inline select{
    width:100%;
    max-width:none;
  }
}

@media (max-width: 480px){
  .ep-section-range .ep-form-grid-2 > .ep-block:last-child .ep-option-list{
    grid-template-columns: 1fr;
  }

  .ep-section-range .ep-form-grid-2 > .ep-block:last-child .ep-preset-row{
    gap:6px;
  }
}
