/* Site editor. Deliberately plain: it is a tool, not a brochure, and it must
   not be mistaken for the site it edits. */
:root {
  --ink: #16242b;
  --muted: #5d7076;
  --line: #dfe5e7;
  --bg: #f4f6f7;
  --card: #fff;
  --accent: #107A88;
  --accent-dark: #0B5A65;
  --danger: #a3301f;
  --ok: #1d6b4f;
  --r: 10px;
}
* , *::before, *::after { box-sizing: border-box; }

/* `hidden` is only `display: none` at the UA level, so any rule that sets
   `display` on the same element beats it. `.login` is a grid and `.app` is a
   flex column, which meant the sign-in card stayed painted on top of the
   loaded editor. Making the attribute win everywhere is the fix; doing it
   per-class is how this comes back. */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: .86rem; }
.err { color: var(--danger); font-size: .88rem; }

/* buttons */
.btn {
  font: inherit; font-size: .88rem; font-weight: 600;
  padding: .5rem .9rem; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn--quiet { border-color: transparent; color: var(--muted); }
.btn--wide { width: 100%; }
.btn--danger { color: var(--danger); border-color: #e7c9c4; }
.btn[disabled] { opacity: .5; cursor: default; }
:where(button, input, select, textarea, a):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
  width: min(380px, 100%); background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 1.8rem;
  display: flex; flex-direction: column; gap: .9rem;
  box-shadow: 0 16px 40px -20px rgba(0,0,0,.25);
}
.login-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; }
input[type=email], input[type=password], input[type=text], input[type=url], textarea, select {
  font: inherit; padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: inherit; width: 100%;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.5; }

/* shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1rem; background: #fff; border-bottom: 1px solid var(--line);
}
.bar-l { display: flex; align-items: center; gap: .7rem; }
.bar-r { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
.picker { width: auto; padding: .35rem .5rem; font-size: .85rem; }
.dirty { font-size: .8rem; color: var(--danger); font-weight: 600; }

.cols { display: grid; grid-template-columns: 290px minmax(0, 1fr); flex: 1; align-items: start; }
.rail { padding: 1rem; border-right: 1px solid var(--line); position: sticky; top: 57px; }
.rail-head { display: flex; align-items: baseline; gap: .6rem; margin: 1.2rem 0 .5rem; }
.rail-head:first-child { margin-top: 0; }
.rail-head h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }

.seclist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.seci {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .6rem; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; cursor: grab; font-size: .9rem;
}
.seci.is-on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.seci.dragging { opacity: .4; }
.seci.off .seci-name { color: var(--muted); text-decoration: line-through; }
.seci-grip { color: #b7c2c5; cursor: grab; display: inline-flex; align-items: center; }
.seci-name { flex: 1; text-align: left; background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }
.seci-eye { background: none; border: 0; cursor: pointer; color: var(--muted); padding: .2rem; display: inline-flex; align-items: center; border-radius: 5px; }
.seci-eye:hover { color: var(--accent); background: #eef5f6; }

.langpick { display: flex; gap: .4rem; }
.langpick button { flex: 1; }
.langpick button.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.history { font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; gap: .35rem; max-height: 220px; overflow: auto; }

/* editing pane */
.pane { padding: 1.3rem 1.5rem 4rem; }
.pane h2.sec-title { font-size: 1.25rem; margin-bottom: .2rem; }
.field { margin-bottom: 1.1rem; }
.field > label { display: block; font-size: .8rem; font-weight: 650; margin-bottom: .3rem; }
.field select { max-width: 320px; }
.field .hint { font-size: .76rem; color: var(--muted); margin-top: .25rem; }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px,100%), 1fr)); gap: .7rem; }
.pair .side { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .6rem .7rem; }
.pair .side h4 { margin: 0 0 .35rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.side[dir=rtl] textarea, .side[dir=rtl] input { text-align: right; }
.stale { border-color: #e2b95f; background: #fffaf0; }
.stale-note { font-size: .74rem; color: #8a6a1f; margin-top: .35rem; line-height: 1.45; }
.linkish { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: #8a6a1f; cursor: pointer; text-decoration: underline; }
.linkish:hover { color: var(--accent); }
.stale-badge {
  display: inline-grid; place-items: center;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: #e2b95f; color: #3a2c08;
  font-size: .66rem; font-weight: 800; vertical-align: 1px;
}

.group { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem; margin-bottom: .8rem; }
.group-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.group-head h3 { font-size: .95rem; flex: 1; }
.rowtools { display: flex; gap: .3rem; }
.rowtools button { background: none; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: .8rem; padding: .15rem .45rem; color: var(--muted); }
.rowtools button:hover { color: var(--accent); border-color: var(--accent); }

.thumbrow { display: flex; flex-wrap: wrap; gap: .5rem; }
.thumb { position: relative; width: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.thumb img { width: 100%; height: 105px; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 3px; right: 3px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; line-height: 1; }
.thumb .tag { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.55); color: #fff; font-size: .62rem; text-align: center; padding: 1px; }

/* media library */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(12,26,30,.55); display: grid; place-items: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 14px; width: min(920px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; font-size: 1.05rem; }
.uploader { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: .4rem; }
.upstatus { padding: .6rem 1.1rem; font-size: .84rem; background: #f0f7f8; border-bottom: 1px solid var(--line); }
.mediagrid { padding: 1rem 1.1rem; overflow: auto; display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(min(130px,100%), 1fr)); }
.mediacard { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.mediacard img { width: 100%; aspect-ratio: 4/5; object-fit: cover; display: block; background: #eef1f2; }
.mediacard .mc-b { padding: .4rem .5rem; display: flex; align-items: center; gap: .3rem; }
.mediacard .mc-n { font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .65rem 1.1rem; border-radius: 999px;
  font-size: .88rem; z-index: 90; max-width: min(90vw, 620px);
}
.toast[hidden] { display: none; }
.toast.bad { background: var(--danger); }
.toast.good { background: var(--ok); }

@media (max-width: 860px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---------- client branding ---------- */

/* The tokens above are overwritten at runtime from the client's own brand
   block, so the editor on quranway.com/admin is QuranWay teal and gold rather
   than a generic tool that happens to edit their site. */
.login-logo { width: 150px; height: auto; align-self: flex-start; margin-bottom: .2rem; }
body.branded h1, body.branded .sec-title { font-family: var(--display), Georgia, serif; }
body.branded .login-card h1 { font-size: 1.5rem; }
.login-card h1:has(span:empty) { font-size: 1.5rem; }
