/* Γραμματοσειρές των πλαισίων κειμένου (dist/fonts, αναλλοίωτα TTF με άδεια OFL: βλ. FONTS.md).
   font-display: block, ώστε η στοιχειοθεσία να μη μετρά ποτέ με άλλη γραμματοσειρά. */
@font-face { font-family: "GFS Didot"; src: url("fonts/GFSDidot-Regular.ttf") format("truetype"); font-style: normal; font-weight: normal; font-display: block; }
@font-face { font-family: "GFS Didot"; src: url("fonts/GFSDidotItalic.ttf") format("truetype"); font-style: italic; font-weight: normal; font-display: block; }
@font-face { font-family: "GFS Didot"; src: url("fonts/GFSDidotBold.ttf") format("truetype"); font-style: normal; font-weight: bold; font-display: block; }
@font-face { font-family: "GFS Didot"; src: url("fonts/GFSDidotBoldItalic.ttf") format("truetype"); font-style: italic; font-weight: bold; font-display: block; }
@font-face { font-family: "GFS Neohellenic"; src: url("fonts/GFSNeohellenic.ttf") format("truetype"); font-style: normal; font-weight: normal; font-display: block; }
@font-face { font-family: "GFS Neohellenic"; src: url("fonts/GFSNeohellenicItalic.ttf") format("truetype"); font-style: italic; font-weight: normal; font-display: block; }
@font-face { font-family: "GFS Neohellenic"; src: url("fonts/GFSNeohellenicBold.ttf") format("truetype"); font-style: normal; font-weight: bold; font-display: block; }
@font-face { font-family: "GFS Neohellenic"; src: url("fonts/GFSNeohellenicBoldItalic.ttf") format("truetype"); font-style: italic; font-weight: bold; font-display: block; }
@font-face { font-family: "Noto Serif"; src: url("fonts/NotoSerif-Regular.ttf") format("truetype"); font-style: normal; font-weight: normal; font-display: block; }
@font-face { font-family: "Noto Serif"; src: url("fonts/NotoSerif-Italic.ttf") format("truetype"); font-style: italic; font-weight: normal; font-display: block; }
@font-face { font-family: "Noto Serif"; src: url("fonts/NotoSerif-Bold.ttf") format("truetype"); font-style: normal; font-weight: bold; font-display: block; }
@font-face { font-family: "Noto Serif"; src: url("fonts/NotoSerif-BoldItalic.ttf") format("truetype"); font-style: italic; font-weight: bold; font-display: block; }
@font-face { font-family: "Noto Sans"; src: url("fonts/NotoSans-Regular.ttf") format("truetype"); font-style: normal; font-weight: normal; font-display: block; }
@font-face { font-family: "Noto Sans"; src: url("fonts/NotoSans-Italic.ttf") format("truetype"); font-style: italic; font-weight: normal; font-display: block; }
@font-face { font-family: "Noto Sans"; src: url("fonts/NotoSans-Bold.ttf") format("truetype"); font-style: normal; font-weight: bold; font-display: block; }
@font-face { font-family: "Noto Sans"; src: url("fonts/NotoSans-BoldItalic.ttf") format("truetype"); font-style: italic; font-weight: bold; font-display: block; }
@font-face { font-family: "Gentium Book Plus"; src: url("fonts/GentiumBookPlus-Regular.ttf") format("truetype"); font-style: normal; font-weight: normal; font-display: block; }
@font-face { font-family: "Gentium Book Plus"; src: url("fonts/GentiumBookPlus-Italic.ttf") format("truetype"); font-style: italic; font-weight: normal; font-display: block; }
@font-face { font-family: "Gentium Book Plus"; src: url("fonts/GentiumBookPlus-Bold.ttf") format("truetype"); font-style: normal; font-weight: bold; font-display: block; }
@font-face { font-family: "Gentium Book Plus"; src: url("fonts/GentiumBookPlus-BoldItalic.ttf") format("truetype"); font-style: italic; font-weight: bold; font-display: block; }
@font-face { font-family: "Fira Sans"; src: url("fonts/FiraSans-Regular.ttf") format("truetype"); font-style: normal; font-weight: normal; font-display: block; }
@font-face { font-family: "Fira Sans"; src: url("fonts/FiraSans-Italic.ttf") format("truetype"); font-style: italic; font-weight: normal; font-display: block; }
@font-face { font-family: "Fira Sans"; src: url("fonts/FiraSans-Bold.ttf") format("truetype"); font-style: normal; font-weight: bold; font-display: block; }
@font-face { font-family: "Fira Sans"; src: url("fonts/FiraSans-BoldItalic.ttf") format("truetype"); font-style: italic; font-weight: bold; font-display: block; }
/* Ποτέ ψεύτικα έντονα/πλάγια με τις γραμματοσειρές μας: μόνο οι μορφές που υπάρχουν ως αρχείο (textflow.js FACES).
   Ίδιος κανόνας στον renderer (print_server.py SHIPPED_FONTS_RULE), ώστε οθόνη και PS να μένουν ίδια. */
#paper [font-family*="GFS Didot"], #paper [font-family*="GFS Neohellenic"],
#paper [font-family*="Noto Serif"], #paper [font-family*="Noto Sans"],
#paper [font-family*="Gentium Book Plus"], #paper [font-family*="Fira Sans"] { font-synthesis: none; }

:root {
  color-scheme: light;
  --ink: #26332e;
  --muted: #66746e;
  --line: #d9e0da;
  --paper: #fff;
  --panel: #f8faf7;
  --workspace: #e3e9e2;
  --green: #173c32;
  --green-deep: #102d26;
  --green-pale: #e5efe8;
  --accent: #dcedb4;
  font-family: "Aptos", "Inter", system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
button:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #528166; outline-offset: 2px; }
button, input, textarea { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h2, h3 { margin: 0; }

.header {
  position: relative; z-index: 3; min-height: 64px;
  display: flex; align-items: center; gap: clamp(1rem, 3vw, 3rem);
  padding: .62rem 1.3rem; background: var(--green-deep); color: #f4f9f3;
}
.brand { display: flex; align-items: center; gap: .6rem; font-size: 1.38rem; font-weight: 710; letter-spacing: -.05rem; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px;
  background: var(--accent); color: var(--green-deep); font: italic 800 1.3rem Georgia, serif;
}
.menus { display: flex; align-items: center; gap: .3rem; flex: 1; }
.menus details { position: relative; }
.menus summary { list-style: none; cursor: pointer; padding: .56rem .65rem; border-radius: 6px; font-size: .9rem; font-weight: 560; }
.menus summary::-webkit-details-marker { display: none; }
.menus summary:hover, .menus details[open] summary { background: #ffffff16; }
.dropdown {
  position: absolute; top: calc(100% + .45rem); left: 0; min-width: 246px; padding: .32rem;
  color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 10px 34px #152e2326;
}
.dropdown button {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; padding: .55rem .65rem;
  color: inherit; background: transparent; border: 0; border-radius: 5px; text-align: left; font-size: .87rem;
}
.dropdown button:hover { background: var(--green-pale); }
/* Βήμα 3: υπομενού (όπως στο PM5), διαχωριστικά. Ανοίγουν με το ποντίκι και με το πληκτρολόγιο (focus-within). */
.dropdown hr { margin: .28rem .4rem; border: 0; border-top: 1px solid var(--line); }
.submenu { position: relative; }
.submenu-label::after { content: "›"; color: var(--muted); font-size: 1rem; line-height: 1; }
.submenu > .dropdown { display: none; top: -.36rem; left: calc(100% - .2rem); max-height: 70vh; overflow-y: auto; }
.submenu:hover > .dropdown, .submenu:focus-within > .dropdown { display: block; }
.submenu:hover > .submenu-label, .submenu:focus-within > .submenu-label { background: var(--green-pale); }
.dropdown button[aria-checked] { justify-content: flex-start; gap: .35rem; }
.dropdown button[aria-checked]::before { content: ""; display: inline-block; width: .9rem; color: var(--green); }
.dropdown button[aria-checked="true"]::before { content: "✓"; }
kbd { color: var(--muted); font: 500 .72rem system-ui, sans-serif; white-space: nowrap; }
.button {
  border: 1px solid transparent; border-radius: 7px; padding: .47rem .77rem; color: var(--ink);
  font-size: .85rem; font-weight: 640; white-space: nowrap;
}
.primary { background: var(--accent); color: var(--green-deep); }
.primary:hover { background: #e9f4cd; }
.outline { background: #fff; border-color: var(--line); }
.outline:hover, .quiet:hover { background: var(--green-pale); }
.quiet { background: transparent; font-size: 1.12rem; padding-inline: .48rem; }

.document-bar {
  display: flex; justify-content: space-between; gap: 1rem; align-items: center; min-height: 60px;
  background: #fff; padding: .45rem 1.25rem; border-bottom: 1px solid var(--line);
}
.document-title { min-width: 0; display: flex; gap: .75rem; align-items: center; }
#document-name {
  font-weight: 710; font-size: 1.18rem; color: var(--ink); border: 1px solid transparent; border-radius: 5px;
  width: min(29vw, 310px); min-width: 8rem; padding: .23rem .38rem;
}
#document-name:hover, #document-name:focus { border-color: var(--line); }
#save-status { color: var(--muted); font-size: .78rem; white-space: nowrap; }
#save-status.error { color: #982c1e; font-weight: 640; }
.document-actions { display: flex; align-items: center; gap: .42rem; }

.workspace { min-height: 0; display: grid; grid-template-columns: 186px minmax(0, 1fr) 258px; }
/* Μενού «Παράθυρο»: τα πάνελ κρύβονται (όπως οι παλέτες του PM5). */
.workspace.no-pages { grid-template-columns: minmax(0, 1fr) 258px; }
.workspace.no-inspector { grid-template-columns: 186px minmax(0, 1fr); }
.workspace.no-pages.no-inspector { grid-template-columns: minmax(0, 1fr); }
.workspace.no-pages > .pages-panel, .workspace.no-inspector > .inspector { display: none; }
.pages-panel, .inspector { display: flex; min-height: 0; flex-direction: column; background: var(--panel); }
.pages-panel { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }
/* Με πολλά πεδία (πλαίσια κειμένου) το πάνελ κυλά μόνο του, αντί να σπρώχνει όλο το παράθυρο. */
@media (min-width: 681px) { .inspector { overflow-y: auto; } .inspector .properties { flex: none; } }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: .4rem; min-height: 50px; padding: .55rem .86rem; border-bottom: 1px solid var(--line); }
.panel-heading h2, .layers-heading h3 { font-size: .9rem; font-weight: 730; }
.icon-button {
  width: 29px; height: 29px; padding: 0; border-radius: 6px; border: 1px solid var(--line);
  background: transparent; color: var(--green); font-weight: 680; display: grid; place-items: center;
}
.icon-button:hover, .fit-button:hover { background: var(--green-pale); }
a.icon-button { text-decoration: none; }
.page-list, .layers { min-height: 0; overflow: auto; }
.page-list { padding: .7rem .7rem 1rem; display: grid; align-content: start; gap: .48rem; }
.page-tile {
  display: grid; justify-items: center; gap: .43rem; color: var(--muted); font-size: .78rem; font-weight: 630;
  width: 100%; padding: .6rem .38rem; background: transparent; border: 1px solid transparent; border-radius: 8px;
}
.page-tile:hover { background: #eff3ee; }
.page-tile[aria-current="true"] { background: var(--green-pale); border-color: #adc8b4; color: var(--green); }
.thumbnail { width: 80px; height: 100px; display: grid; place-items: center; }
.thumbnail svg { background: white; max-width: 100%; max-height: 100%; display: block; box-shadow: 0 1px 5px #102b2430; }

.working-area { min-width: 0; min-height: 0; display: grid; grid-template-rows: 50px 1fr; }
.tools { background: #f3f6f1; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .3rem; padding-inline: .8rem; }
.tools button { display: grid; place-items: center; width: 35px; height: 34px; border: 1px solid transparent; background: transparent; border-radius: 6px; color: var(--green); }
.tools button[aria-pressed="true"] { background: #dce9de; border-color: #c7d8cb; }
.tools button:not(:disabled):hover { background: #e5eee5; }
.tools svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* Βήμα 3β: παλέτα ελέγχου στη μπάρα των εργαλείων (τα ίδια πεδία και κουμπιά, πιο πυκνά). */
.control-palette { margin-left: auto; display: flex; align-items: center; gap: .45rem; min-width: 0; }
.control-palette[hidden], .cp-view[hidden], .cp-modes[hidden] { display: none; }
.cp-view, .cp-modes { display: flex; align-items: center; gap: .25rem; }
.cp-modes { padding-right: .35rem; border-right: 1px solid var(--line); }
.control-palette label { display: flex; align-items: center; gap: .2rem; color: var(--muted); font-size: .74rem; font-weight: 640; }
.control-palette input, .control-palette select { width: 58px; height: 28px; padding: 0 .3rem; border: 1px solid var(--line); border-radius: 5px;
  background: #fff; color: var(--ink); font-size: .8rem; }
.control-palette select { width: 132px; }
.control-palette input:disabled { background: transparent; color: var(--muted); }
.control-palette button { width: 28px; height: 28px; font-size: .82rem; }
.control-palette .cp-align svg { width: 16px; height: 16px; }
.tool-divider { height: 22px; width: 1px; background: var(--line); margin-inline: .25rem; }
.studio {
  overflow: auto; min-height: 0; padding: 29px 35px 33px;
  background-image: radial-gradient(#c0ccc2 0.75px, transparent 0.75px); background-size: 15px 15px; background-color: var(--workspace);
}
.artboard { --ruler-size: 24px; position: relative; width: max-content; margin-inline: auto; }
/* Γύρος 2: αντικριστές σελίδες. Η ενεργή μένει το #paper, η απέναντι δίπλα της (χωρίς κενό, όπως στο ανοιχτό βιβλίο).
   Ο οριζόντιος χάρακας και οι οδηγοί μένουν στην ενεργή· ο κάθετος στην άκρη του ζεύγους. */
.artboard { padding-left: var(--spread-left, 0px); padding-right: var(--spread-right, 0px); }
.artboard > .ruler-horizontal { left: var(--spread-left, 0px); right: var(--spread-right, 0px); }
.artboard > .guides { left: var(--spread-left, 0px); right: var(--spread-right, 0px); }
.artboard > .facing { position: absolute; top: 0; cursor: pointer; }
.artboard > .facing.left { left: 0; }
.artboard > .facing.right { right: 0; }
.facing > svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.facing > .guides { inset: 0; }
/* Γύρος 2: μενού δεξιού κλικ, με την εμφάνιση των μενού της γραμμής. */
.context-menu { position: fixed; top: 0; left: 0; z-index: 60; max-height: calc(100vh - 16px); overflow: visible; }
.context-menu button:disabled { color: var(--muted); opacity: .5; cursor: default; }
.context-menu button:disabled:hover { background: transparent; }
.context-menu button:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; background: var(--green-pale); }
.context-menu .submenu > .dropdown.flip { left: auto; right: calc(100% - .2rem); }
/* Γύρος 2: «Αφαίρεση σελίδων…»: τι θα σβηστεί, πριν από την επιβεβαίωση. */
.remove-summary { max-width: 34em; font-size: 13px; line-height: 1.45; color: #355747; }
.remove-summary ul { margin: 4px 0 0; padding-left: 18px; }
.remove-summary.confirm { color: #1d3a32; font-weight: 600; }
.facing:hover { outline: 2px solid #7752a355; outline-offset: -2px; }
.paper { background: white; box-shadow: 0 2px 3px #172f2420, 0 15px 42px #1734271d; position: relative; }
.paper > svg { display: block; width: 100%; height: 100%; touch-action: none; }
.paper [data-editor-id] { cursor: move; }
.paper.text-marquee, .paper.text-marquee [data-editor-id] { cursor: crosshair; }
.paper.text-tool, .paper.text-tool [data-editor-id] { cursor: text; }
/* Υπερχείλιση πλαισίου κειμένου (όπως το ▼ του PM5), με το χρώμα σφάλματος που ήδη υπάρχει. */
/* «Ρολοκουρτίνες» του PM5 (Φάση 3): ○ αρχή/τέλος, + συνέχεια, κόκκινο ▼ υπερχείλιση. Τα + και ▼ είναι κουμπιά. */
.frame-handle { position: absolute; left: 50%; transform: translateX(-50%); min-width: 1.05rem; padding: 0 .2rem;
  color: #347e60; background: #fff; border: 1px solid #347e60; border-radius: 3px; font: 700 .72rem/1 system-ui, sans-serif;
  text-align: center; pointer-events: auto; }
.frame-handle.top { top: -.62rem; }
.frame-handle.bottom { bottom: -.62rem; }
button.frame-handle { cursor: pointer; }
.frame-overflow { color: #982c1e; border-color: #982c1e; }
.paper.text-loaded, .paper.text-loaded [data-editor-id] { cursor: copy; }
/* Ο τρόπος ροής φαίνεται στον κέρσορα: ημιαυτόματη (Shift) και αυτόματη. */
.paper.text-loaded.flow-semi, .paper.text-loaded.flow-semi [data-editor-id] { cursor: cell; }
.paper.text-loaded.flow-auto, .paper.text-loaded.flow-auto [data-editor-id] { cursor: alias; }
/* «Εμφάνιση ροής»: λεπτά βέλη ανάμεσα στα πλαίσια μιας σειράς, με το χρώμα της επιλογής. */
.flow-view { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.flow-view line { stroke: #347e60; stroke-width: 1; stroke-dasharray: 3 3; }
.flow-page { position: absolute; transform: translateX(-50%); padding: 0 .25rem; color: #347e60; background: #fff;
  font: 600 .7rem/1.4 system-ui, sans-serif; white-space: nowrap; pointer-events: none; }
#selection-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
/* Φάση 7: κέρσορας και επιλογή μέσα στο πλαίσιο (δικό τους στρώμα, ποτέ μέσα στο SVG της σελίδας). */
#inline-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.inline-caret { position: absolute; background: var(--ink); width: 1px !important; animation: inline-blink 1.06s steps(1) infinite; }
.inline-selection { position: absolute; background: #347e6038; }
#inline-overlay.inactive .inline-caret { display: none; }
#inline-overlay.inactive .inline-selection { background: #66746e26; }
@keyframes inline-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .inline-caret { animation: none; } }
/* Το κρυφό πεδίο εισόδου (νεκροί τόνοι, IME): στη θέση του κέρσορα, ώστε το παράθυρο του IME να ανοίγει εκεί. */
.inline-input { position: absolute; left: 0; top: 0; width: 1px; height: 1em; padding: 0; border: 0; margin: 0; opacity: 0;
  resize: none; overflow: hidden; pointer-events: none; z-index: 0; font-size: 12px; }
.selection { position: absolute; outline: 1px dashed #347e60; }
.selection.is-group { pointer-events: auto; cursor: move; touch-action: none; }
.marquee-box { position: absolute; border: 1px dashed #347e60; background: #347e6024; }
.resize-handle {
  position: absolute; width: 14px; height: 14px; padding: 0; transform: translate(-50%, -50%);
  border: 0; background: transparent; pointer-events: auto; touch-action: none;
}
.resize-handle::before { content: ""; display: block; width: 8px; height: 8px; margin: auto; background: #fff; border: 1px solid #347e60; }
.resize-handle:hover::before { background: #347e60; }
.resize-handle[data-corner="nw"], .resize-handle[data-corner="se"] { cursor: nwse-resize; }
.resize-handle[data-corner="ne"], .resize-handle[data-corner="sw"] { cursor: nesw-resize; }
.resize-hint { padding-block: .5rem; }
.ruler, .ruler-corner { position: absolute; color: #355747; background: #f2f6f1; box-shadow: inset 0 0 0 1px #c9d5cb; }
.ruler-horizontal { inset: calc(-1 * var(--ruler-size)) 0 auto; height: var(--ruler-size); }
.ruler-vertical { inset: 0 auto 0 calc(-1 * var(--ruler-size)); width: var(--ruler-size); }
.ruler-corner { inset: calc(-1 * var(--ruler-size)) auto auto calc(-1 * var(--ruler-size)); display: grid; place-items: center; width: var(--ruler-size); height: var(--ruler-size); font-size: 10px; }
.ruler svg { display: block; width: 100%; height: 100%; }
.ruler path { stroke: #789486; stroke-width: 1; fill: none; }
.ruler text { fill: currentColor; font: 10px ui-monospace, monospace; }
.ruler-setting { display: grid; gap: .35rem; padding: .5rem; font-size: .82rem; }
.ruler-setting select { width: 100%; padding: .32rem; font: inherit; color: var(--ink); }
.guide-toggle { display: flex; align-items: center; gap: .4rem; padding: .35rem .5rem; font-size: .82rem; }
.guide-toggle input { accent-color: var(--green); }
.guides { position: absolute; inset: 0; pointer-events: none; }
.guides > span { position: absolute; border: 0 dashed #7752a3aa; }
.guides > .column-guide { border-color: #276d94a8; }
.guides > .guide-x { inset-block: 0; border-left-width: 1px; }
.guides > .guide-y { inset-inline: 0; border-top-width: 1px; }
#guide-dialog { width: min(360px, calc(100% - 32px)); padding: 1.15rem; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fbfcfa; }
#guide-dialog::backdrop { background: #172f2460; }
.guide-form { display: grid; gap: .75rem; }
.guide-form h2 { margin: 0 0 .25rem; font-size: 1.1rem; }
.guide-form label { display: grid; gap: .25rem; font-size: .85rem; }
.guide-form input { width: 100%; padding: .4rem; border: 1px solid var(--line); border-radius: 4px; font: inherit; }
.guide-actions { display: flex; justify-content: flex-end; gap: .5rem; }
#guide-error { margin: 0; color: #982c1e; font-size: .82rem; }
#ai-dialog, #projects-dialog, #story-dialog, #aibook-dialog, #ai-notice-dialog { width: min(580px, calc(100% - 28px)); max-height: calc(100dvh - 36px); padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fbfcfa; }
#ai-dialog::backdrop, #projects-dialog::backdrop, #story-dialog::backdrop, #aibook-dialog::backdrop, #ai-notice-dialog::backdrop { background: #172f246b; }
/* Παράθυρο «Έργα»: ίδιο με το παράθυρο AI· η λίστα χρησιμοποιεί το στυλ .layer των αντικειμένων. */
.project-list { height: min(46dvh, 380px); padding: .3rem; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.project-list .layer { grid-template-columns: 44px minmax(0, 1fr); }
.project-list .thumbnail { width: 44px; height: 56px; }
.project-text { display: grid; gap: .12rem; min-width: 0; }
.project-tools { display: flex; flex-wrap: wrap; gap: .35rem; }
.ai-panel { padding: 1.05rem 1.15rem; }
.ai-heading, .ai-actions { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.ai-heading { margin-bottom: .85rem; }
.ai-heading h2 { font-size: 1.15rem; }
.ai-form, .ai-preview, .ai-form label { display: grid; gap: .55rem; min-width: 0; }
.ai-form label { gap: .22rem; font-size: .82rem; }
.ai-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.ai-inline { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .45rem; }
.ai-form input:not([type=checkbox]), .ai-form select, .ai-form textarea { width: 100%; min-width: 0; padding: .42rem .48rem; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: white; font: inherit; }
.ai-form textarea { resize: vertical; }
.ai-form .ai-check { display: flex; align-items: center; }
.ai-help, .ai-status { color: var(--muted); font-size: .78rem; margin: 0; }
.ai-status { margin-top: .55rem; }
.ai-status.error { color: #982c1e; }
/* Βήμα 8: λίστα γραμματοσειρών του χρήστη (ίδιο στυλ .layer, όνομα · ελληνικά · ×). */
#fonts-list { max-height: min(40dvh, 320px); overflow: auto; border: 1px solid var(--line); border-radius: 5px; background: #fff; padding: .3rem; }
#fonts-list .layer { grid-template-columns: minmax(0, 1fr) auto auto; }
.font-greek { color: var(--muted); font-size: .74rem; }
/* Βήμα 10: γραμματοσειρά από χειρόγραφο. */
.fontmaker { border: 1px solid var(--line); border-radius: 5px; padding: .5rem .7rem; background: #fff; }
.fontmaker summary { cursor: pointer; font-weight: 600; font-size: .84rem; }
.fontmaker ol { margin: .5rem 0; padding-left: 1.2rem; }
.fontmaker a { color: var(--green); font-weight: 600; }
.fontmaker-preview { margin: .5rem 0 0; font-size: 1.6rem; line-height: 1.3; overflow-wrap: anywhere; }
/* Βήμα 9: «AI για το βιβλίο»: πρόοδος και σύγκριση δίπλα-δίπλα (αρχικό | αποτέλεσμα), ένα τικ ανά παράγραφο. */
#aibook-progress { width: 100%; height: .5rem; accent-color: var(--green); }
.aibook-compare { max-height: min(46dvh, 420px); overflow: auto; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.aibook-compare:empty { display: none; }
/* Οι διάλογοι των φάσεων 6–9 με το ίδιο πλαίσιο με τους υπόλοιπους (έλειπε: έβγαιναν με το μαύρο πλαίσιο του browser). */
#fonts-dialog, #press-dialog, #booklet-dialog, #note-dialog, #toc-dialog { width: min(580px, calc(100% - 28px)); max-height: calc(100dvh - 36px); padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fbfcfa; }
#fonts-dialog::backdrop, #press-dialog::backdrop, #booklet-dialog::backdrop, #note-dialog::backdrop, #toc-dialog::backdrop { background: #172f246b; }
#aibook-dialog { width: min(940px, calc(100% - 28px)); }
.aibook-row > div { min-width: 0; max-height: 9.6em; overflow: auto; overflow-wrap: anywhere; }
.aibook-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; padding: .45rem .55rem; border-bottom: 1px solid var(--line); font-size: .8rem; line-height: 1.45; }
.aibook-row:last-child { border-bottom: 0; }
.aibook-row .aibook-before { color: var(--muted); }
.aibook-row del { background: #f6dcd7; text-decoration: line-through; }
.aibook-row ins { background: #d9ecdc; text-decoration: none; }
.aibook-row .aibook-number { grid-column: 2 / -1; color: var(--muted); font-size: .72rem; }
.ai-preview { border-top: 1px solid var(--line); padding-top: .65rem; }
.ai-preview > button { justify-self: end; }
.ai-image-preview { position: relative; width: fit-content; max-width: 100%; margin-inline: auto; }
.ai-image-preview img { display: block; max-width: 100%; max-height: 240px; width: auto; height: auto; border-radius: 5px; }
.ai-image-preview.cover img { width: 100%; height: 100%; object-fit: cover; }
.ai-image-preview.cover { height: 240px; max-height: 44vh; }
#ai-cover-preview { display: grid; gap: .25rem; position: absolute; inset: auto 0 0; padding: .75rem; color: white; background: #102d26d9; overflow-wrap: anywhere; }
#ai-cover-preview strong { font: bold 1.1rem Georgia, serif; }
#ai-cover-preview span { font-size: .7rem; }

.object-kind { color: var(--muted); font-size: .73rem; }
.empty { font-size: .88rem; color: var(--muted); padding: .9rem; }
.properties { padding: .82rem; border-bottom: 1px solid var(--line); }
.properties label { display: grid; gap: .32rem; min-width: 0; color: var(--muted); font-size: .80rem; font-weight: 640; }
.properties input, .properties textarea, .properties select {
  width: 100%; min-width: 0; color: var(--ink); background: #fff; padding: .39rem .46rem;
  border: 1px solid var(--line); border-radius: 5px; font-size: .87rem; font-weight: 500;
}
.properties textarea { resize: vertical; }
.properties input[type="color"] { min-height: 34px; padding: .17rem .25rem; }
.property-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .58rem; }
#font-field { grid-column: 1 / -1; }
#indent-first-field { grid-column: 1 / -1; }
#unthread-frame { width: 100%; margin-top: .7rem; }
/* Συλλαβισμός «Όχι»: οι ρυθμίσεις του δεν ισχύουν, με την ίδια ένδειξη που έχουν τα ανενεργά κουμπιά. */
#hyphen-limit-field:has(:disabled), #hyphen-before-field:has(:disabled), #hyphen-after-field:has(:disabled),
#hyphen-zone-field:has(:disabled) { opacity: .4; }
#text-field { margin-bottom: .7rem; }
.layers-heading { display: flex; align-items: center; justify-content: space-between; padding: .73rem .86rem .46rem; }
#object-count { color: var(--muted); font-size: .74rem; font-variant-numeric: tabular-nums; }
.layers { padding: 0 .51rem .65rem; }
.layer {
  display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: .45rem; width: 100%;
  padding: .45rem .46rem; text-align: left; color: var(--ink); background: transparent; border: 1px solid transparent;
  border-radius: 5px; font-size: .82rem; min-width: 0;
}
.layer:hover { background: #eef3ee; }
.layer[aria-pressed="true"] { background: var(--green-pale); color: var(--green); border-color: #c3d6c7; }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-symbol { color: #48725a; font-weight: 710; text-align: center; }

.status-bar {
  z-index: 1; min-height: 35px; display: grid; grid-template-columns: 1fr minmax(0, 2fr) 1fr;
  gap: .45rem; align-items: center; font-size: .76rem; color: var(--muted);
  border-top: 1px solid var(--line); background: #fbfcfa; padding: .2rem .85rem;
}
.status-message { text-align: center; color: var(--green); }
.status-message.error { color: #982c1e; }
.zoom { display: flex; align-items: center; gap: .3rem; justify-content: end; }
.zoom .icon-button { width: 23px; height: 23px; font-size: .85rem; }
.fit-button { min-width: 68px; border: 0; background: transparent; color: var(--green); padding: .2rem .4rem; font: inherit; border-radius: 4px; }
#print-pages { display: none; }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 116px minmax(0, 1fr) 210px; }
  .page-list { padding-inline: .42rem; }
  .header { gap: .95rem; }
  .status-bar { grid-template-columns: 1fr 2fr auto; }
}
@media (max-width: 680px) {
  body { overflow: auto; height: auto; min-height: 100dvh; grid-template-rows: auto auto minmax(650px, 1fr) auto; }
  .header { flex-wrap: wrap; justify-content: space-between; padding: .6rem .8rem; gap: .45rem; }
  .menus { order: 3; flex: 1 1 100%; gap: 0; }
  .menus summary { padding-inline: .48rem; }
  .menus details:last-child .dropdown { left: auto; right: 0; }
  .document-bar { padding-inline: .55rem; gap: .25rem; }
  #document-name { font-size: .95rem; width: 32vw; min-width: 5.5rem; }
  #save-status { display: none; }
  .document-actions { gap: .2rem; }
  .button { font-size: .76rem; padding-inline: .45rem; }
  .workspace { grid-template-columns: 68px minmax(0, 1fr); grid-template-rows: minmax(400px, 55dvh) auto; }
  .inspector { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .pages-panel .panel-heading { padding: .35rem .2rem; gap: .1rem; }
  .pages-panel .panel-heading h2 { font-size: .67rem; }
  .pages-panel .icon-button { width: 19px; height: 23px; }
  .thumbnail { width: 43px; height: 56px; }
  .layers { max-height: 200px; }
  .studio { padding-inline: 26px; }
  .status-bar { grid-template-columns: auto 1fr auto; font-size: .68rem; }
}
@media print {
  @page { margin: 0; }
  body { display: block; overflow: visible; height: auto; }
  body > :not(#print-pages) { display: none !important; }
  #print-pages { display: block; }
  #print-pages svg { display: block; print-color-adjust: exact; break-after: page; }
  #print-pages svg:last-child { break-after: auto; }
}
/* Story Editor (Φάση 5): απλό κείμενο με τα πεδία της εφαρμογής· το μαλακό ενωτικό ως αχνό σύμβολο. */
/* 5β.3: ο Story Editor δεν μπλοκάρει τη σελίδα· στέκεται αριστερά, πάνω από τη σελίδα, και μετακινείται. */
/* Αλλάζει μέγεθος από τη γωνία (resize): το κείμενο παίρνει όλο τον χώρο που περισσεύει. */
#story-dialog { position: fixed; inset: 184px auto auto 196px; margin: 0; z-index: 30; width: min(640px, calc(100% - 28px));
  height: min(640px, calc(100dvh - 200px)); min-width: 380px; min-height: 360px; max-width: calc(100vw - 8px); max-height: calc(100dvh - 8px);
  overflow: hidden; resize: both; box-shadow: 0 12px 34px #172f2440; }
#story-dialog .ai-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; box-sizing: border-box; }
#story-dialog .ai-form { grid-template-rows: auto minmax(120px, 1fr) auto auto auto; min-height: 0; }
#story-dialog .story-body { height: auto; min-height: 0; }
#story-dialog .ai-heading { cursor: move; user-select: none; }
/* 5β.3: πού πάνε οι αλλαγές του πάνελ, παλέτα «Στυλ» (λίστες .layer) και παράθυρο «Στυλ…». */
.text-scope { margin: .55rem 0 0; padding: .4rem .55rem; border-radius: 5px; background: var(--green-pale); color: var(--green); font-size: .8rem; font-weight: 640; }
.styles-field { margin: .6rem 0 .8rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
.styles-heading { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-bottom: .35rem; }
.styles-heading h3 { font-size: .85rem; font-weight: 730; }
.styles-tools { display: flex; gap: .25rem; }
.styles-tools .button { padding: .15rem .45rem; font-size: .74rem; }
.style-list { display: grid; gap: .15rem; max-height: 190px; overflow: auto; }
.style-list .layer { grid-template-columns: minmax(0, 1fr) auto; }
#style-dialog { width: min(560px, calc(100% - 28px)); max-height: calc(100dvh - 36px); padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fbfcfa; }
#style-dialog::backdrop { background: #172f246b; }
/* 5β.2α: «Λέξεις συλλαβισμού…». */
#hyphen-dialog { width: min(520px, calc(100% - 28px)); max-height: calc(100dvh - 36px); padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fbfcfa; }
#hyphen-dialog::backdrop { background: #172f246b; }
.hyphen-add { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .5rem; align-items: end; }
.hyphen-add label { display: grid; gap: .3rem; color: var(--muted); font-size: .8rem; font-weight: 640; }
.hyphen-preview { min-height: 1.1em; }
.hyphen-list { max-height: 260px; overflow: auto; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.hyphen-list:empty { display: none; }
.hyphen-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .5rem; padding: .1rem .3rem .1rem .55rem; border-bottom: 1px solid var(--line); }
.hyphen-list li:last-child { border-bottom: 0; }
.hyphen-entry { padding: .3rem 0; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.hyphen-entry:hover { text-decoration: underline; }
.hyphen-where { color: var(--muted); font-size: .75rem; }
#hyphen-words { grid-column: 1 / -1; justify-self: start; }
.style-group { margin: 0; padding: .5rem .6rem .6rem; border: 1px solid var(--line); border-radius: 6px; }
.style-group legend { padding: 0 .3rem; color: var(--muted); font-size: .8rem; font-weight: 700; }
.style-group label { display: grid; gap: .3rem; color: var(--muted); font-size: .8rem; font-weight: 640; }
#style-dialog .guide-toggle { display: flex; align-items: center; gap: .45rem; margin-top: .55rem; }
#style-dialog .guide-toggle input { width: auto; margin: 0; }
/* 5β.2: αριστερή στήλη με το στυλ κάθε παραγράφου (όπως στο PM5), που κυλά μαζί με το κείμενο. */
.story-body { position: relative; display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); height: min(52dvh, 460px); overflow: auto;
  border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.story-body:focus-within { outline: 2px solid #347e60; outline-offset: 1px; }
.story-styles { position: relative; border-right: 1px solid var(--line); background: #f3f6f3; }
.story-styles button { position: absolute; left: 0; right: 0; padding: 0 .45rem; border: 0; background: none; color: var(--muted);
  font: 400 .78rem/1.9 system-ui, sans-serif; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.story-styles button:hover, .story-styles button.current { color: var(--ink); background: #e3ebe5; }
.story-text { min-height: 100%; box-sizing: border-box; padding: .55rem .65rem; outline: none;
  color: var(--ink); font: 400 .95rem/1.55 "GFS Didot", Georgia, serif; white-space: pre-wrap; overflow-wrap: anywhere; }
/* 5β.5: μορφή χαρακτήρων στον Story Editor (μόνο έντονα, πλάγια, υπογράμμιση, εκθέτης/δείκτης). */
.story-text .b { font-weight: 700; }
.story-text .i { font-style: italic; }
.story-text .u { text-decoration: underline; text-underline-offset: 2px; }
.story-text .sup, .story-text .sub { font-size: .72em; line-height: 0; }
.story-text .sup { vertical-align: .45em; }
.story-text .sub { vertical-align: -.25em; }
#story-dialog .ai-row:has(.story-format) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.story-format { display: flex; gap: 2px; align-self: end; }
.story-format button { min-width: 30px; height: 32px; padding: 0 .4rem; border: 1px solid var(--line); border-radius: 6px; background: #fff;
  color: var(--ink); font: 400 .9rem/1 system-ui, sans-serif; cursor: pointer; }
.story-format button[aria-pressed="true"] { background: #e3ebe5; border-color: #347e60; }
.story-format button:disabled { opacity: .5; cursor: default; }
.story-text .shy { color: var(--muted); opacity: .55; font-weight: 700; padding: 0 1px; border-bottom: 1px dotted currentColor; cursor: default; }
#story-dialog .guide-toggle { display: flex; align-items: center; gap: .45rem; justify-self: start; color: var(--muted); font-size: .85rem; }
#story-dialog .guide-toggle input { width: auto; margin: 0; }
/* Κουμπιά μέσα στη γραμμή μηνυμάτων (B35): τα υπάρχοντα button outline, μικρότερα. */
.status-message .message-action { padding: .12rem .5rem; font-size: .78rem; vertical-align: baseline; }

/* Βήμα 3γ: διάλογοι Διαμόρφωση σελίδας, Χαρακτηριστικά γραμμάτων, Παράγραφος, Εσοχές και στηλοθέτες. */
#place-dialog .style-group .guide-toggle, #page-dialog .style-group .guide-toggle, #type-dialog .style-group .guide-toggle, #para-dialog .style-group .guide-toggle {
  display: flex; align-items: center; gap: .45rem; padding: .2rem 0; }
#type-dialog .style-group, #para-dialog .style-group { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem .6rem; }
.dialog-scope, .page-count, .tabs-empty { margin: 0; color: var(--muted); font-size: .8rem; }
#tabs-dialog .ai-inline { grid-template-columns: 1fr 1fr 1fr auto; }
#tabs-list:empty { display: none; }
#tabs-list .layer { display: grid; grid-template-columns: 1fr 1fr 1fr auto; align-items: center; gap: .45rem; }
.tab-ruler { position: relative; height: 26px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); overflow: hidden; }
.tab-ruler span { position: absolute; bottom: 0; width: 0; height: 9px; border-left: 1px solid var(--muted); }
.tab-ruler span.major { height: 14px; }
.tab-ruler b { position: absolute; top: 1px; transform: translateX(-50%); font-size: .68rem; color: var(--ink); line-height: 1; }
.tab-ruler i { position: absolute; bottom: 0; transform: translateX(-50%); font-style: normal; font-size: .7rem; color: var(--green); }
.story-text .page-number { color: var(--green); opacity: 1; border-bottom: 0; }
.story-text .footnote { color: var(--green); opacity: 1; border-bottom: 0; vertical-align: super; font-size: 75%; }

/* Βήμα 4: master σελίδες στο πάνελ «Σελίδες» (όπως τα εικονίδια L/R του PM5). */
.master-tiles { display: flex; justify-content: center; gap: .4rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.master-tile { width: 34px; height: 42px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper);
  color: var(--muted); font-weight: 700; font-size: .85rem; }
.master-tile:hover { background: #eff3ee; }
.master-tile[aria-current="true"] { background: var(--green-pale); border-color: #adc8b4; color: var(--green); }
/* Βήμα 5: μικρά κεφαλαία και αριθμοί παλαιού τύπου στον Story Editor. */
.story-text .sc { font-variant-caps: small-caps; }
.story-text .os { font-variant-numeric: oldstyle-nums; }
/* Βήμα 11: σελίδα σύνδεσης (live server) και λογαριασμός. */
body.login-page { grid-template-rows: auto minmax(0, 1fr); overflow: auto; background: var(--canvas, #e6e9e4); }
.login-main { display: grid; place-items: center; padding: 2rem 1rem; }
.login-panel { width: min(380px, 100%); border: 1px solid var(--line); border-radius: 12px; background: #fbfcfa; box-shadow: 0 10px 30px #172f2418; }
.login-panel h1 { margin: 0 0 .9rem; font-size: 1.25rem; }
#account-dialog { width: min(460px, calc(100% - 28px)); max-height: calc(100dvh - 36px); padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fbfcfa; }
#account-dialog::backdrop { background: #172f246b; }
.story-text .shy.linebreak { border-bottom: 0; }
.story-text .shy.linebreak::after { content: "\A"; white-space: pre; }
