:root {
  --bg: #0e0f17;
  --bg2: #161827;
  --card: #1b1e30;
  --card2: #21263c;
  --line: #2c3350;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --pink: #ff2d55;
  --gold: #ffd54a;
  --green: #36d399;
  --red: #f87272;
  --amber: #fbbd23;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 45, 85, 0.12), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(91, 140, 255, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

a { color: var(--gold); }
code { background: rgba(255, 255, 255, 0.08); padding: 1px 5px; border-radius: 5px; font-size: 0.92em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- header ---- */
.hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px; gap: 16px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.hd-left { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  font-size: 26px; color: #fff;
  background: linear-gradient(135deg, var(--pink), #b3204a);
  box-shadow: 0 8px 24px rgba(255, 45, 85, 0.35);
}
.hd h1 { margin: 0; font-size: 22px; letter-spacing: 0.2px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #666; box-shadow: 0 0 8px #666; }
.dot.ok { background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot.bad { background: var(--red); box-shadow: 0 0 10px var(--red); }
.dot.warn { background: var(--amber); box-shadow: 0 0 10px var(--amber); }

/* ---- gallery grid ---- */
.grid {
  display: grid; gap: 20px; padding: 28px;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  max-width: 1200px; margin: 0 auto;
}
.card {
  background: linear-gradient(180deg, var(--card), var(--card2));
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45); border-color: #3b4470; }
.card-preview {
  position: relative; height: 230px; background: #0b0c14;
  border-bottom: 1px solid var(--line); overflow: hidden;
}
.card-preview iframe {
  position: absolute; top: 50%; left: 50%; border: 0;
  transform-origin: center center; pointer-events: none;
}
.card-preview .badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  background: rgba(0, 0, 0, 0.55); border: 1px solid var(--line);
  color: var(--gold); font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
}
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-name { font-size: 17px; font-weight: 800; margin: 0; }
.card-tag { color: var(--muted); font-size: 12.5px; margin: -2px 0 0; }
.card-desc { color: var(--muted); font-size: 13px; line-height: 1.5; flex: 1; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; color: var(--muted); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }
.card-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ---- buttons ---- */
.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer;
  background: linear-gradient(180deg, var(--pink), #cf2348); color: #fff;
  font-weight: 700; font-size: 13.5px; padding: 9px 14px; border-radius: 10px;
  transition: filter 0.12s, transform 0.05s; display: inline-flex; align-items: center;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; justify-content: center; }
.btn:focus-visible, .cfg-input:focus-visible, .cfg-switch:focus-visible,
.cfg-range input:focus-visible, .cfg-tags-input:focus-visible, .cfg-chip button:focus-visible,
#obsUrl:focus-visible, a:focus-visible {
  outline: 3px solid #8db9ff;
  outline-offset: 2px;
}

/* ---- configurator ---- */
.cfg { max-width: 1200px; margin: 0 auto; padding: 16px 28px 40px; }
.cfg-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cfg-title { font-size: 18px; font-weight: 800; }
.cfg-bar-spacer { flex: 1; }
.cfg-body { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .cfg-body { grid-template-columns: 1fr; } }

.cfg-preview { position: sticky; top: 16px; }
.preview-frame {
  background:
    repeating-conic-gradient(#1a1c2b 0% 25%, #15172400 0% 50%) 0 / 24px 24px,
    #12131d;
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  height: 560px; display: grid; place-items: center;
}
.preview-frame iframe { width: 100%; height: 100%; border: 0; background: transparent; }
.preview-demo { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 10px; }

.cfg-panel { display: flex; flex-direction: column; gap: 18px; }
#form { display: flex; flex-direction: column; gap: 14px; }

/* ---- url box ---- */
.url-box { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: rgba(255, 255, 255, 0.02); }
.url-label { font-weight: 800; font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.hintdot { width: 16px; height: 16px; border-radius: 50%; background: var(--line); color: var(--text); font-size: 11px; display: inline-grid; place-items: center; cursor: help; }
#obsUrl { width: 100%; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--gold); background: #11131f; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.url-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.url-note { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; line-height: 1.5; }
.connection-notice {
  color: var(--text); font-size: 12.5px; line-height: 1.5; margin-bottom: 14px;
  padding: 10px 12px; border: 1px solid rgba(251, 189, 35, 0.45); border-radius: 10px;
  background: rgba(251, 189, 35, 0.09);
}
.connection-notice strong { color: var(--gold); }
.toast { position: fixed; z-index: 30; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--green); color: #04210f; font-weight: 800; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.ft { text-align: center; color: var(--muted); font-size: 12.5px; padding: 22px; border-top: 1px solid var(--line); }
.hidden { display: none !important; }

/* ---- Settings dialog (the configurator form) — dark, CJP-style layout ---- */
.cfg-dialog {
  background: linear-gradient(180deg, var(--card), var(--card2)); color: var(--text);
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
}
.cfg-dialog-head {
  background: rgba(255, 255, 255, 0.04); color: var(--text); font-weight: 800; font-size: 16px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.cfg-dialog-body { padding: 4px 18px 18px; max-height: 72vh; overflow-y: auto; }
.cfg-sec { padding: 2px 0; margin: 0; border: 0; min-width: 0; }
.cfg-sec-head {
  color: #6aa8ff; font-size: 14px; font-weight: 800; letter-spacing: 0.02em;
  margin: 24px 0 8px; padding: 0 0 5px; border-bottom: 1px solid var(--line);
  width: 100%; float: left;
}
.cfg-sec > .cfg-field:first-of-type { clear: both; }
.cfg-sec:first-child .cfg-sec-head { margin-top: 10px; }
.cfg-sec.hl .cfg-sec-head { color: var(--gold); }   /* this project's added sections */

.cfg-field {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 5px 0; min-height: 38px;
}
.cfg-field-label-wrap { color: var(--muted); font-size: 13.5px; flex: 1 1 auto; min-width: 0; }
.cfg-field-label { color: inherit; cursor: pointer; }
.cfg-field-value { flex: 0 1 250px; width: 250px; max-width: 250px; min-width: 0; display: flex; justify-content: flex-end; }
.cfg-input {
  width: 250px; max-width: 100%; background: #11131f; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font: inherit; font-size: 13.5px; color: var(--text);
}
.cfg-input:focus { border-color: #6aa8ff; box-shadow: 0 0 0 2px rgba(106, 168, 255, 0.22); }
select.cfg-input { cursor: pointer; }
.cfg-input option { background: #11131f; color: var(--text); }
.cfg-switch { width: 20px; height: 20px; accent-color: var(--pink); cursor: pointer; margin: 0; }
.cfg-range { width: 250px; max-width: 100%; display: flex; align-items: center; gap: 10px; }
.cfg-range input[type=range] { flex: 1; min-width: 0; accent-color: var(--pink); }
.cfg-range-val { min-width: 40px; text-align: right; color: var(--gold); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.cfg-tags {
  width: 250px; max-width: 100%; min-height: 38px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
  background: #11131f; border: 1px solid var(--line); border-radius: 8px; padding: 5px 7px;
}
.cfg-tags:focus-within { border-color: #6aa8ff; box-shadow: 0 0 0 2px rgba(106, 168, 255, 0.22); }
.cfg-tags-input { flex: 1; min-width: 70px; border: 0; font: inherit; font-size: 13px; background: transparent; color: var(--text); }
.cfg-chip { display: inline-flex; align-items: center; gap: 5px; background: rgba(106, 168, 255, 0.16); color: #9cc4ff; border: 1px solid rgba(106, 168, 255, 0.35); border-radius: 999px; padding: 2px 5px 2px 9px; font-size: 12.5px; }
.cfg-chip button { border: 0; background: transparent; color: #9cc4ff; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.cfg-hidden { display: none !important; }

@media (max-width: 600px) {
  .hd { padding: 16px; }
  .grid { padding: 16px; }
  .cfg { padding: 12px 12px 28px; }
  .cfg-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
  .cfg-bar-spacer { display: none; }
  .cfg-title { text-align: right; align-self: center; font-size: 16px; overflow-wrap: anywhere; }
  #testBtn { grid-column: 1; justify-content: center; }
  #resetBtn { grid-column: 2; justify-content: center; }
  .cfg-preview { position: static; }
  .preview-frame { height: min(500px, 64vh); min-height: 380px; }
  .cfg-dialog-body { max-height: none; overflow: visible; padding: 4px 14px 16px; }
  .cfg-field:not(.is-check) { flex-direction: column; align-items: stretch; gap: 6px; }
  .cfg-field-value, .cfg-input, .cfg-range, .cfg-tags { width: 100%; max-width: 100%; flex-basis: auto; }
  .cfg-field.is-check .cfg-field-value { flex: 0 0 auto; width: auto; }
  .url-box { padding: 12px; }
  .url-actions .btn { flex: 1 1 140px; justify-content: center; }
  .ft { padding: 18px 14px; overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .btn, .toast { transition: none; }
  .card:hover { transform: none; }
}
