/* Bayan — application interface styles (title bar, ribbon, panes, menus, dialogs, backstage, status bar), Qalam's
 * design in PowerPoint's colours. Uses logical properties, so the whole UI mirrors automatically for right-to-left
 * (Arabic). The slides themselves, the selection handles and the slide show: deck.css. */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI", "Geeza Pro", Tahoma, Arial, sans-serif;
  --accent: #c43e1c; --accent-hover: #a8341a; --accent-text: #b7472a; --accent-weak: #fbe0d8; --accent-dark: #a33a1c;
  --ic-accent: #c43e1c;
  --titlebar-bg: #b7472a; --titlebar-fg: #fff;
  --chrome-bg: #f3f3f3; --ribbon-bg: #ffffff; --sep: #e1dfdd;
  --fg: #242424; --fg-muted: #616161;
  --hover: #ebebeb; --pressed: #e0e0e0; --checked: #fbe4dc; --checked-border: #f0b8a6;
  --canvas-bg: #e6e6e6; --pane-bg: #f3f3f3;
  --menu-bg: #fff; --menu-border: #d6d6d6; --menu-shadow: 0 8px 24px rgba(0,0,0,.16);
  --input-bg: #fff; --input-border: #c8c8c8; --btn-bg: #fff; --btn-border: #c8c8c8; --bs-bg: #fff;
  --ctx-bg: #fbe9e4;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --accent: #e2643f; --accent-hover: #ec7a57; --accent-text: #f19a7c; --accent-weak: #4a2a20; --accent-dark: #6e2a17;
  --ic-accent: #f19a7c;
  --titlebar-bg: #6e2a17;
  --chrome-bg: #1f1f1f; --ribbon-bg: #2b2b2b; --sep: #3d3d3d;
  --fg: #f0f0f0; --fg-muted: #b3b3b3;
  --hover: #3a3a3a; --pressed: #454545; --checked: #533026; --checked-border: #7a4636;
  --canvas-bg: #161616; --pane-bg: #1f1f1f;
  --menu-bg: #2b2b2b; --menu-border: #474747; --menu-shadow: 0 8px 24px rgba(0,0,0,.5);
  --input-bg: #1e1e1e; --input-border: #565656; --btn-bg: #333; --btn-border: #565656; --bs-bg: #242424;
  --ctx-bg: #4a2a20;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 13px/1.35 var(--font-ui); color: var(--fg); background: var(--chrome-bg); -webkit-font-smoothing: antialiased; }
html[lang="ar"] body { font-size: 13.5px; }
button { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }
#app { display: flex; flex-direction: column; height: 100vh; position: relative; }
.ic { width: 18px; height: 18px; flex: none; display: block; direction: ltr; }
.ic .f { fill: currentColor; stroke: none; }
.ic .a { stroke: var(--ic-accent); }
.ic .af { fill: var(--ic-accent); stroke: none; }
.ic .w { fill: var(--ribbon-bg); }
.ic .rd { stroke: #d13438; }
.ic .pf { fill: #e3008c; stroke: none; }
.ic text { fill: currentColor; stroke: none; }
.ic .at { fill: var(--ic-accent); }
.ic .rt { fill: #c43e1c; }
.ic .gnf { fill: #2f9e44; stroke: none; }
.ic .ylf { fill: #e0a100; stroke: none; }
.ic .rdf { fill: #d13438; stroke: none; }
[dir="rtl"] .ic.flip { transform: scaleX(-1); }

/* ---------------- title bar ---------------- */
#titlebar { height: 38px; flex: none; display: flex; align-items: center; padding: 0 8px; background: var(--titlebar-bg); color: var(--titlebar-fg); user-select: none; -webkit-user-select: none; }
.tb-side { flex: 1 1 0; display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-end { justify-content: flex-end; }
.tb-center { flex: 0 1 auto; min-width: 0; padding: 0 12px; }
.tb-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.tb-title.dirty::after { content: " •"; opacity: .8; }
.app-logo { width: 20px; height: 20px; background: url(../img/icon.svg) center / contain no-repeat; margin-inline-end: 4px; }
.qat { display: flex; align-items: center; gap: 2px; }
.qbtn { width: 30px; height: 28px; display: flex; align-items: center; justify-content: center; border: none; background: none; color: inherit; border-radius: 5px; padding: 0; }
.qbtn:hover:not(:disabled) { background: rgba(255,255,255,.16); }
.qbtn:disabled { opacity: .45; }
.qbtn .ic { width: 17px; height: 17px; }
.cmd-search { width: min(320px, 34vw); height: 26px; display: flex; align-items: center; gap: 6px; padding: 0 8px; border-radius: 6px; background: rgba(255,255,255,.92); color: #333; }
:root[data-theme="dark"] .cmd-search { background: rgba(255,255,255,.12); color: #eee; }
.cmd-search .search-icon .ic { width: 14px; height: 14px; opacity: .7; }
.search-input { flex: 1; min-width: 0; border: none; background: transparent; font: inherit; font-size: 12.5px; color: inherit; outline: none; }
.search-input::placeholder { color: inherit; opacity: .6; }
body.native #titlebar { display: none; }
body.native #tabbar .cmd-search { width: 220px; height: 24px; margin: 0 6px 4px; align-self: flex-end; background: var(--input-bg); border: 1px solid var(--input-border); color: var(--fg); }
.qat.in-tabbar { margin-inline-end: 6px; padding-inline-end: 6px; border-inline-end: 1px solid var(--sep); align-self: center; }
.qat.in-tabbar .qbtn { color: var(--fg); width: 28px; height: 26px; }
.qat.in-tabbar .qbtn:hover:not(:disabled) { background: var(--hover); }

/* ---------------- tabs ---------------- */
#tabbar { height: 34px; flex: none; display: flex; align-items: flex-end; gap: 2px; padding: 0 8px; background: var(--chrome-bg); user-select: none; -webkit-user-select: none; }
.tab { height: 30px; padding: 0 11px; border: none; background: none; color: var(--fg); font-size: 13px; border-radius: 5px 5px 0 0; position: relative; white-space: nowrap; cursor: default; }
html[lang="ar"] .tab { font-size: 13.5px; }
.tab:hover { background: var(--hover); }
.tab.active { color: var(--accent-text); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; inset-inline: 10px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--accent); }
.tab-file { color: var(--accent-text); font-weight: 600; }
.tab.ctx { background: var(--ctx-bg); color: var(--accent-text); }
.tab-spacer { flex: 1; }
.tab-collapse { width: 28px; height: 26px; margin-bottom: 3px; border: none; background: none; color: var(--fg-muted); border-radius: 5px; display: flex; align-items: center; justify-content: center; padding: 0; }
.tab-collapse:hover { background: var(--hover); }
.tab-collapse .ic { width: 14px; height: 14px; }
body.ribbon-collapsed .tab-collapse .ic { transform: rotate(180deg); }

/* ---------------- ribbon ---------------- */
#ribbon { height: 98px; flex: none; display: flex; margin: 0 6px 6px; background: var(--ribbon-bg); border-radius: 8px; box-shadow: 0 0 0 1px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.12); overflow: hidden; user-select: none; -webkit-user-select: none; }
body.ribbon-collapsed #ribbon { display: none; }
body.ribbon-collapsed.ribbon-peek #ribbon { display: flex; position: absolute; top: 72px; inset-inline: 0; z-index: 60; box-shadow: var(--menu-shadow); }
body.native.ribbon-collapsed.ribbon-peek #ribbon { top: 34px; }
.rpanel { display: none; flex: 1; align-items: stretch; padding: 4px 2px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.rpanel::-webkit-scrollbar { display: none; }
.rpanel.active { display: flex; }
.rgroup { display: flex; flex-direction: column; flex: none; padding: 0 6px; position: relative; }
.rgroup + .rgroup { border-inline-start: 1px solid var(--sep); }
.rgroup-body { flex: 1; display: flex; align-items: flex-start; gap: 2px; padding-top: 1px; }
.rgroup-label { height: 18px; line-height: 16px; font-size: 11px; color: var(--fg-muted); text-align: center; white-space: nowrap; padding: 0 16px; }
.rlauncher { position: absolute; bottom: 2px; inset-inline-end: 3px; width: 16px; height: 16px; padding: 0; border: none; background: none; color: var(--fg-muted); border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.rlauncher:hover { background: var(--hover); color: var(--fg); }
.rlauncher .ic { width: 11px; height: 11px; }
.rbtn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 26px; min-width: 26px; padding: 0 4px; border: 1px solid transparent; border-radius: 4px; background: none; color: var(--fg); font-size: 12px; white-space: nowrap; position: relative; cursor: default; }
html[lang="ar"] .rbtn { font-size: 12.5px; }
.rbtn:hover:not(:disabled) { background: var(--hover); }
.rbtn:active:not(:disabled), .rbtn.open { background: var(--pressed); }
.rbtn.on { background: var(--checked); border-color: var(--checked-border); }
.rbtn:disabled, .rbtn.disabled { opacity: .38; }
.rbtn-icon { display: flex; align-items: center; justify-content: center; flex: none; }
.rbtn.big { flex-direction: column; justify-content: flex-start; height: 74px; min-width: 52px; max-width: 86px; padding: 4px 4px 2px; gap: 3px; }
.rbtn.big .ic { width: 32px; height: 32px; stroke-width: 1.15; }
.rbtn.big .rbtn-label { white-space: normal; text-align: center; line-height: 1.15; max-width: 82px; }
.rbtn .caret { display: flex; }
.rbtn .caret .ic { width: 10px; height: 10px; stroke-width: 2; }
.rbtn.big.dd .caret { margin-top: -2px; }
.rbtn.labeled { justify-content: flex-start; padding-inline: 4px 7px; }
.rcol { display: flex; flex-direction: column; gap: 0; padding-top: 0; }
.rcol > .rbtn, .rcol > .rsplit > .rbtn { height: 25px; }
.rcol > .rbtn, .rcol > .rsplit { width: 100%; justify-content: flex-start; }
.rrows { display: flex; flex-direction: column; gap: 5px; padding-top: 3px; }
.rrow { display: flex; align-items: center; gap: 1px; }
.rsep { width: 1px; height: 20px; background: var(--sep); margin: 0 4px; flex: none; }
.rsplit { display: inline-flex; align-items: stretch; border-radius: 4px; }
.rsplit > .rbtn { border-radius: 0; }
.rsplit > .rbtn:first-child { border-start-start-radius: 4px; border-end-start-radius: 4px; }
.rsplit > .rbtn:last-child { border-start-end-radius: 4px; border-end-end-radius: 4px; }
.rsplit:hover > .rbtn:not(:disabled) { border-color: var(--sep); }
.rsplit .rarrow { min-width: 14px; width: 14px; padding: 0; }
.rsplit .rarrow .ic { width: 10px; height: 10px; stroke-width: 2; }
.rsplit.big { flex-direction: column; }
.rsplit.big > .rbtn.big { height: 54px; border-radius: 4px 4px 0 0; }
.rsplit.big > .rarrow { width: auto; height: 20px; border-radius: 0 0 4px 4px; }
.color-btn .rbtn-icon { flex-direction: column; gap: 0; }
.cbar { display: block; width: 16px; height: 4px; margin-top: -2px; border-radius: 1px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.rbtn.big .cbar { width: 28px; height: 5px; }
.rcombo { display: inline-flex; align-items: center; height: 24px; border: 1px solid var(--input-border); border-radius: 4px; background: var(--input-bg); margin-inline-end: 2px; }
.rcombo:hover { border-color: var(--fg-muted); }
.rcombo:focus-within { border-color: var(--accent); }
.rcombo.disabled { opacity: .5; }
.rcombo-input { height: 100%; border: none; background: transparent; padding: 0 6px; font: inherit; font-size: 12px; color: var(--fg); outline: none; min-width: 0; }
.rcombo-arrow { width: 18px; height: 100%; border: none; background: none; color: var(--fg-muted); padding: 0; display: flex; align-items: center; justify-content: center; }
.rcombo-arrow .ic { width: 10px; height: 10px; stroke-width: 2; }
.rspin { display: flex; align-items: center; gap: 6px; height: 27px; font-size: 12px; white-space: nowrap; }
.rspin-label { min-width: 52px; }
.rspin-input { width: 62px; height: 23px; border: 1px solid var(--input-border); border-radius: 4px; padding: 0 4px; font: inherit; font-size: 12px; background: var(--input-bg); color: var(--fg); }
.rspin-input:disabled { opacity: .5; }
.rspin-unit { color: var(--fg-muted); font-size: 11px; min-width: 26px; }
.rcheck { display: flex; align-items: center; gap: 6px; height: 23px; padding: 0 4px; font-size: 12.5px; white-space: nowrap; }
/* galleries (themes, variants, transitions) */
.rgallery { display: flex; align-items: stretch; height: 70px; border: 1px solid var(--sep); border-radius: 6px; margin-top: 1px; }
.gal-list { display: flex; flex-wrap: wrap; align-content: flex-start; height: 68px; overflow: hidden; padding: 1px; gap: 2px; }
.gal-item { flex: none; border: 1px solid transparent; border-radius: 5px; background: none; padding: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--fg); overflow: hidden; }
.gal-item:hover { background: var(--hover); border-color: var(--sep); }
.gal-item.on { border-color: var(--accent); background: var(--checked); }
.gal-item .gal-ic .ic { width: 30px; height: 30px; stroke-width: 1.1; }
.gal-name { font-size: 11px; color: var(--fg-muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trans .gal-item { width: 58px; height: 64px; }
.themes .gal-item { height: 64px; padding: 4px; }
.gal-nav { display: flex; flex-direction: column; border-inline-start: 1px solid var(--sep); }
.gal-scroll { flex: 1; width: 17px; border: none; background: none; padding: 0; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; }
.gal-scroll:hover { background: var(--hover); }
.gal-scroll .ic { width: 11px; height: 11px; stroke-width: 2; }
.gal-popup { display: flex; flex-wrap: wrap; gap: 4px; max-width: 470px; padding: 6px; }
.gal-popup.trans .gal-item { width: 64px; height: 66px; }
.anims .gal-item { width: 60px; height: 64px; }
.anims .gal-item .gal-name, .anim-picker .gal-name { white-space: normal; text-align: center; line-height: 1.1; max-height: 2.3em; }
.anims .gal-item .gal-ic .ic { width: 26px; height: 26px; }
.gal-head { width: 100%; padding: 6px 4px 2px; font-size: 11.5px; font-weight: 600; color: var(--fg-muted); }
.anim-picker { display: flex; flex-wrap: wrap; gap: 4px; width: 400px; padding: 6px; }
.anim-picker .gal-item { width: 72px; height: 64px; }
.anim-picker .gal-item .gal-ic .ic { width: 26px; height: 26px; }
.rcaption .rspin-label { min-width: 40px; }
.rcombo.readonly .rcombo-input { cursor: default; caret-color: transparent; }
#ribbon.compact-small .rbtn.labeled .rbtn-label { display: none; }
#ribbon.compact-small .rcol > .rbtn, #ribbon.compact-small .rcol > .rsplit { width: auto; }
#ribbon.compact-small .rgroup-label { padding: 0 6px; }
#ribbon.compact .rbtn.big { height: auto; min-width: 28px; max-width: none; padding: 3px; }
#ribbon.compact .rbtn.big .rbtn-label { display: none; }
#ribbon.compact .rbtn.big .ic { width: 22px; height: 22px; }
#ribbon.compact .rsplit.big > .rbtn.big { height: auto; }
#ribbon.compact .rgroup-label { padding: 0 4px; }
#ribbon.compact .rbtn.labeled .rbtn-label { display: none; }
#ribbon.compact .rcol > .rbtn, #ribbon.compact .rcol > .rsplit { width: auto; }
#ribbon.compact .rgroup { padding: 0 3px; }
#ribbon.compact .gal-list { max-width: 220px; }

/* ---------------- main area: slides pane | slide + notes ---------------- */
#main { flex: 1; display: flex; min-height: 0; position: relative; }
#slidepane { width: 214px; flex: none; display: flex; flex-direction: column; background: var(--pane-bg); border-inline-end: 1px solid var(--sep); }
#editarea { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#workspace { flex: 1; display: flex; overflow: auto; background: var(--canvas-bg); position: relative; direction: ltr; outline: none; }
#stagewrap { margin: auto; padding: 28px; flex: none; }
#notespane { height: 92px; flex: none; display: flex; background: var(--ribbon-bg); border-top: 1px solid var(--sep); }
body.notes-hidden #notespane { display: none; }
.notes-box { flex: 1; resize: none; border: none; outline: none; padding: 10px 16px; background: transparent; color: var(--fg); font: 14px/1.5 var(--font-ui); unicode-bidi: plaintext; }
.notes-box::placeholder { color: var(--fg-muted); }
body.view-sorter #slidepane, body.view-sorter #editarea, body.view-sorter #animpane { display: none !important; }
/* Animation Pane */
#animpane { width: 260px; flex: none; display: flex; flex-direction: column; background: var(--ribbon-bg); border-inline-start: 1px solid var(--sep); }
.ap-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 6px 12px; font-weight: 600; font-size: 14px; }
.np-x { width: 26px; height: 26px; border: none; background: none; border-radius: 4px; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; padding: 0; }
.np-x:hover { background: var(--hover); }
.np-x .ic { width: 14px; height: 14px; }
.ap-bar { padding: 2px 12px 8px; display: flex; gap: 6px; }
.ap-bar .btn .ic { width: 12px; height: 12px; }
.ap-list { flex: 1; overflow: auto; padding: 6px; border-top: 1px solid var(--sep); }
.ap-item { display: grid; grid-template-columns: 18px 18px 18px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 4px; padding: 5px 6px; border-radius: 5px; font-size: 12.5px; cursor: default; }
.ap-item:hover { background: var(--hover); }
.ap-item.on { background: var(--checked); }
.ap-num { color: var(--fg-muted); text-align: center; font-size: 11.5px; }
.ap-start .ic, .ap-star .ic { width: 15px; height: 15px; }
.ap-start { color: var(--fg-muted); }
.ap-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; text-align: start; }
.ap-sub { grid-column: 4; font-size: 11px; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-foot { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-top: 1px solid var(--sep); }
.ap-icon { width: 28px; height: 26px; border: none; background: none; border-radius: 4px; color: var(--fg); display: flex; align-items: center; justify-content: center; padding: 0; }
.ap-icon:hover:not(:disabled) { background: var(--hover); }
.ap-icon:disabled { opacity: .35; }
.ap-icon .ic { width: 16px; height: 16px; }
.ap-empty { padding: 14px 8px; font-size: 12px; color: var(--fg-muted); line-height: 1.7; }
#sorter { flex: 1; overflow: auto; background: var(--canvas-bg); padding: 26px 30px; }

/* ---------------- status bar ---------------- */
#statusbar { height: 26px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 8px; background: var(--chrome-bg); border-top: 1px solid var(--sep); font-size: 12px; color: var(--fg-muted); user-select: none; -webkit-user-select: none; }
.sb-item { height: 22px; padding: 0 8px; border: none; background: none; border-radius: 4px; font: inherit; color: inherit; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.sb-item .ic { width: 14px; height: 14px; }
.sb-item:hover, .sb-icon:hover { background: var(--hover); color: var(--fg); }
.sb-item.on { color: var(--accent-text); }
.sb-spacer { flex: 1; }
.sb-views { display: flex; gap: 1px; margin-inline: 6px 10px; }
.sb-icon { width: 26px; height: 22px; padding: 0; border: none; background: none; border-radius: 4px; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; }
.sb-icon .ic { width: 15px; height: 15px; }
.sb-icon.on { background: var(--checked); color: var(--accent-text); }
.sb-zoom { display: flex; align-items: center; gap: 2px; direction: ltr; }
.zoom-slider { width: 110px; accent-color: var(--accent); }
.zoom-pct { min-width: 48px; justify-content: center; }

/* ---------------- menus & popups ---------------- */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 2500; }
.menu { position: fixed; pointer-events: auto; min-width: 190px; max-width: 520px; max-height: 80vh; overflow: auto; padding: 4px; background: var(--menu-bg); color: var(--fg); border: 1px solid var(--menu-border); border-radius: 8px; box-shadow: var(--menu-shadow); }
.mi { display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 0 10px; border-radius: 5px; white-space: nowrap; cursor: default; outline: none; }
.mi:hover, .mi:focus { background: var(--hover); }
.mi.disabled { opacity: .45; pointer-events: none; }
.mi.hint { font-size: 11px; min-height: 24px; }
.mi.checked-icon { background: var(--checked); }
.mi-icon { width: 18px; height: 18px; flex: none; display: flex; align-items: center; justify-content: center; }
.mi-icon .ic { width: 16px; height: 16px; }
.mi.checked .mi-icon { color: var(--accent-text); }
.mi-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.mi-sc { color: var(--fg-muted); font-size: 11.5px; direction: ltr; unicode-bidi: isolate; margin-inline-start: 18px; }
.mi-sub .ic { width: 12px; height: 12px; }
.msep { height: 1px; background: var(--sep); margin: 4px 6px; }
.mhead { padding: 7px 10px 3px; font-size: 11.5px; font-weight: 600; color: var(--fg-muted); }
.combo-menu { max-height: 440px; }
.font-menu { width: 300px; }
.color-panel { width: 236px; padding-bottom: 2px; }
.swatches { display: grid; gap: 2px; padding: 2px 10px; justify-content: start; direction: ltr; }
.swatches.cols10 { grid-template-columns: repeat(10, 18px); }
.swatches.first { margin-bottom: 5px; }
.swatches.tints { row-gap: 0; padding-top: 0; padding-bottom: 0; }
.sw { width: 18px; height: 18px; padding: 0; border: 1px solid rgba(0,0,0,.14); border-radius: 2px; }
.sw:hover { outline: 2px solid var(--accent); outline-offset: 1px; position: relative; z-index: 1; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 2px; border: 1px solid rgba(0,0,0,.2); }
.swatch.big { width: 26px; height: 16px; }
.hidden-color { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
.list-lib { display: grid; grid-template-columns: repeat(3, 60px); gap: 6px; padding: 6px 10px 10px; }
.lib-item { height: 56px; border: 1px solid var(--sep); background: var(--ribbon-bg); color: var(--fg); border-radius: 5px; font-size: 22px; padding: 0; }
.lib-item:hover { border-color: var(--accent); }
.lib-item.on { border-color: var(--accent); background: var(--checked); }
.list-lib .lib-item:first-child { font-size: 12px; }
.list-lib.num { grid-template-columns: repeat(3, 76px); }
.list-lib.num .lib-item { height: 78px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 3px; padding: 4px 10px; font-size: 12.5px; }
.list-lib.num .lib-item:first-child { align-items: center; }
.sym-grid { display: grid; grid-template-columns: repeat(10, 30px); gap: 3px; padding: 6px 10px; }
.sym { height: 30px; padding: 0; border: 1px solid var(--sep); background: var(--ribbon-bg); color: var(--fg); border-radius: 4px; font-size: 16px; }
.sym:hover { border-color: var(--accent); background: var(--checked); }
.tooltip { position: fixed; max-width: 300px; padding: 8px 10px; background: var(--menu-bg); color: var(--fg); border: 1px solid var(--menu-border); border-radius: 6px; box-shadow: var(--menu-shadow); font-size: 12px; pointer-events: none; z-index: 3000; }
.tt-title { font-weight: 600; }
.tt-sc { font-weight: normal; color: var(--fg-muted); direction: ltr; unicode-bidi: isolate; }
.tt-desc { margin-top: 4px; color: var(--fg-muted); line-height: 1.45; }
.toast { position: fixed; bottom: 44px; left: 50%; transform: translate(-50%, 16px); max-width: 80vw; padding: 10px 18px; border-radius: 8px; background: #323130; color: #fff; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; transition: opacity .25s, transform .25s; z-index: 4000; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
/* shape gallery, quick styles, layout gallery */
.shape-gallery { width: 318px; max-height: min(68vh, 560px); overflow-y: auto; padding: 0 2px 6px; }
.shape-gallery .mhead { position: sticky; top: 0; background: var(--menu-bg); z-index: 1; }
.sg-grid { display: grid; grid-template-columns: repeat(12, 24px); gap: 1px; padding: 2px 6px 6px; direction: ltr; }
.sg-item { width: 24px; height: 24px; border: 1px solid transparent; border-radius: 3px; background: none; padding: 0; color: var(--fg); display: flex; align-items: center; justify-content: center; }
.sg-item:hover { background: var(--hover); border-color: var(--sep); color: var(--accent-text); }
.sg-ic { width: 20px; height: 20px; display: block; }
.shape-styles { padding: 0 6px 8px; }
.ss-grid { display: grid; grid-template-columns: repeat(7, 40px); gap: 6px; padding: 2px 2px 6px; direction: ltr; }
.ss-item { width: 40px; height: 30px; border: 1.5px solid; border-radius: 3px; font: 600 12px var(--font-ui); padding: 0; }
.ss-item.shadow { box-shadow: 2px 3px 4px rgba(0,0,0,.35); }
.ss-item:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.layout-gallery { display: grid; grid-template-columns: repeat(3, 128px); gap: 8px; padding: 8px; }
.lg-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--fg); font-size: 11.5px; }
.lg-item:hover { background: var(--hover); border-color: var(--sep); }
.lg-item.on { border-color: var(--accent); background: var(--checked); }
.lg-pic { box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.lg-name { max-width: 120px; text-align: center; line-height: 1.25; white-space: normal; }

/* ---------------- dialogs ---------------- */
.dlg-back { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.28); }
.dlg-back.modeless { background: transparent; pointer-events: none; align-items: flex-start; justify-content: flex-end; padding: 150px 24px 0; }
.dlg-back.modeless .dlg { pointer-events: auto; box-shadow: 0 10px 36px rgba(0,0,0,.3); }
.dlg { max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; background: var(--menu-bg); color: var(--fg); border: 1px solid var(--menu-border); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.28); }
.dlg-title { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 6px 16px; padding-inline: 16px 10px; font-size: 14px; font-weight: 600; cursor: move; user-select: none; -webkit-user-select: none; }
.dlg-x { width: 28px; height: 28px; border: none; background: none; border-radius: 5px; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; padding: 0; }
.dlg-x:hover { background: var(--hover); }
.dlg-x .ic { width: 14px; height: 14px; }
.dlg-body { padding: 6px 16px 12px; overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 8px 16px 14px; }
.btn { height: 30px; padding: 0 16px; border: 1px solid var(--btn-border); border-radius: 6px; background: var(--btn-bg); color: var(--fg); font-size: 13px; white-space: nowrap; cursor: default; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.small { height: 26px; padding: 0 12px; font-size: 12px; }
.btn .ic { width: 12px; height: 12px; }
.form { display: flex; flex-direction: column; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; min-width: 0; }
.field-label { color: var(--fg-muted); }
.inp { height: 30px; min-width: 0; padding: 0 8px; border: 1px solid var(--input-border); border-radius: 6px; background: var(--input-bg); color: var(--fg); font: inherit; font-size: 13px; }
.inp:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
select.inp { padding: 0 6px; }
.fs-title { margin-top: 6px; padding-bottom: 3px; border-bottom: 1px solid var(--sep); font-size: 12px; font-weight: 600; }
.opts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 2px; }
.opts.col { flex-direction: column; gap: 6px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.color-pick { justify-content: space-between; width: 90px; padding: 0 8px; }
.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats td { padding: 6px 4px; border-bottom: 1px solid var(--sep); }
.stats td.kbd { text-align: end; direction: ltr; unicode-bidi: isolate; color: var(--fg-muted); white-space: nowrap; }
.stats tr.kh td { padding-top: 14px; font-weight: 600; color: var(--accent-text); border-bottom-color: var(--accent-weak); }
.keys-wrap { max-height: 64vh; overflow: auto; }
.about { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.about h2 { margin: 4px 0 0; font-size: 22px; }
.about p { max-width: 440px; line-height: 1.6; }
.about-logo { width: 72px; height: 72px; background: url(../img/icon.svg) center / contain no-repeat; }
.about.big { align-items: flex-start; text-align: start; }
.about.big .about-logo { width: 96px; height: 96px; }
.confirm-msg { font-size: 14px; font-weight: 600; line-height: 1.5; }
.confirm-sub { margin-top: 6px; color: var(--fg-muted); }
.muted { color: var(--fg-muted); }

/* ---------------- backstage (File tab) ---------------- */
#backstage { position: fixed; inset: 0; z-index: 1500; display: flex; background: var(--bs-bg); color: var(--fg); }
.bs-nav { width: 220px; flex: none; display: flex; flex-direction: column; padding: 10px 0; background: var(--accent-dark); color: #fff; user-select: none; -webkit-user-select: none; }
.bs-back { width: 42px; height: 42px; margin: 4px 12px 14px; padding: 0; border: none; background: none; color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.bs-back:hover { background: rgba(255,255,255,.15); }
.bs-back .ic { width: 30px; height: 30px; stroke-width: 1.15; }
.bs-item { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 20px; border: none; background: none; color: #fff; font-size: 14px; text-align: start; }
.bs-item:hover { background: rgba(255,255,255,.12); }
.bs-item.active { background: rgba(255,255,255,.22); font-weight: 600; }
.bs-item .ic { width: 18px; height: 18px; }
.bs-spacer { flex: 1; }
.bs-main { flex: 1; overflow: auto; padding: 32px 48px; }
.bs-h1 { margin: 0 0 24px; font-size: 30px; font-weight: 300; }
.bs-h2 { margin: 28px 0 12px; font-size: 16px; font-weight: 600; }
.tpl-grid { display: flex; flex-wrap: wrap; gap: 22px; }
.tpl { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0; border: none; background: none; color: var(--fg); font-size: 13px; }
.tpl-thumb { border: 1px solid var(--sep); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tpl:hover .tpl-thumb { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.bs-row { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; margin-bottom: 18px; }
.bs-big { width: 112px; height: 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--sep); border-radius: 8px; background: var(--ribbon-bg); color: var(--fg); font-size: 14px; }
.bs-big .ic { width: 36px; height: 36px; stroke-width: 1.1; }
.bs-big:hover { border-color: var(--accent); background: var(--checked); }
.bs-big.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.recent { display: flex; flex-direction: column; max-width: 780px; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: none; background: none; border-radius: 6px; color: var(--fg); text-align: start; font-size: 13px; }
.recent-item:hover { background: var(--hover); }
.ri-icon .ic { width: 28px; height: 28px; stroke-width: 1.1; }
.ri-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ri-title { font-weight: 600; }
.ri-sub { font-size: 12px; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; text-align: start; }
[dir="rtl"] .ri-sub { text-align: right; }
.ri-date { font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.fmt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; max-width: 920px; }
.fmt-card { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--sep); border-radius: 8px; background: var(--ribbon-bg); color: var(--fg); text-align: start; }
.fmt-card:hover { border-color: var(--accent); background: var(--checked); }
.fmt-icon .ic { width: 40px; height: 40px; stroke-width: 1; }
.fmt-text { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.info-card { max-width: 700px; margin-bottom: 8px; }
.info-doc { display: flex; align-items: center; gap: 12px; }
.info-doc .ic { width: 44px; height: 44px; stroke-width: 1; }
.info-name { font-size: 18px; font-weight: 600; }
.props { width: 100%; border-collapse: collapse; }
.props th { width: 170px; padding: 8px 0; text-align: start; font-weight: normal; color: var(--fg-muted); vertical-align: middle; }
.props td { padding: 6px 0; }
.ver-hint { line-height: 1.6; max-width: 640px; }
.versions { display: flex; flex-direction: column; gap: 2px; }
.ver-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; }
.ver-item:hover { background: var(--hover); }
.ver-icon .ic { width: 20px; height: 20px; color: var(--accent-text); }
.ver-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ver-text .muted { font-size: 12px; }
.opt-row { display: flex; align-items: center; gap: 16px; max-width: 580px; padding: 8px 0; }
.opt-row label { width: 230px; }
.opt-row .inp { min-width: 230px; }
