/* Ummat CMS. Plain CSS, system fonts only (nothing to download). */
:root {
  --bg: #f3f4f1;
  --panel: #fff;
  --ink: #1c211d;
  --muted: #69716b;
  --line: #dcdfd9;
  --accent: #0f7a3e;
  --accent-ink: #fff;
  --accent-soft: #e3f1e8;
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --danger: #b3261e;
  --danger-soft: #fdeceb;
  --ins: #d7f5dd;
  --del: #fbdcdc;
  --radius: 6px;
  --ur-nastaliq: "Jameel Noori Nastaleeq", "Jameel Noori Nastaleeq Kasheeda", "Noto Nastaliq Urdu", "Urdu Typesetting", "Alvi Nastaleeq", serif;
  --ur-naskh: "Noto Naskh Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --ur-font: var(--ur-naskh);
}
body.font-nastaliq { --ur-editor-font: var(--ur-nastaliq); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", Tahoma, Arial, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 .8rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.warn { color: var(--warn); font-weight: 600; }

/* Urdu text: right-to-left, fast Naskh in lists; editor font is switchable. */
.ur { direction: rtl; text-align: right; font-family: var(--ur-font); unicode-bidi: plaintext; }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 16px;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.search { flex: 1 1 220px; max-width: 420px; }
.search input { width: 100%; }
.nav { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.nav > a:not(.btn) { color: var(--ink); text-decoration: none; }
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; }
.menu summary::after { content: " ▾"; color: var(--muted); }
.menu summary::-webkit-details-marker { display: none; }
.menu > div {
  position: absolute; top: 140%; left: 0; z-index: 10; min-width: 180px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0,0,0,.08); padding: 6px 0;
}
.menu-right > div { left: auto; right: 0; }
.menu > div > * { display: block; padding: 6px 14px; color: var(--ink); text-decoration: none; }
.menu > div > a:hover { background: var(--bg); }
.menu form { padding: 0; }
.menu .link { padding: 6px 14px; width: 100%; text-align: left; }

/* ---------- Controls ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 6px 8px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
label { display: block; margin: 0 0 12px; }
label > input:not([type=checkbox]), label > select { display: block; width: 100%; margin-top: 4px; }
label.check { display: flex; gap: 6px; align-items: center; }
.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 6px 12px; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #0b6332; }
.btn-danger { color: var(--danger); border-color: #e6b8b5; }
.btn-small { padding: 3px 9px; font-size: .85rem; }
.btn-wide { width: 100%; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- Messages ---------- */
.flash { padding: 9px 12px; border-radius: var(--radius); margin: 0 0 12px; background: var(--accent-soft); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-warn { background: var(--warn-soft); color: #5c3a00; }
.note { background: var(--warn-soft); border-left: 3px solid var(--warn); padding: 6px 10px; margin: 0 0 12px; border-radius: var(--radius); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.narrow { max-width: 440px; margin: 24px auto; }
.login { max-width: 340px; margin: 10vh auto; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; }

/* ---------- Queue ---------- */
.queue { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 16px; align-items: start; }
.facets {
  position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; font-size: .9rem;
}
.facets summary { font-weight: 600; cursor: pointer; margin-bottom: 4px; }
.facets h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 4px; }
.facets ul { list-style: none; margin: 0; padding: 0; }
.facets li a { display: flex; justify-content: space-between; gap: 8px; padding: 3px 6px; border-radius: 4px; color: var(--ink); text-decoration: none; }
.facets li a:hover { background: var(--bg); }
.facets li.on a { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.facets .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.facets .box { color: var(--muted); }
.facets li.on .box { color: var(--accent); }
.facets-clear { display: block; font-size: .85rem; margin-bottom: 4px; }
.daynav form { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.daynav { display: flex; gap: 6px; align-items: center; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs a {
  padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.count { display: inline-block; min-width: 1.6em; padding: 0 5px; border-radius: 9px; background: var(--line); color: var(--ink); font-size: .8rem; text-align: center; }
.tabs a.on .count { background: var(--accent); color: #fff; }

.stories { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.story {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "side main" "side meta";
  gap: 2px 16px; padding: 10px 14px; border-top: 1px solid var(--line);
}
.story:first-child { border-top: 0; }
.story.mine { background: #f5fbf7; box-shadow: inset -3px 0 0 var(--accent); }
.story-main { grid-area: main; text-decoration: none; color: var(--ink); min-width: 0; }
.story-head { display: block; font-size: 1.15rem; font-weight: 600; }
.story-kicker { display: block; font-size: .9rem; color: var(--muted); }
.story-excerpt { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-meta { grid-area: meta; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 12px; font-size: .85rem; color: var(--muted); }
.story-side { grid-area: side; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; font-size: .85rem; }
.id { font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 0 7px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line); font-size: .8rem; color: var(--ink); }
.pill.live { background: var(--warn-soft); border-color: #f0d9a8; color: var(--warn); }
.stage-sub_edit { background: #e8f0fb; } .stage-proof { background: #f4ecfb; }
.stage-trash { background: var(--danger-soft); }
.pill.ai { background: #eef0ff; border-color: #c9cdf5; color: #3a43a8; }
.flash-ai { background: #eef0ff; color: #2c3389; }
.assignee.me { color: var(--accent); font-weight: 600; }
.copy-btn.copied, #copy-text.copied { background: var(--accent-soft); color: var(--accent); border-color: #b9dcc6; }
.copy-btn.changed, #copy-text.changed { background: #f2a600; border-color: #d08f00; color: #241a00; font-weight: 600; }
li.story.copy-changed { box-shadow: inset 4px 0 0 #f2a600; background: #fffaf0; }
.stories-compact tr.copy-changed td { background: #fffaf0; }
.stories-compact tr.copy-changed td:last-child { box-shadow: inset 4px 0 0 #f2a600; }

/* Compact view: a real table so columns line up. */
.density { margin-left: auto; }
.density.on { background: var(--accent-soft); border-color: #b9dcc6; color: var(--accent); }
/* Right-to-left column order: headline on the right, actions on the left. */
.stories-compact { border-radius: var(--radius); direction: rtl; }
.stories-compact th, .stories-compact td { text-align: right; }
.stories-compact th:not(.ur-head), .stories-compact td:not(.ur-head) { direction: ltr; }
.stories-compact td.actions { text-align: left; }
.stories-compact th, .stories-compact td { padding: 3px 8px; white-space: nowrap; vertical-align: middle; font-size: .88rem; }
.stories-compact .btn-small { padding: 0 8px; font-size: .8rem; }
.stories-compact .pill { font-size: .75rem; }
.stories-compact th { font-size: .8rem; color: var(--muted); }
.stories-compact td.ur-head { width: 100%; max-width: 0; }
.stories-compact td.ur-head a { display: block; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; color: var(--ink); text-decoration: none; font-weight: 600; text-align: right; }
.stories-compact td.ur-head a:hover { color: var(--accent); }
.stories-compact th.ur-head { text-align: right; }
.stories-compact .num { text-align: right; font-variant-numeric: tabular-nums; }
.stories-compact td.reporter { max-width: 7em; overflow: hidden; text-overflow: ellipsis; }
.stories-compact tr.mine td { background: #f5fbf7; }
.stories-compact tr.mine td:first-child { box-shadow: inset -3px 0 0 var(--accent); }
.stories-compact tbody tr:hover td { background: var(--bg); }


/* Quick view: the story in a box over the list. */
.quick { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50; background: rgba(20, 25, 22, .45); display: flex; justify-content: center; align-items: flex-start; padding: 4vh 16px; }
.quick[hidden] { display: none; }
.quick-box { background: var(--panel); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.25); width: 100%; max-width: 820px; max-height: 92vh; display: flex; flex-direction: column; }
.quick-bar { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.quick-close { margin-left: auto; }
.quick-body { overflow-y: auto; padding: 14px 20px 18px; }
.quick-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .85rem; color: var(--muted); margin-bottom: 10px; align-items: center; }
.quick-story { font-family: var(--ur-editor-font, var(--ur-naskh)); line-height: 2.1; }
.quick-story .q-kicker { margin: 0; font-size: 1.05rem; color: #3d4a40; }
.quick-story .q-headline { margin: 0; font-size: 1.6rem; line-height: 1.9; }
.quick-story .q-subhead { margin: 0; font-size: 1.2rem; }
.quick-story .q-body { margin-top: 10px; font-size: 1.2rem; }
.quick-actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.quick-open { overflow: hidden; }
.story-meta .quick-btn { padding: 0 8px; font-size: .8rem; }
.peek { border: 0; background: none; padding: 0 2px; cursor: pointer; color: var(--muted); vertical-align: middle; line-height: 1; }
.peek:hover, .peek:focus { color: var(--accent); }

/* ---------- Editor ---------- */
.editor-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.pipeline { display: flex; list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.pipeline li { padding: 3px 12px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.pipeline li + li { border-left: 0; }
.pipeline li:first-child { border-radius: 12px 0 0 12px; } .pipeline li:last-child { border-radius: 0 12px 12px 0; }
.pipeline .done { color: var(--accent); }
.pipeline .now { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pipeline .now.trash { background: var(--danger); border-color: var(--danger); }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
.editor-main { min-width: 0; }
.headings { margin-bottom: 8px; }
.headings input { display: block; width: 100%; margin-bottom: 6px; padding: 4px 12px; font-family: var(--ur-editor-font, var(--ur-naskh)); }
.headings .kicker { height: 2.9rem; font-size: 1.1rem; color: #3d4a40; }
.headings .headline { height: 3.6rem; font-size: 1.5rem; font-weight: 600; }
.headings .subhead { height: 3.1rem; font-size: 1.2rem; }
.show-headings { display: block; margin: 0 0 0 auto; }
.diff-label { font-size: .8rem; color: var(--muted); direction: ltr; text-align: left; }
.editor .body {
  display: block; width: 100%; height: 64vh; min-height: 320px; resize: vertical;
  font-family: var(--ur-editor-font, var(--ur-naskh)); font-size: 1.3rem; line-height: 2.1; padding: 12px 16px;
}
.body.readonly { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); height: auto; min-height: 200px; }
.body-short { height: 160px !important; min-height: 0 !important; margin-bottom: 8px; }
.editor-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 8px; font-size: .9rem; }
.words.over { color: var(--danger); font-weight: 600; }
.words.near { color: var(--accent); font-weight: 600; }

.editor-side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.savebar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.save-status { font-size: .9rem; color: var(--muted); }
.save-status.dirty { color: var(--warn); }
.save-status.error { color: var(--danger); font-weight: 600; }
.moves { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin: 0 0 12px; min-width: 0; }
.moves legend { padding: 0 4px; font-weight: 600; font-size: .9rem; }
.move { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.move .btn { order: -1; width: 100%; white-space: normal; }
.move select { width: 100%; font-size: .85rem; padding: 3px 6px; color: var(--muted); }
.moves textarea { width: 100%; font-size: .9rem; }
.fields { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; margin: 0; }
.fields dt { color: var(--muted); font-size: .85rem; }
.fields dd { margin: 0; }
.fields input, .fields select { width: 100%; }
.assign { margin: 12px 0 0; }
.meta-info { margin: 12px 0 0; }

/* ---------- History / diff ---------- */
.history { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.compare { display: flex; gap: 10px; flex-wrap: wrap; }
.compare label { flex: 1 1 240px; }
.diff { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; font-size: 1.15rem; line-height: 2; }
.diff p { margin: 0 0 .6em; }
.diff ins { background: var(--ins); text-decoration: none; }
.diff del { background: var(--del); color: #8a1c15; }
.diff-ins { border-right: 3px solid #3aa55a; padding-right: 6px; }
.diff-del { border-right: 3px solid var(--danger); padding-right: 6px; }
.ins-count { color: var(--accent); font-weight: 600; } .del-count { color: var(--danger); font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); }
.conflict-actions { display: flex; gap: 10px; align-items: center; margin: 16px 0; }

/* ---------- Wires, admin ---------- */
.wires { list-style: none; padding: 0; margin: 0; }
.wire { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 6px; }
.wire details { flex: 1; min-width: 0; }
.wire summary { cursor: pointer; }
.wire summary .ur { display: block; }
.wire.used { opacity: .65; }
.wire-body { margin-top: 8px; line-height: 1.9; }
.add-wire summary { cursor: pointer; font-weight: 600; }
.add-wire form { margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
.table th, .table td { text-align: left; padding: 7px 10px; border-top: 1px solid var(--line); font-size: .92rem; }
.table th { background: var(--bg); font-weight: 600; }
tr.inactive td { color: var(--muted); }
tr.bad td { color: var(--danger); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two-col.wide-left { grid-template-columns: 2fr 1fr; }
.list-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.list-row input[name=name] { flex: 1 1 140px; }
.list-row input[name=target_words] { width: 110px; }
.list-row .sort { width: 64px; }
.list-row label.check { margin: 0; font-size: .85rem; }

/* ---------- Phones ---------- */
@media (max-width: 820px) {
  main { padding: 10px; }
  .top { padding: 8px 10px; gap: 8px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .editor, .history, .two-col, .two-col.wide-left, .queue { grid-template-columns: 1fr; }
  .facets { position: static; max-height: none; order: -1; }
  .editor .body { height: 55vh; font-size: 1.2rem; }
  .story { grid-template-columns: 1fr; grid-template-areas: "main" "meta" "side"; }
  .queue-main { overflow-x: auto; }
  .story-side { flex-direction: row; justify-content: flex-end; flex-wrap: wrap; }
  .story-kicker { display: block; font-size: .9rem; color: var(--muted); }
.story-excerpt { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .filters select, .filters .daynav { flex: 1 1 auto; }
}
