/* Cyber Cafe Utility Suite: print-shop palette.
   Cyan = actions, magenta = crop and cut marks (the one signature colour). */
:root {
    --bg: #E9EDF0;
    --surface: #FFFFFF;
    --ink: #16222D;
    --muted: #5A6875;
    --line: #CDD5DB;
    --cyan: #00799A;
    --cyan-dark: #005F79;
    --magenta: #C8186B;
    --warn-ink: #8A4B00;
    --warn-bg: #FFF3DD;
    --radius: 4px;
    --font: "IBM Plex Sans", "Hind Siliguri", system-ui, -apple-system, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }
code { font-size: .9em; background: var(--bg); padding: 1px 4px; border-radius: 3px; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #DCE3E8; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; padding: 0 8px; }
.brand-mark { width: 22px; height: 22px; position: relative; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; width: 11px; height: 11px; border: 0 solid var(--magenta); }
.brand-mark::before { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; }
.brand-mark::after { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: #C3CDD4; text-decoration: none; padding: 7px 10px; border-radius: var(--radius); font-size: 14px; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.nav-sep { height: 1px; background: rgba(255,255,255,.12); margin: 8px 10px; }
.sidebar-note { margin-top: auto; font-size: 12.5px; color: #93A1AC; padding: 0 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 20px; font-weight: 600; }
.topbar-extra { margin-left: auto; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 10px; cursor: pointer; }
.content { padding: 24px; }
.flash { margin: 16px 24px 0; padding: 10px 14px; background: #E2F3F7; border-left: 3px solid var(--cyan); border-radius: var(--radius); }

.search { width: min(380px, 50vw); padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.search:focus { background: #fff; }
.local-badge { font-size: 13px; color: var(--muted); padding: 5px 10px; border: 1px dashed var(--line); border-radius: 20px; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); cursor: pointer; text-decoration: none; font-weight: 500; font-size: 14px; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--cyan-dark); border-color: var(--cyan-dark); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--cyan); padding: 6px 8px; }
.btn-danger { color: var(--magenta); border-color: transparent; background: transparent; }
.btn-danger:hover { text-decoration: underline; }
.danger { color: var(--magenta); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
input:not([type=checkbox]):not([type=range]):not([type=file]), select { padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink); font-size: 14px; width: 100%; }
label.check { flex-direction: row; align-items: flex-start; gap: 8px; color: var(--ink); font-weight: 400; font-size: 14px; }
label.check input { margin-top: 4px; accent-color: var(--cyan); }
input[type=range] { accent-color: var(--magenta); width: 100%; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
fieldset:disabled { opacity: .45; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* Dashboard */
.category, .pinned > div { margin-bottom: 30px; }
.category h2, .pinned h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.tool { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
/* Crop-mark corners: the print trade's own vocabulary */
.tool::before, .tool::after { content: ""; position: absolute; width: 12px; height: 12px; border: 0 solid var(--magenta); opacity: 0; transition: opacity .15s; pointer-events: none; }
.tool::before { top: -6px; left: -6px; border-top-width: 2px; border-left-width: 2px; }
.tool::after { bottom: -6px; right: -6px; border-bottom-width: 2px; border-right-width: 2px; }
.tool:hover::before, .tool:hover::after, .tool:focus-within::before, .tool:focus-within::after { opacity: 1; }
.tool-link { display: block; padding: 16px 44px 16px 16px; color: inherit; text-decoration: none; height: 100%; }
.tool h3 { font-size: 15.5px; font-weight: 600; margin-bottom: 4px; }
.tool p { margin: 0; font-size: 13.5px; color: var(--muted); }
.tool.is-soon h3 { color: var(--muted); }
.badge { display: inline-block; margin-top: 10px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 20px; padding: 1px 8px; }
.fav { position: absolute; top: 10px; right: 10px; background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); line-height: 1; padding: 4px; }
.fav[aria-pressed="true"] { color: var(--magenta); }
.empty { color: var(--muted); }
.soon { max-width: 560px; padding: 40px 0; }
.soon-cat { color: var(--muted); margin: 0 0 6px; }
.soon h2 { font-size: 24px; margin-bottom: 10px; }
.soon p { margin: 0 0 20px; }

/* Card cropper */
.cropper { display: grid; grid-template-columns: 290px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.controls { padding: 4px 16px; }
.group { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.group:last-child { border-bottom: 0; }
.group h2, .output h2 { font-size: 14.5px; font-weight: 600; }
.filepick { position: relative; border: 1px dashed var(--cyan); border-radius: var(--radius); padding: 12px; text-align: center; color: var(--cyan); font-weight: 600; cursor: pointer; }
.filepick:hover { background: #F0F8FA; }
.filepick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.filepick:focus-within { outline: 2px solid var(--cyan); outline-offset: 2px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tabs button { border: 0; background: #fff; padding: 7px; cursor: pointer; font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--magenta); color: #fff; }
.tabs button:disabled { color: var(--line); cursor: not-allowed; }
output { color: var(--ink); font-weight: 600; }

.stage-wrap { padding: 12px; position: sticky; top: 76px; }
.stage { min-height: 460px; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#F2F4F6 0 25%, #fff 0 50%) 0 0 / 20px 20px; border-radius: var(--radius); }
.stage.dragging { outline: 3px dashed var(--magenta); outline-offset: -8px; }
.stage canvas { display: block; touch-action: none; box-shadow: 0 0 0 1px var(--line); }
.empty-state { text-align: center; padding: 30px; max-width: 380px; }
.empty-state p { margin: 0 0 6px; color: var(--muted); }
.empty-state .big { font-size: 17px; color: var(--ink); font-weight: 600; }
.empty-state .btn { margin-top: 14px; }
.empty-mark { display: block; width: 86px; height: 54px; margin: 0 auto 18px; position: relative; border: 1px dashed var(--muted); border-radius: 4px; }
.empty-mark::before, .empty-mark::after { content: ""; position: absolute; width: 14px; height: 14px; border: 0 solid var(--magenta); }
.empty-mark::before { top: -7px; left: -7px; border-top-width: 2px; border-left-width: 2px; }
.empty-mark::after { bottom: -7px; right: -7px; border-bottom-width: 2px; border-right-width: 2px; }
.stage-hint { margin-top: 8px; }

.output { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 76px; }
.info { margin: 0; font-size: 13.5px; }
.warnings { margin: 0; padding: 10px 12px 10px 28px; background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); font-size: 13px; }
.preview { display: flex; flex-direction: column; gap: 12px; max-height: 52vh; overflow-y: auto; }
.preview figure { margin: 0; }
.preview canvas { width: 100%; height: auto; display: block; box-shadow: 0 1px 3px rgba(22,34,45,.25); background: #fff; }
.preview figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn-primary { grid-column: 1 / -1; }

.busy { position: fixed; inset: 0; background: rgba(22,34,45,.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.busy span { background: #fff; padding: 12px 20px; border-radius: var(--radius); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); z-index: 60; max-width: 90vw; font-size: 14px; }
.dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(400px, 92vw); }
.dialog::backdrop { background: rgba(22,34,45,.45); }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog h2 { font-size: 17px; }
.dialog p { margin: 0; }

/* Presets */
.presets { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.preset-form { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.preset-form h2 { font-size: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); font-weight: 500; }
.table small { display: block; color: var(--muted); font-size: 12.5px; }
.t-actions { display: flex; gap: 4px; justify-content: flex-end; }
.t-actions form { margin: 0; }

/* Responsive */
@media (max-width: 1280px) {
    .cropper { grid-template-columns: 280px minmax(0, 1fr); }
    .output { grid-column: 1 / -1; position: static; }
    .preview { flex-direction: row; max-height: none; overflow-x: auto; }
    .preview figure { flex: 0 0 220px; }
}
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
    .nav-open .sidebar { transform: none; }
    .menu-btn { display: inline-block; }
    .cropper, .presets { grid-template-columns: 1fr; }
    .stage-wrap { position: static; }
    .content { padding: 14px; }
    .topbar { padding: 10px 14px; flex-wrap: wrap; }
    .search { width: 100%; }
    .topbar-extra { width: 100%; margin: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Phase 2 ---------- */
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
input[type=color] { width: 100%; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.empty-mark-portrait { width: 54px; height: 70px; }

/* Passport photo: finished photo next to download controls */
.photo-single { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: start; }
.photo-single canvas { width: 96px; height: auto; display: block; box-shadow: 0 1px 3px rgba(22,34,45,.25); background: #fff; }
.photo-single > div { display: flex; flex-direction: column; gap: 8px; }

/* Print layout: item list */
.items-wrap { min-height: 460px; display: flex; flex-direction: column; }
.items-wrap.dragging { outline: 3px dashed var(--magenta); outline-offset: -8px; }
.items-wrap .empty-state { margin: auto; }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.item-thumb { width: 96px; height: auto; max-height: 120px; object-fit: contain; display: block; box-shadow: 0 0 0 1px var(--line); justify-self: center; }
.item-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.item-name { margin: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.item-actions label.check { margin-right: auto; }
@media (max-width: 560px) {
    .item { grid-template-columns: 1fr; }
    .item-fields { grid-template-columns: 1fr 1fr; }
}

/* Colour swatches */
.field-label { margin: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.swatch { position: relative; aspect-ratio: 1; min-width: 0; padding: 0; border-radius: 50%; border: 1px solid rgba(22,34,45,.25); background: var(--c); cursor: pointer; }
.swatch[aria-checked="true"], .swatch-custom.is-on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--magenta); }
.swatch-custom { display: block; overflow: hidden; background: conic-gradient(#e53935, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935); }
.swatch-custom.is-on { background: var(--c); }
.swatch-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.swatch-custom:focus-within { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* Photo strip (multiple photos / joint photos) */
.tray-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.tray { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; overflow-x: auto; flex: 1 1 260px; min-height: 0; }
.tray:empty { display: none; }
.tray-card { position: relative; flex: 0 0 auto; width: 92px; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; background: #fff; display: flex; flex-direction: column; gap: 4px; }
.tray-card.is-active { border-color: var(--magenta); box-shadow: 0 0 0 1px var(--magenta); }
.tray-select { border: 0; padding: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; color: var(--ink); }
.tray-select canvas { height: 64px; width: auto; max-width: 78px; display: block; box-shadow: 0 0 0 1px var(--line); background: #f2f4f6; }
.tray-copies { display: flex; flex-direction: row; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 400; }
.tray-copies input { padding: 2px 4px !important; font-size: 12px !important; }
.tray-remove { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--magenta); cursor: pointer; line-height: 1; padding: 0; font-size: 14px; }
.tray-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.part-tabs { margin-bottom: 10px; max-width: 420px; grid-template-columns: 1fr 1fr 1fr; }
.bg-fixed { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.bg-fixed .swatch { width: 28px; height: 28px; cursor: default; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--magenta); }

/* Sidebar: categories with their ready tools underneath */
.sidebar nav a.nav-cat { margin-top: 8px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: #8E9BA6; padding-top: 4px; padding-bottom: 4px; }
.sidebar nav a.nav-tool { padding-left: 20px; position: relative; }
.sidebar nav a.nav-tool::before { content: ""; position: absolute; left: 10px; top: 50%; width: 4px; height: 4px; border-radius: 50%; background: #5C6B77; }
.sidebar nav a.nav-tool.active::before { background: var(--magenta); }

/* Together view zoom bar */
.zoom-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 10px; }
.zoom-who { font-size: 13px; color: var(--muted); min-width: 92px; }
.zoom-bar { position: sticky; top: 64px; z-index: 3; background: var(--surface); padding: 4px 0; }
.zoom-who output { color: var(--ink); font-weight: 600; }
.zoom-btn { width: 44px; height: 44px; padding: 0; font-size: 22px; font-weight: 600; line-height: 1; touch-action: manipulation; }
#jZoomReset { min-height: 44px; min-width: 52px; touch-action: manipulation; }
.zoom-bar label.check { margin-left: 4px; }

/* ---------- Phase 3: Bangla typing ---------- */
.bn-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 250px; gap: 16px; align-items: start; }
.bn-side .tpl-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.tpl-group { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 8px; }
.tpl-item { width: 100%; text-align: left; border: 0; background: none; padding: 7px 8px; border-radius: var(--radius); cursor: pointer; font-family: 'Hind Siliguri', var(--font); font-size: 14px; }
.tpl-item:hover, .tpl-item:focus-visible { background: #F0F8FA; color: var(--cyan-dark); }
.bn-main { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.bn-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; position: sticky; top: 64px; z-index: 4; }
.tb { min-width: 38px; height: 38px; padding: 0 9px; border: 1px solid transparent; background: none; border-radius: var(--radius); cursor: pointer; font-size: 15px; font-family: 'Hind Siliguri', var(--font); }
.tb:hover { background: var(--bg); }
.tb[aria-pressed="true"] { background: var(--ink); color: #fff; }
.tb-select { width: auto !important; height: 38px; }
.tb-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.bn-mode { height: 38px; padding: 0; overflow: hidden; display: inline-flex; border-color: var(--magenta); font-family: 'Hind Siliguri', var(--font); }
.bn-mode span { padding: 0 12px; display: inline-flex; align-items: center; height: 100%; }
.bn-mode .bn-mode-bn { background: var(--magenta); color: #fff; }
.bn-mode.is-en .bn-mode-bn { background: none; color: var(--muted); }
.bn-mode.is-en .bn-mode-en { background: var(--magenta); color: #fff; }
.bn-keyboard { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.kb-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.kb-key { min-width: 40px; height: 42px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); font-size: 19px; font-family: 'Noto Sans Bengali', 'Hind Siliguri', sans-serif; cursor: pointer; touch-action: manipulation; }
.kb-key:active { background: var(--bg); }
.kb-wide { min-width: 120px; font-size: 14px; }
.bn-paper-wrap { position: relative; overflow-x: auto; padding: 6px 0 20px; }
.bn-paper {
    --font: 'Noto Sans Bengali'; --size: 13pt; --lh: 1.6; --pw: 210mm; --ph: 297mm; --mt: 20mm; --ms: 20mm; --mb: 20mm;
    box-sizing: border-box; width: min(100%, var(--pw)); min-height: var(--ph); margin: 0 auto; background: #fff;
    padding: var(--mt) var(--ms) var(--mb); box-shadow: 0 1px 4px rgba(22,34,45,.18); outline: none;
    font-family: var(--font), 'Noto Sans Bengali', sans-serif; font-size: var(--size); line-height: var(--lh); color: #111;
    word-wrap: break-word; caret-color: var(--magenta);
}
.bn-paper:focus { box-shadow: 0 0 0 2px var(--cyan), 0 1px 4px rgba(22,34,45,.18); }
.bn-paper p { margin: 0 0 .6em; }
.bn-paper h2 { font-size: 1.35em; margin: .4em 0 .5em; }
.bn-paper h3 { font-size: 1.15em; margin: .4em 0 .5em; }
.bn-paper mark.ph { background: #FFF1A8; color: inherit; border-radius: 2px; padding: 0 2px; box-shadow: 0 0 0 1px #E8D36A inset; cursor: text; }
.bn-suggest { position: absolute; z-index: 10; list-style: none; margin: 0; padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(22,34,45,.18); min-width: 120px; max-width: 280px; }
.bn-suggest li { padding: 6px 10px; border-radius: 3px; cursor: pointer; font-family: 'Noto Sans Bengali', 'Hind Siliguri', sans-serif; font-size: 17px; }
.bn-suggest li[aria-selected="true"] { background: var(--magenta); color: #fff; }
.bn-suggest li.is-en { font-family: var(--font); font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); }
.bn-suggest li.is-en[aria-selected="true"] { color: #fff; }
.bn-status { font-size: 13px; color: var(--muted); }
.bn-out { display: flex; flex-direction: column; gap: 10px; }
.bn-actions { grid-template-columns: 1fr 1fr; }
.bn-actions .btn-primary { grid-column: auto; }
.bn-help { border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; }
.bn-help p { margin: 0 0 6px; font-family: 'Hind Siliguri', var(--font); }
kbd { font-family: var(--font); font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; background: #fff; }
.tpl-admin { padding: 16px; }
.tpl-row { display: grid; grid-template-columns: 1fr 160px 80px auto auto; gap: 8px; align-items: center; }
@media (max-width: 1280px) {
    .bn-layout { grid-template-columns: 240px minmax(0, 1fr); }
    .bn-out { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
    .bn-layout { grid-template-columns: 1fr; }
    .bn-main { order: -1; }
    .bn-toolbar { top: 0; }
    .bn-paper { --ms: 6mm !important; --mt: 8mm !important; min-height: 60vh; }
    .tpl-row { grid-template-columns: 1fr 1fr; }
}
/* Phone: on-screen keyboard docks at the bottom like a real keyboard */
@media (max-width: 900px) {
    .bn-keyboard:not([hidden]) {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 44vh; overflow-y: auto;
        border-radius: 0; border-width: 1px 0 0; box-shadow: 0 -4px 16px rgba(22,34,45,.15); padding: 6px 4px env(safe-area-inset-bottom);
    }
    .bn-keyboard .kb-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 3px; }
    .bn-keyboard .kb-key { min-width: 0; height: 40px; font-size: 18px; padding: 0; }
    .bn-keyboard .kb-wide { grid-column: span 4; }
    body:has(.bn-keyboard:not([hidden])) .bn-paper-wrap { padding-bottom: 46vh; }
}
/* Bangla editor: colour picker */
.tb-color { position: relative; }
.tb-color #colorBtn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.tb-a { font-weight: 700; line-height: 1; font-size: 16px; }
.tb-bar { display: block; width: 18px; height: 4px; border-radius: 1px; background: #c0262d; }
.color-pop { position: absolute; top: 44px; left: 0; z-index: 20; width: 236px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(22,34,45,.18); padding: 10px; }
.color-title { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.color-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 10px; }
.color-sw { aspect-ratio: 1; min-height: 36px; border-radius: 50%; border: 1px solid rgba(22,34,45,.25); background: var(--c); cursor: pointer; padding: 0; touch-action: manipulation; }
.color-sw:hover, .color-sw:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--magenta); }
.color-sw.is-none { background: #fff linear-gradient(135deg, transparent 45%, #c0262d 45%, #c0262d 55%, transparent 55%); }
.color-custom { flex-direction: row !important; align-items: center; gap: 8px !important; margin-bottom: 10px; }
.color-custom input { width: 44px !important; height: 32px; padding: 2px !important; }
@media (max-width: 900px) { .color-pop { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; } }

/* ---------- Phase 4: PDF studio ---------- */
.ps-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.ps-main { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.ps-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; position: sticky; top: 64px; z-index: 4; }
.ps-count { margin-left: auto; font-size: 13px; color: var(--muted); }
.ps-files { padding: 6px 12px; }
.ps-file-list { list-style: none; margin: 0; padding: 0; }
.ps-file-list li { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.ps-file-list li:last-child { border-bottom: 0; }
.ps-fname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.ps-stage { min-height: 380px; border-radius: var(--radius); }
.ps-stage.dragging { outline: 3px dashed var(--magenta); outline-offset: -6px; }
.ps-stage .empty-state { margin: 60px auto; }
.ps-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.ps-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.ps-card.is-sel { border-color: var(--magenta); box-shadow: 0 0 0 2px var(--magenta); }
.ps-card.is-drag { opacity: .4; }
.ps-card.drop-before { box-shadow: -4px 0 0 var(--cyan); }
.ps-card.drop-after { box-shadow: 4px 0 0 var(--cyan); }
.ps-thumb { position: relative; border: 0; background: var(--bg); padding: 0; height: 180px; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 3px; overflow: hidden; }
.ps-rot { display: inline-flex; transition: transform .15s; }
.ps-thumb canvas { max-width: 130px; max-height: 165px; width: auto; height: auto; display: block; box-shadow: 0 1px 3px rgba(22,34,45,.3); background: #fff; }
.ps-num { position: absolute; top: 6px; left: 6px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; border-radius: 10px; padding: 1px 7px; }
.ps-card.is-sel .ps-num { background: var(--magenta); }
.ps-label { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.ps-tools button { height: 34px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); cursor: pointer; font-size: 14px; touch-action: manipulation; }
.ps-tools button:hover { border-color: var(--muted); }
.ps-tools [data-act="del"] { color: var(--magenta); }
.ps-out { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 76px; }
.ps-sec { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.ps-sec.is-focus { background: #FFF8E6; margin: -6px -8px 0; padding: 6px 8px 12px; border-radius: var(--radius); }
.ps-sec h2 { font-size: 14.5px; font-weight: 600; }
@media (max-width: 900px) {
    .ps-layout { grid-template-columns: 1fr; }
    .ps-out { position: static; }
    .ps-bar { top: 0; }
    .ps-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}

/* ---------- Phase 4: image studio ---------- */
.img-result { background: repeating-conic-gradient(#F2F4F6 0 25%, #fff 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: flex; justify-content: center; }
.img-result canvas { max-width: 100%; max-height: 260px; width: auto; height: auto; display: block; box-shadow: 0 1px 3px rgba(22,34,45,.25); image-rendering: auto; }
.straighten { flex-direction: row !important; align-items: center; gap: 6px !important; min-width: 200px; flex: 1; }
.straighten input { flex: 1; }

/* ---------- PDF tools (Sejda-style) ---------- */
.pt { max-width: 1100px; margin: 0 auto; }
.pt-hub-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.pt-hub-head h2 { font-size: 22px; font-weight: 700; }
.pt-cat { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 22px 0 10px; }
.pt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.pt-card { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto 1fr; column-gap: 12px; row-gap: 2px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s, transform .12s; }
.pt-card:hover, .pt-card:focus-visible { border-color: var(--c, var(--cyan)); box-shadow: 0 6px 18px rgba(22,34,45,.10); transform: translateY(-1px); }
.pt-card .pt-icon { grid-row: 1 / 3; }
.pt-card-name { font-weight: 600; font-size: 15.5px; align-self: end; }
.pt-card-desc { font-size: 13px; color: var(--muted); line-height: 1.4; }
.pt-icon { --c: var(--cyan); width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--c); flex: none; }
.pt-icon svg { width: 24px; height: 24px; }
.pt-icon-lg { width: 56px; height: 56px; border-radius: 12px; }
.pt-icon-lg svg { width: 30px; height: 30px; }
.pt-icon-sm { width: 26px; height: 26px; border-radius: 6px; }
.pt-icon-sm svg { width: 16px; height: 16px; }
.pt-tool { display: flex; flex-direction: column; gap: 16px; }
.pt-back { color: var(--cyan); text-decoration: none; font-weight: 500; font-size: 14px; }
.pt-head { display: flex; gap: 14px; align-items: center; }
.pt-head h2 { font-size: 26px; font-weight: 700; }
.pt-head p { margin: 2px 0 0; color: var(--muted); }
.pt-drop { background: #fff; border: 2px dashed #B8C6D0; border-radius: 12px; padding: 56px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pt-tool.dragging .pt-drop, .pt-tool.dragging #work { outline: 3px dashed var(--magenta); outline-offset: 4px; }
.pt-upload { font-size: 18px; padding: 16px 34px; border-radius: 8px; }
.pt-drop p { margin: 0; color: var(--muted); }
.pt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.pt-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pt-file { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.pt-file.is-drag { opacity: .4; }
.pt-file.drop-before { box-shadow: 0 -3px 0 var(--cyan); }
.pt-file.drop-after { box-shadow: 0 3px 0 var(--cyan); }
.pt-file canvas { width: 48px; height: 60px; object-fit: contain; background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
.pt-file-name { min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-file-name small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.pt-file-tools { display: flex; gap: 4px; }
.pt-file-tools button { width: 38px; height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 15px; touch-action: manipulation; }
.pt-file-tools button:disabled { opacity: .35; cursor: default; }
.pt-file-tools [data-fact="del"] { color: var(--magenta); }
.pt-opts { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.pt-opts:empty { display: none; }
.pt-go { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: center; gap: 10px; padding: 14px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); flex-wrap: wrap; }
.pt-big { font-size: 18px; padding: 15px 40px; border-radius: 8px; min-width: 240px; }
.pt-more { padding: 15px 20px; border-radius: 8px; }
.pt-result { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 36px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pt-done { width: 64px; height: 64px; border-radius: 50%; background: #2E9E5B; color: #fff; font-size: 34px; display: flex; align-items: center; justify-content: center; }
.pt-result h2 { font-size: 24px; }
.pt-result p { margin: 0; color: var(--muted); word-break: break-word; }
.pt-continue-title { margin: 14px 0 6px !important; font-weight: 600; color: var(--ink) !important; }
.pt-continue { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 720px; }
.pt-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); background: #fff; border-radius: 20px; cursor: pointer; font-size: 14px; }
.pt-chip:hover { border-color: var(--muted); }
.pt-result-actions { margin-top: 8px; }
@media (max-width: 600px) {
    .pt-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
    .pt-card { grid-template-columns: 1fr; padding: 12px; }
    .pt-card .pt-icon { grid-row: auto; margin-bottom: 6px; }
    .pt-card-desc { display: none; }
    .pt-head h2 { font-size: 21px; }
    .pt-big { min-width: 0; flex: 1; }
    .pt-drop { padding: 36px 14px; }
}

/* ---------- PDF editor ---------- */
.pe { display: flex; flex-direction: column; gap: 10px; }
.pe-bar { position: sticky; top: 64px; z-index: 6; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; box-shadow: 0 2px 8px rgba(22,34,45,.06); }
.pe-modes, .pe-props { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pe-mode { height: 40px; padding: 0 12px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-weight: 500; touch-action: manipulation; }
.pe-mode[aria-pressed="true"] { background: #0F5BD3; border-color: #0F5BD3; color: #fff; }
.pe-tb { height: 38px; min-width: 38px; padding: 0 9px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; touch-action: manipulation; }
.pe-tb[aria-pressed="true"] { background: var(--ink); color: #fff; }
.pe-tb:disabled, .pe-props select:disabled, .pe-props input:disabled { opacity: .4; cursor: default; }
.pe-props select { width: auto !important; height: 38px; }
.pe-props #peSize { width: 64px !important; height: 38px; }
.pe-props #peColor { width: 40px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; }
.pe-zoom { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; }
.pe-zoom output { min-width: 44px; text-align: center; font-size: 13px; }
.pe-hint { margin: 0; }
.pe-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; overflow-x: auto; padding: 4px 0 10px; }
.pe-page { position: relative; background: #fff; box-shadow: 0 1px 6px rgba(22,34,45,.25); flex: none; }
.pe-canvas { display: block; }
.pe-pnum { position: absolute; right: -32px; top: 0; font-size: 12px; color: var(--muted); }
.pe-layer { position: absolute; inset: 0; touch-action: none; }
.pe-obj { position: absolute; box-sizing: border-box; white-space: pre; cursor: pointer; border-radius: 1px; }
.pe-obj.pe-pdf.pe-text:not([contenteditable]):not(.is-cover):hover, .pe-obj.pe-pdf.pe-image:not(.is-cover):hover { outline: 1.5px dashed #0F5BD3; background: rgba(15,91,211,.06); }
/* While typing over original text, a solid white box hides the old words (also on touch screens) */
.pe-obj.is-cover, .pe-obj[contenteditable="true"] { background-color: #fff !important; }
.pe-obj.pe-pdf.pe-text { color: transparent; overflow: visible; }
.pe-obj.is-cover { background: #fff; }
.pe-obj.pe-image { background-size: 100% 100%; background-repeat: no-repeat; cursor: move; }
.pe-obj.pe-new.pe-text { cursor: move; min-width: 8px; }
.pe-obj.pe-white { cursor: move; box-shadow: 0 0 0 1px rgba(22,34,45,.15); }
.pe-obj.is-sel { outline: 2px solid var(--magenta); outline-offset: 1px; }
.pe-obj[contenteditable="true"] { outline: 2px solid #0F5BD3; cursor: text; background: #fff; overflow: visible; min-width: 20px; }
.pe-obj.is-deleted { display: none; }
.pe-orig-cover { position: absolute; background: #fff; pointer-events: none; }
.pe-h { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid var(--magenta); border-radius: 2px; }
.pe-h-nw { left: -7px; top: -7px; cursor: nwse-resize; } .pe-h-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.pe-h-sw { left: -7px; bottom: -7px; cursor: nesw-resize; } .pe-h-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
@media (pointer: coarse) { .pe-h { width: 22px; height: 22px; } .pe-h-nw, .pe-h-sw { left: -12px; } .pe-h-ne, .pe-h-se { right: -12px; } .pe-h-nw, .pe-h-ne { top: -12px; } .pe-h-sw, .pe-h-se { bottom: -12px; } }
.pe-go { flex-direction: column; align-items: center; }
.pe-flat { max-width: 560px; font-size: 13px; }
@media (max-width: 900px) { .pe-bar { top: 0; } .pe-pnum { display: none; } }
.pe-warn { margin: 0; max-width: 560px; font-size: 13px; color: var(--warn-ink); background: var(--warn-bg); padding: 8px 12px; border-radius: 6px; }
