/* Settings admin page — opened on the laptop, never on the TV */
:root {
  --bg: #0c1418; --card: #13212a; --edge: #24333d; --ink: #f0ece0; --dim: #9fb0bb;
  --gold: #e9c873; --btn: #1c2c36; --ok: #6fcf97;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Cairo", system-ui, sans-serif; line-height: 1.5;
}
.s-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: #0a1216; border-bottom: 1px solid var(--edge);
}
.s-head h1 { font-size: 22px; margin: 0; }
.s-head-right { display: flex; align-items: center; gap: 16px; }
.status { color: var(--ok); font-size: 14px; min-width: 60px; transition: opacity .3s; opacity: 0; }
.status.show { opacity: 1; }
.open-display { color: var(--gold); text-decoration: none; font-weight: 600; font-size: 15px; }
.open-display:hover { text-decoration: underline; }

.s-layout { display: flex; max-width: 1000px; margin: 0 auto; align-items: flex-start; }
.s-nav { position: sticky; top: 70px; width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; padding: 22px 12px; }
.s-nav button { text-align: start; background: none; border: none; color: var(--dim); padding: 11px 15px; border-radius: 10px; font-family: inherit; font-size: 15px; cursor: pointer; }
.s-nav button:hover { background: var(--btn); color: var(--ink); }
.s-nav button.active { background: var(--gold); color: #0c1418; font-weight: 700; }
.s-main { flex: 1; min-width: 0; padding: 22px 18px 80px; }
.s-section { display: none; flex-direction: column; gap: 18px; }
.s-section.active { display: flex; }
@media (max-width: 680px) { .s-layout { flex-direction: column; } .s-nav { position: static; width: auto; flex-direction: row; flex-wrap: wrap; } }
.card { background: var(--card); border: 1px solid var(--edge); border-radius: 14px; padding: 20px 22px; }
.card h2 { margin: 0 0 14px; font-size: 19px; color: var(--gold); }
.hint { color: var(--dim); font-size: 13px; margin: -6px 0 14px; }

.field { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; flex-wrap: wrap; }
.field > label { font-size: 15px; color: var(--ink); }

/* segmented control */
.seg { display: inline-flex; background: var(--btn); border: 1px solid var(--edge); border-radius: 10px; overflow: hidden; }
.seg button { background: none; border: none; color: var(--dim); padding: 8px 14px; font-family: inherit; font-size: 14px; cursor: pointer; }
.seg button.active { background: var(--gold); color: #0c1418; font-weight: 700; }

/* Apple-style toggle switch */
.tgl { position: relative; display: inline-flex; cursor: pointer; flex-shrink: 0; }
.tgl input { position: absolute; opacity: 0; width: 0; height: 0; }
.tgl-track { position: relative; width: 46px; height: 28px; border-radius: 999px; background: #3a4651; transition: background .2s; }
.tgl-track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tgl input:checked + .tgl-track { background: var(--ok); }
.tgl input:checked + .tgl-track::after { transform: translateX(-18px); }

.btn { background: var(--btn); color: var(--ink); border: 1px solid var(--edge); border-radius: 10px; padding: 9px 16px; font-family: inherit; font-size: 14px; cursor: pointer; }
.btn:hover { border-color: var(--gold); }
.btn-edit { display: inline-block; background: var(--gold); color: #0c1418; font-weight: 700; border: none; text-decoration: none; padding: 11px 20px; border-radius: 10px; font-size: 15px; margin-bottom: 10px; }
.btn-edit:hover { filter: brightness(1.07); }
.num { width: 90px; background: var(--btn); border: 1px solid var(--edge); color: var(--ink); border-radius: 8px; padding: 7px 10px; font-family: inherit; font-size: 15px; }
input[type=range] { accent-color: var(--gold); width: 200px; }
.rangeval { color: var(--gold); font-size: 13px; }
textarea { width: 100%; background: var(--btn); border: 1px solid var(--edge); color: var(--ink); border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 15px; resize: vertical; }

/* colour swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; width: 46px; height: 46px; border-radius: 10px; border: 3px solid transparent; cursor: pointer; }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.swatch-x { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; line-height: 16px; text-align: center; border-radius: 50%; background: #0a1216; color: #fff; font-size: 12px; border: 1px solid var(--edge); }
.swatch-add { display: flex; align-items: center; justify-content: center; background: var(--btn); border: 2px dashed var(--edge); color: var(--dim); font-size: 22px; overflow: hidden; position: relative; }
.swatch-add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* prayer-time rows */
.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.row-head, .row-item { display: grid; grid-template-columns: 32px minmax(70px,1fr) 148px 90px 46px 64px 28px; gap: 8px; align-items: center; }
.row-head { padding: 2px 10px 6px; color: var(--dim); font-size: 12px; }
.row-head span { text-align: center; }
.row-head span:nth-child(2) { text-align: start; }
.row-item { background: var(--btn); border: 1px solid var(--edge); border-radius: 10px; padding: 8px 10px; }
.row-item .ord { display: flex; flex-direction: column; }
.row-item .ord button { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 12px; line-height: 1; padding: 1px; }
.row-item input[type=text] { width: 100%; background: var(--card); border: 1px solid var(--edge); color: var(--ink); border-radius: 7px; padding: 6px 8px; font-family: inherit; }
.row-item select { width: 100%; background: var(--card); border: 1px solid var(--edge); color: var(--ink); border-radius: 7px; padding: 6px 6px; font-family: inherit; font-size: 13px; }
.row-item .chk { justify-content: center; }
.key-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.key-cell input[type=time] { width: 100%; background: var(--card); border: 1px solid var(--edge); color: var(--ink); border-radius: 7px; padding: 5px 6px; font-family: inherit; font-size: 12px; cursor: pointer; direction: ltr; text-align: center; }
.key-cell input[type=time]:hover { border-color: var(--gold); }
.key-cell input[type=time]::-webkit-calendar-picker-indicator { filter: invert(0.85); opacity: 0.8; cursor: pointer; }
.lib-collbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--btn); border: 1px solid var(--edge); border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--dim); }
.lib-collbar.on { border-color: var(--gold); color: var(--ink); }
.lib-collbar b { color: var(--gold); }

/* text-groups compact rows + preview modal */
.tg-row { display: grid; grid-template-columns: 34px minmax(80px,1fr) 56px 116px 80px 26px 26px 44px; gap: 8px; align-items: center; background: var(--btn); border: 1px solid var(--edge); border-radius: 10px; padding: 8px 10px; }
.tg-rowhead { display: grid; grid-template-columns: 34px minmax(80px,1fr) 56px 116px 80px 26px 26px 44px; gap: 8px; align-items: center; padding: 2px 10px; font-size: 11px; font-weight: 700; color: var(--dim); }
.tg-detail { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin-top: -6px; background: var(--card); border: 1px dashed var(--edge); border-radius: 8px; }
.tg-detail .tg-detail-lbl { font-size: 12px; color: var(--dim); }
.tg-detail input, .tg-detail select { background: var(--btn); border: 1px solid var(--edge); color: var(--ink); border-radius: 7px; padding: 6px 8px; font-family: inherit; font-size: 13px; }
.tg-detail .tg-cd-day { width: 54px; text-align: center; }
.tg-detail .tg-cd-name { flex: 1; min-width: 150px; }
.tg-row .tg-nm { font-weight: 600; }
.tg-count { font-size: 12px; color: var(--dim); text-align: center; }
.tg-prev { background: var(--card); border: 1px solid var(--edge); color: var(--gold); border-radius: 7px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 6px; }
.tg-row select { width: 100%; background: var(--card); border: 1px solid var(--edge); color: var(--ink); border-radius: 7px; padding: 5px 4px; font-family: inherit; font-size: 12px; }
.tg-icon-btn { background: none; border: none; color: var(--dim); cursor: pointer; text-decoration: none; font-size: 15px; text-align: center; padding: 0; }
.tg-icon-btn.tg-del { color: #e0807f; }
.txt-box { width: 600px; max-width: 100%; }
.txt-list { padding: 14px 20px; overflow: auto; max-height: 38vh; display: flex; flex-direction: column; gap: 7px; }
.txt-line { display: flex; gap: 10px; font-size: 15px; line-height: 1.6; }
.txt-no { color: var(--gold); min-width: 24px; text-align: end; font-weight: 700; }
.txt-edit-wrap { padding: 0 20px 10px; display: flex; flex-direction: column; gap: 6px; }
.row-item .del { margin: 0; justify-self: center; }
.row-item label.chk { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--dim); }
.row-item .del { margin-inline-start: auto; background: none; border: none; color: #e0807f; font-size: 18px; cursor: pointer; }
.icon-pick { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.ip { width: 30px; height: 30px; padding: 0; border-radius: 6px; border: 2px solid transparent; cursor: pointer; background-color: var(--gold); -webkit-mask-size: 78%; mask-size: 78%; -webkit-mask-position: center; mask-position: center; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.ip.ip-auto { width: auto; height: 30px; padding: 0 8px; background: var(--btn); color: var(--dim); font-size: 11px; -webkit-mask-image: none; mask-image: none; }
.ip.on { border-color: #fff; }

/* background image grid */
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.bg-tile { position: relative; aspect-ratio: 16/10; border-radius: 10px; border: 3px solid transparent; background-size: cover; background-position: center; cursor: pointer; }
.bg-tile.active { border-color: var(--gold); }
.bg-tile .check { position: absolute; top: 6px; inset-inline-end: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--gold); color: #0c1418; font-weight: 700; display: none; align-items: center; justify-content: center; }
.bg-tile.active .check { display: flex; }
#mosqueIcons .bg-tile { aspect-ratio: 1; background-size: contain; background-repeat: no-repeat; background-color: #0a1216; }

/* ---- asset summary rows + per-row icon button ---- */
.asset-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.asset-cur { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 14px; }
.asset-cur .muted { color: var(--dim); }
.asset-cur .thumb { width: 96px; height: 56px; border-radius: 8px; background: #0e1a22 center/cover no-repeat; border: 1px solid var(--edge); flex-shrink: 0; }
.btn-browse { background: var(--gold); color: #0c1418; border: none; font-weight: 700; }
.row-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 9px; border: 1px solid var(--edge); cursor: pointer; background-color: var(--gold); -webkit-mask-size: 72%; mask-size: 72%; -webkit-mask-position: center; mask-position: center; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.row-icon:not(.has) { background: var(--btn); color: var(--dim); font-size: 10px; -webkit-mask-image: none; mask-image: none; }
.row-icon:hover { border-color: var(--gold); }

/* ---- shared asset-library modal ---- */
.lib { position: fixed; inset: 0; z-index: 200; background: rgba(4,8,11,.62); display: flex; align-items: center; justify-content: center; padding: 24px; }
.lib[hidden] { display: none; }
.lib-box { width: 780px; max-width: 100%; max-height: 88vh; background: var(--card); border: 1px solid var(--edge); border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; }
.lib-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--edge); }
.lib-head span { font-size: 18px; color: var(--gold); font-weight: 700; }
.lib-x { background: none; border: none; color: var(--dim); font-size: 20px; cursor: pointer; }
.lib-tabs { display: flex; gap: 8px; padding: 14px 20px 4px; flex-wrap: wrap; }
.lib-tab { background: var(--btn); color: var(--dim); border: 1px solid var(--edge); border-radius: 999px; padding: 6px 14px; font-family: inherit; font-size: 13px; cursor: pointer; }
.lib-tab.on { background: var(--gold); color: #0c1418; border-color: var(--gold); font-weight: 700; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; padding: 16px 20px; overflow: auto; }
.lib-tile { background: #0e1a22; border: 2px solid var(--edge); border-radius: 12px; padding: 10px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; font-family: inherit; }
.lib-tile:hover { border-color: var(--dim); }
.lib-tile.on { border-color: var(--gold); }
.lib-thumb { width: 100%; height: 76px; border-radius: 8px; background: #142028 center/cover no-repeat; }
.lib-ico { width: 56px; height: 56px; background-color: var(--gold); -webkit-mask-size: contain; mask-size: contain; -webkit-mask-position: center; mask-position: center; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.lib-auto { background: var(--btn); color: var(--dim); -webkit-mask: none; mask: none; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 26px; }
.lib-nm { font-size: 12px; color: var(--ink); text-align: center; word-break: break-word; line-height: 1.3; }
.lib-empty { grid-column: 1 / -1; color: var(--dim); text-align: center; padding: 36px 10px; }
.lib-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--edge); }
.lib-sp { flex: 1; }
.btn-done { background: var(--gold); color: #0c1418; border: none; font-weight: 700; }

/* layout drag canvas */
.lay-canvas { position: relative; width: 100%; aspect-ratio: 16/9; background: #0a1216; border: 1px solid var(--edge); border-radius: 10px; overflow: hidden; margin-bottom: 12px; touch-action: none; }
.lay-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.lay-box { position: absolute; z-index: 2; transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center; text-align: center; padding: 2px; box-sizing: border-box; background: rgba(233,200,115,.2); backdrop-filter: blur(2px); border: 1.5px solid var(--gold); color: var(--gold); border-radius: 7px; font-size: 13px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.85); cursor: grab; }
.lay-box:active { cursor: grabbing; background: rgba(233,200,115,.32); }
.lay-box.blocked { border-color: #e0807f; background: rgba(224,128,127,.32); color: #ffd9d8; cursor: not-allowed; }
.lay-guide { position: absolute; background: #6ab0f3; box-shadow: 0 0 4px #6ab0f3; pointer-events: none; z-index: 5; }
.lay-guide.v { width: 2px; top: 0; bottom: 0; transform: translateX(-1px); }
.lay-guide.h { height: 2px; left: 0; right: 0; transform: translateY(-1px); }
.align-list { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.align-title { color: var(--dim); font-size: 13px; margin-bottom: 2px; }
.align-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.align-row > span { font-size: 14px; }
.seg.sm button { padding: 4px 10px; font-size: 12px; }
.txt-wide { flex: 1; min-width: 220px; background: var(--btn); border: 1px solid var(--edge); color: var(--ink); border-radius: 8px; padding: 8px 10px; font-family: inherit; font-size: 15px; }
.logo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-row img { height: 42px; max-width: 110px; object-fit: contain; border-radius: 6px; }
.logo-row img:not([src]), .logo-row img[src=""] { display: none; }
.tg-list { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 12px; }
.tg-item { background: var(--btn); border: 1px solid var(--edge); border-radius: 10px; padding: 12px; }
.tg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.tg-name { font-weight: 700; color: var(--gold); font-family: monospace; }
.tg-head label { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 4px; }
.tg-head select { background: var(--card); border: 1px solid var(--edge); color: var(--ink); border-radius: 7px; padding: 5px 8px; font-family: inherit; font-size: 13px; }
.tg-dl { text-decoration: none; }
.tg-del { margin-inline-start: auto; color: #e0807f; }
.tg-text { width: 100%; min-height: 90px; }
.tg-save { margin-top: 8px; }
.tg-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tg-head code, .hint code { background: var(--card); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* backup / restore */
.backup-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 6px; }
.backup-actions .btn { font-size: 15px; padding: 10px 16px; }
.backup-warn { color: #e0807f; }
