:root {
  --navy: #102a43;
  --navy-2: #173f5f;
  --yellow: #f4c430;
  --ink: #17212b;
  --muted: #687580;
  --line: #dce2e6;
  --soft: #f4f6f7;
  --canvas-bg: #e7ecef;
  --danger: #a93232;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 25px; background: radial-gradient(circle at 20% 10%, #234c6b, #0a1d2d 65%); }
.auth-card { width: min(430px, 100%); padding: 42px; border-radius: 16px; background: white; box-shadow: 0 30px 90px rgba(0,0,0,.34); }
.auth-card.setup-card { width: min(520px, 100%); }
.auth-card h1 { margin: 6px 0 10px; color: var(--navy); font-size: 34px; line-height: 1.05; letter-spacing: -.045em; }
.auth-intro { margin: 0 0 25px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-note { margin: 20px 0 0; color: #84909a; text-align: center; font-size: 10px; }
.auth-form label, .dialog label { display: block; margin-bottom: 16px; color: #5d6872; font-size: 11px; font-weight: 750; }
.auth-form input, .dialog input, .dialog select { width: 100%; height: 43px; margin-top: 6px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; }
.alert { margin: 0 0 18px; padding: 11px 13px; border-radius: 7px; font-size: 11px; line-height: 1.5; }
.alert.error { color: #7e2525; background: #fdecec; border: 1px solid #f4caca; }
.alert.success { color: #28623b; background: #eaf6ed; border: 1px solid #cce9d3; }
.eyebrow { margin: 0 0 7px; color: #567184; font-size: 9px; font-weight: 900; letter-spacing: .17em; }
.logo-mark { width: 34px; height: 34px; display: flex; align-items: center; gap: 3px; margin-bottom: 20px; }
.logo-mark.small { width: 29px; height: 29px; margin: 0; }
.logo-mark i { display: block; width: 8px; border-radius: 2px; background: var(--yellow); transform: skewY(-8deg); box-shadow: 2px 2px rgba(0,0,0,.13); }
.logo-mark i:nth-child(1) { height: 21px; }.logo-mark i:nth-child(2) { height: 30px; }.logo-mark i:nth-child(3) { height: 17px; }
.logo-mark.small i { width: 7px; }.logo-mark.small i:nth-child(1) { height: 17px; }.logo-mark.small i:nth-child(2) { height: 25px; }.logo-mark.small i:nth-child(3) { height: 14px; }

.button { min-height: 38px; padding: 8px 14px; border: 1px solid transparent; border-radius: 7px; font-size: 12px; font-weight: 800; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #17212b; background: var(--yellow); border-color: var(--yellow); }
.button.secondary { color: white; background: var(--navy-2); border-color: var(--navy-2); }
.button.ghost { color: var(--ink); background: white; border-color: var(--line); }
.button.danger-text { color: var(--danger); background: transparent; }
.button.full { width: 100%; }

.topbar { height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 18px; color: white; background: var(--navy); box-shadow: 0 3px 14px rgba(9,27,41,.2); position: relative; z-index: 50; }
.brand-button { display: flex; align-items: center; gap: 10px; padding: 0; border: 0; color: white; background: none; font-size: 16px; }
.brand-button strong { font-weight: 900; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.topbar .button.ghost { color: white; background: transparent; border-color: #587188; }
.topbar .button.secondary { background: #245171; border-color: #315e7e; }
.top-quiet { color: #c0ccd5; background: transparent; border: 0; }
.logout-form { margin: 0; }
.editor-centre { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 3px; }
.tool-button { width: 31px; height: 31px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 5px; color: #d9e1e7; background: transparent; font-size: 17px; }
.tool-button:hover { background: rgba(255,255,255,.1); }
.tool-button:disabled { opacity: .3; }
.editor-centre .divider { width: 1px; height: 20px; margin: 0 6px; background: #526a7e; }
#zoomValue { min-width: 42px; color: #b9c7d1; text-align: center; font-size: 10px; }
.save-status { margin-right: 5px; color: #b8c6d0; font-size: 10px; }
.save-status.dirty { color: #ffe287; }

.library-view { max-width: 1450px; margin: auto; padding: 52px 44px 80px; }
.library-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 35px; margin-bottom: 32px; }
.library-heading h1 { margin: 0; color: var(--navy); font-size: clamp(34px, 4vw, 49px); line-height: 1; letter-spacing: -.05em; }
.library-heading p:not(.eyebrow) { max-width: 680px; margin: 13px 0 0; color: var(--muted); font-size: 13px; }
.search-field { color: var(--muted); font-size: 10px; font-weight: 800; }
.search-field input { display: block; width: 260px; height: 40px; margin-top: 6px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 22px; }
.book-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 8px 26px rgba(21,42,59,.06); transition: transform .2s ease, box-shadow .2s ease; }
.book-card:hover { transform: translateY(-4px); box-shadow: 0 15px 34px rgba(21,42,59,.12); }
.book-cover { position: relative; aspect-ratio: 4/3; display: flex; flex-direction: column; justify-content: flex-end; padding: 22px; color: white; background: var(--navy) center/cover; overflow: hidden; }
.book-cover::before { content: ""; position: absolute; inset: 0; background: linear-gradient(140deg, rgba(16,42,67,.15), rgba(16,42,67,.95)); }
.book-cover::after { content: ""; position: absolute; width: 115px; height: 150%; right: -80px; top: -25%; background: var(--yellow); transform: rotate(17deg); }
.book-cover > * { position: relative; z-index: 1; }
.book-cover small { margin-bottom: 7px; font-size: 8px; font-weight: 900; letter-spacing: .15em; }
.book-cover strong { max-width: 90%; font-size: 21px; line-height: 1.04; letter-spacing: -.035em; }
.book-card-meta { padding: 15px 17px 17px; }
.book-card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 14px; color: #28623b; background: #eaf6ed; font-size: 9px; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #47955f; }
.status-pill.draft { color: #6c767e; background: #eff1f2; }.status-pill.draft::before { background: #9ca4aa; }
.book-card-meta small { color: #7d8992; font-size: 10px; }
.book-card-meta p { min-height: 34px; margin: 9px 0 14px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.book-card-actions { display: flex; gap: 7px; }.book-card-actions .button { flex: 1; }
.empty-library { grid-column: 1/-1; padding: 70px 20px; border: 1px dashed #c6cfd5; border-radius: 12px; color: var(--muted); background: white; text-align: center; }

.editor-view { height: calc(100vh - 66px); display: grid; grid-template-columns: 74px 190px minmax(430px,1fr) 310px; overflow: hidden; }
.asset-toolbar { padding: 10px 7px; border-right: 1px solid var(--line); background: #f8f9fa; overflow-y: auto; }
.asset-toolbar button { width: 100%; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; margin-bottom: 5px; border: 0; border-radius: 7px; color: #52616c; background: transparent; font-size: 9px; font-weight: 750; }
.asset-toolbar button:hover { color: var(--navy); background: #e8edf0; }
.asset-toolbar b { width: 28px; height: 26px; display: grid; place-items: center; color: var(--navy); font-size: 17px; }
.page-sidebar { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: white; }
.panel-heading { min-height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 10px 13px; border-bottom: 1px solid var(--line); }
.panel-heading .eyebrow { margin-bottom: 3px; }.panel-heading strong { font-size: 11px; }
.circle-button { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; color: white; background: var(--navy); font-size: 19px; }
.page-list { flex: 1; min-height: 0; padding: 10px; overflow-y: auto; }
.page-item { display: grid; grid-template-columns: 17px 1fr; align-items: center; gap: 6px; margin-bottom: 10px; cursor: pointer; }
.page-item-number { color: #89939a; text-align: center; font-size: 8px; }
.page-thumbnail { position: relative; aspect-ratio: var(--page-ratio,4/3); overflow: hidden; border: 2px solid transparent; border-radius: 4px; background: var(--page-background,#fff); box-shadow: 0 2px 8px rgba(20,38,53,.13); }
.page-item.active .page-thumbnail { border-color: var(--yellow); box-shadow: 0 0 0 2px rgba(244,196,48,.22); }
.thumb-layer { position: absolute; overflow: hidden; transform-origin: center; pointer-events: none; }
.thumb-layer.text { line-height: 1.1; white-space: pre-wrap; }
.thumb-layer.image { background-position: center; background-size: cover; }
.thumb-layer.shape { background: var(--layer-fill); }
.page-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.page-actions button { min-height: 40px; border: 0; color: #64717b; background: white; font-size: 9px; font-weight: 800; }.page-actions button + button { border-left: 1px solid var(--line); }.page-actions button:hover { background: var(--soft); }

.workspace { min-width: 0; display: flex; flex-direction: column; background: var(--canvas-bg); }
.workspace-heading { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 8px 16px; border-bottom: 1px solid #ced6db; background: #f6f8f9; }
.breadcrumbs { min-width: 0; display: flex; align-items: center; gap: 7px; font-size: 10px; }.breadcrumbs button { padding: 0; border: 0; color: #52718a; background: none; }.breadcrumbs strong { max-width: 240px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.workspace-tools { display: flex; align-items: flex-end; gap: 7px; }.workspace-tools label { color: #727e87; font-size: 8px; font-weight: 800; }.workspace-tools select { display: block; height: 28px; margin-top: 2px; border: 1px solid #d0d7dc; border-radius: 5px; background: white; font-size: 9px; }.workspace-tools button { height: 28px; padding: 0 9px; border: 1px solid #d0d7dc; border-radius: 5px; color: #55636d; background: white; font-size: 9px; font-weight: 800; }.workspace-tools button[aria-pressed="true"] { color: white; background: var(--navy); }
.canvas-viewport { flex: 1; min-height: 0; display: grid; place-items: center; padding: 30px; overflow: auto; background-image: radial-gradient(#c6cfd4 1px, transparent 1px); background-size: 18px 18px; }
.canvas-scaler { position: relative; flex: none; transform-origin: top left; box-shadow: 0 22px 55px rgba(20,37,50,.23), 0 2px 7px rgba(20,37,50,.12); }
.design-canvas { position: relative; width: 1200px; height: 900px; overflow: hidden; background: white; outline: none; transform-origin: top left; user-select: none; }
.design-canvas.show-grid { background-image: linear-gradient(rgba(16,42,67,.08) 1px,transparent 1px),linear-gradient(90deg,rgba(16,42,67,.08) 1px,transparent 1px); background-size: 20px 20px; }
.canvas-layer { position: absolute; min-width: 10px; min-height: 10px; transform-origin: center; cursor: move; touch-action: none; }
.canvas-layer.locked { cursor: not-allowed; }
.canvas-layer.selected::after { content: ""; position: absolute; z-index: 999; inset: -2px; border: 2px solid #2d82da; pointer-events: none; }
.layer-content { width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
.canvas-layer.type-text .layer-content { white-space: pre-wrap; overflow-wrap: anywhere; }
.canvas-layer.type-image .layer-content { background-position: center; background-repeat: no-repeat; }
.canvas-layer.type-video .layer-content { position: relative; display: grid; place-items: center; color: white; background: #101820 center/cover; }
.canvas-layer.type-video .layer-content::after { content: "▶"; width: 54px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: #e52d27; font-size: 18px; }
.canvas-layer.type-shape .layer-content { border-style: solid; }
.canvas-layer.type-button .layer-content { display: flex; align-items: center; justify-content: center; font-weight: 800; text-align: center; }
.resize-handle { position: absolute; z-index: 1001; width: 12px; height: 12px; border: 2px solid white; border-radius: 2px; background: #2d82da; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.handle-nw { left: -7px; top: -7px; cursor: nwse-resize; }.handle-n { left: 50%; top: -7px; transform: translateX(-50%); cursor: ns-resize; }.handle-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.handle-e { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }.handle-se { right: -7px; bottom: -7px; cursor: nwse-resize; }.handle-s { left: 50%; bottom: -7px; transform: translateX(-50%); cursor: ns-resize; }
.handle-sw { left: -7px; bottom: -7px; cursor: nesw-resize; }.handle-w { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.rotate-handle { position: absolute; z-index: 1001; width: 12px; height: 12px; left: 50%; top: -31px; transform: translateX(-50%); border: 2px solid white; border-radius: 50%; background: #2d82da; box-shadow: 0 1px 3px rgba(0,0,0,.3); cursor: grab; }
.rotate-handle::after { content: ""; position: absolute; width: 1px; height: 17px; left: 50%; top: 10px; background: #2d82da; }
.canvas-footer { min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 13px; border-top: 1px solid #ced6db; color: #7c878f; background: #f6f8f9; font-size: 8px; }

.inspector { border-left: 1px solid var(--line); background: white; overflow-y: auto; }
.inspector-tabs { position: sticky; top: 0; z-index: 10; height: 50px; display: grid; grid-template-columns: repeat(4,1fr); border-bottom: 1px solid var(--line); background: white; }
.inspector-tabs button { border: 0; border-bottom: 3px solid transparent; color: #6d7881; background: white; font-size: 9px; font-weight: 850; }.inspector-tabs button.active { color: var(--navy); border-bottom-color: var(--yellow); }
.inspector-panel { padding: 18px; }
.inspector-panel label { display: block; margin-bottom: 13px; color: #59656e; font-size: 9px; font-weight: 800; }
.inspector-panel input[type="text"],.inspector-panel input[type="url"],.inspector-panel input[type="number"],.inspector-panel textarea,.inspector-panel select,.inspector-panel input[readonly] { width: 100%; min-height: 35px; margin-top: 5px; padding: 7px 8px; border: 1px solid #d6dce0; border-radius: 6px; color: var(--ink); background: white; font-size: 10px; resize: vertical; }
.inspector-panel input:focus,.inspector-panel textarea:focus,.inspector-panel select:focus { outline: 2px solid rgba(244,196,48,.55); border-color: #bea02e; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }.field-row.compact { grid-template-columns: repeat(4,1fr); gap: 5px; }.field-row.compact label { min-width: 0; }.field-row.compact input { padding: 5px; }
.type-controls { margin: 16px -18px 0; padding: 17px 18px 2px; border-top: 1px solid var(--line); }
.check-label { display: flex !important; align-items: center; gap: 7px; font-weight: 650 !important; }.check-label input { accent-color: var(--navy); }
.ratio-lock { margin: 2px 0 4px !important; padding: 9px 10px; border-radius: 6px; color: var(--navy) !important; background: #f1f5f7; font-weight: 800 !important; }
.ratio-help { margin: 0 0 14px; }
.inspector-panel input[type="color"] { width: 100%; height: 35px; display: block; margin-top: 5px; padding: 2px; border: 1px solid var(--line); border-radius: 5px; background: white; }
.field-help { margin: -6px 0 12px; color: #7d8991; font-size: 8px; line-height: 1.45; }.field-help.valid { color: #287040; }.field-help.invalid { color: var(--danger); }
.image-preview { aspect-ratio: 16/9; margin-bottom: 10px; border-radius: 6px; background: #e8ecef center/cover; }
.layer-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }.layer-buttons button { min-height: 34px; padding: 6px; border: 1px solid var(--line); border-radius: 5px; color: #56636d; background: white; font-size: 8px; font-weight: 800; }.layer-buttons button:hover { background: var(--soft); }.layer-buttons .danger { color: var(--danger); }
.empty-inspector { padding: 45px 8px; color: #7a858d; text-align: center; }.empty-inspector > span { display: grid; place-items: center; width: 47px; height: 47px; margin: auto; border-radius: 50%; color: #6b7c89; background: #eef2f4; font-size: 20px; }.empty-inspector h3 { margin: 13px 0 7px; color: var(--ink); font-size: 13px; }.empty-inspector p { margin: 0; font-size: 10px; line-height: 1.55; }
.help-card { margin-top: 22px; padding: 13px; border-radius: 7px; color: #586873; background: #f2f5f6; font-size: 9px; line-height: 1.55; }.help-card p { margin: 5px 0 0; }
.viewer-settings { margin: 18px -18px; padding: 17px 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fafbfc; }.viewer-settings h3 { margin: 0 0 12px; color: var(--navy); font-size: 11px; }.viewer-logo-preview { height: 78px; display: grid; place-items: center; margin-bottom: 8px; overflow: hidden; border: 1px dashed #bcc8cf; border-radius: 7px; color: #7b878f; background: white center/contain no-repeat; font-size: 9px; }.viewer-logo-preview.has-logo span { display: none; }.viewer-logo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 14px; }.viewer-logo-actions .button { min-height: 32px; padding: 5px 8px; font-size: 8px; }
.published-pill { display: inline-block; margin-bottom: 17px; padding: 6px 9px; border-radius: 15px; color: #27653b; background: #e9f5ec; font-size: 8px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.copy-input { display: flex; margin-top: 5px; }.copy-input input { margin: 0 !important; border-radius: 6px 0 0 6px !important; }.copy-input button { padding: 0 10px; border: 0; border-radius: 0 6px 6px 0; color: white; background: var(--navy); font-size: 8px; font-weight: 850; }

.dialog { width: min(450px,calc(100% - 30px)); padding: 0; border: 0; border-radius: 13px; box-shadow: 0 28px 90px rgba(0,0,0,.36); }.dialog::backdrop { background: rgba(6,22,34,.65); backdrop-filter: blur(4px); }.dialog form { position: relative; padding: 30px; }.dialog h2 { margin: 0 0 22px; color: var(--navy); font-size: 28px; letter-spacing: -.04em; }.dialog-close { position: absolute; right: 14px; top: 11px; border: 0; color: #7a858e; background: transparent; font-size: 24px; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 24px; padding: 10px 15px; border-radius: 7px; color: white; background: #17212b; box-shadow: 0 10px 28px rgba(0,0,0,.3); font-size: 10px; transform: translate(-50%,18px); opacity: 0; pointer-events: none; transition: .2s ease; }.toast.show { opacity: 1; transform: translate(-50%,0); }.toast.error { background: #8e2626; }

@media (max-width: 1150px) {
  .editor-view { grid-template-columns: 64px 150px minmax(390px,1fr) 270px; }
  .canvas-footer span:last-child { display: none; }
}
@media (max-width: 850px) {
  .editor-centre { display: none !important; }
  .editor-view { height: auto; min-height: calc(100vh - 66px); grid-template-columns: 58px 130px minmax(360px,1fr); overflow: visible; }
  .inspector { grid-column: 1/-1; border-left: 0; border-top: 1px solid var(--line); }
  .inspector-panel { max-width: 650px; margin: auto; }
  .workspace { min-height: 600px; }
  .library-view { padding: 35px 18px 60px; }
  .library-heading { display: block; }.search-field { display: block; margin-top: 24px; }.search-field input { width: 100%; }
}
@media (max-width: 600px) {
  .brand-button > span:last-child { display: none; }
  .save-status,.topbar .button.ghost { display: none !important; }
  .topbar { padding: 0 10px; }.top-actions { gap: 4px; }.topbar .button { padding: 6px 8px; font-size: 9px; }
  .editor-view { display: grid; grid-template-columns: 55px 1fr; }
  .page-sidebar { grid-column: 2; height: 150px; border-right: 0; }.page-list { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; }.page-item { min-width: 110px; }.page-actions { display: none; }
  .asset-toolbar { grid-row: 1/3; }.workspace { grid-column: 1/-1; min-height: 470px; }.inspector { grid-column: 1/-1; }
  .workspace-heading { padding: 7px 10px; }.workspace-tools label { display: none; }.canvas-viewport { padding: 14px; }
}
