:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.hero {
    background: linear-gradient(135deg, #0f172a, #1d4ed8);
    color: white;
    padding: 22px clamp(18px, 4vw, 56px) 46px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 42px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 20px;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: white;
    color: var(--primary);
    font-size: 13px;
    letter-spacing: 0.06em;
}

.ghost-link {
    color: white;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 10px 16px;
    border-radius: 999px;
}

.hero-content {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
    gap: 36px;
    align-items: center;
    max-width: 1180px;
    margin: 0 auto;
}

.eyebrow {
    color: #bfdbfe;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 13px;
}

h1 {
    margin: 0;
    font-size: clamp(38px, 6vw, 68px);
    line-height: 1;
    letter-spacing: -0.05em;
}

.hero-text {
    max-width: 720px;
    font-size: 19px;
    line-height: 1.6;
    color: #dbeafe;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 24px;
}

.primary-upload,
.primary-btn,
.secondary-btn,
.tool-btn,
.page-action {
    border: 0;
    border-radius: 14px;
    padding: 13px 18px;
    font-weight: 700;
}

.primary-upload,
.primary-btn {
    background: var(--primary);
    color: white;
}

.primary-upload:hover,
.primary-btn:hover { background: var(--primary-dark); }

.primary-upload input { display: none; }

.secondary-btn {
    background: #eef2ff;
    color: #1e3a8a;
}

.secondary-btn:hover { background: #dbeafe; }

.hero-card {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 26px;
    padding: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.hero-card ul {
    margin: 18px 0 0;
    padding-left: 20px;
    color: #eff6ff;
    line-height: 1.9;
}

.editor-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    min-height: calc(100vh - 420px);
}

.toolbar-panel {
    position: sticky;
    top: 0;
    align-self: start;
    min-height: 100vh;
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 24px;
}

.toolbar-panel h2 { margin-top: 0; }

.tool-group {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.tool-btn {
    background: #f3f4f6;
    color: #111827;
    text-align: left;
}

.tool-btn.active {
    background: #dbeafe;
    color: #1e40af;
    outline: 2px solid #93c5fd;
}

.tool-card {
    display: grid;
    gap: 8px;
    background: #f9fafb;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px;
    margin-bottom: 14px;
}

.tool-card label {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

.tool-card input,
.tool-card select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    background: white;
}

.check-card small {
    color: var(--muted);
    line-height: 1.35;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text) !important;
}

.inline-check input {
    width: auto;
}

.full { width: 100%; }

.status-box {
    border-radius: 18px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    padding: 14px;
    color: var(--muted);
    line-height: 1.5;
}

.workspace {
    padding: 34px;
    overflow: auto;
}

.empty-state {
    min-height: 420px;
    cursor: pointer;
    display: grid;
    place-items: center;
    text-align: center;
    background: white;
    border: 2px dashed #cbd5e1;
    border-radius: 28px;
    color: var(--muted);
}

.empty-state > * { max-width: 420px; }
.empty-state .primary-btn { margin-top: 18px; }
.empty-state:focus-visible { outline: 3px solid #93c5fd; outline-offset: 4px; }
.empty-state h2 { color: var(--text); margin: 10px 0 0; }
.empty-icon {
    width: 74px;
    height: 74px;
    margin: 0 auto 8px;
    display: grid;
    place-items: center;
    border-radius: 24px;
    background: #dbeafe;
    color: var(--primary);
    font-size: 42px;
    font-weight: 300;
}

.pages-container {
    display: grid;
    gap: 34px;
    justify-content: center;
}

.page-shell {
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--line);
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}

.page-actions {
    display: flex;
    gap: 8px;
}

.page-action {
    padding: 8px 12px;
    background: white;
    color: #374151;
    border: 1px solid var(--line);
}

.page-action.danger { color: var(--danger); }

.page-canvas-wrap {
    position: relative;
    line-height: 0;
    margin: 0 auto;
    background: white;
}

.pdf-canvas {
    display: block;
}

.annotation-layer {
    position: absolute;
    inset: 0;
    cursor: crosshair;
}

.annotation {
    position: absolute;
    pointer-events: none;
    line-height: 1.15;
    white-space: pre-wrap;
}

.annotation.text {
    padding: 0;
    overflow: visible;
    border: 1px dashed rgba(37, 99, 235, 0.55);
}

.annotation-text-content {
    width: 100%;
    height: 100%;
    padding: 4px 6px;
    overflow: hidden;
    line-height: 1.2;
    white-space: pre-wrap;
    outline: none;
}

.annotation.rect {
    border-radius: 2px;
}

.annotation.signature {
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.draw-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.help-dialog {
    max-width: 560px;
    border: 0;
    border-radius: 24px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.help-dialog::backdrop { background: rgba(15, 23, 42, 0.55); }

.error-page {
    max-width: 760px;
    margin: 80px auto;
    background: white;
    padding: 40px;
    border-radius: 24px;
    box-shadow: var(--shadow);
}

@media (max-width: 900px) {
    .hero-content,
    .editor-shell { grid-template-columns: 1fr; }
    .toolbar-panel {
        position: relative;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
}

.page-shell.page-deleted {
    opacity: 0.45;
    filter: grayscale(1);
}

.page-shell.page-deleted .page-canvas-wrap::after {
    content: "Pagina esclusa dal download";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.55);
    color: #991b1b;
    font-size: 26px;
    font-weight: 800;
    z-index: 10;
    pointer-events: none;
}

.annotation {
    pointer-events: auto;
    cursor: move;
    outline: 1px dashed transparent;
}

.annotation.text {
    line-height: 1.2;
    cursor: move;
}

.annotation.text:focus-within {
    outline: 2px solid #2563eb;
}

.annotation.signature,
.annotation.image {
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center;
}

.annotation.selected {
    outline: 2px solid #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
    z-index: 20;
}

.resize-handle {
    position: absolute;
    right: -13px;
    bottom: -13px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #2563eb;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .28);
    cursor: nwse-resize;
    display: none;
}

.annotation.selected .resize-handle {
    display: block;
}

.annotation-menu-btn {
    position: absolute;
    right: -42px;
    top: -4px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 999px;
    background: #111827;
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .25);
    z-index: 35;
}

.annotation.selected .annotation-menu-btn,
.annotation:hover .annotation-menu-btn {
    display: flex;
}

.annotation-menu {
    position: absolute;
    left: calc(100% + 12px);
    top: 0;
    min-width: 190px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .22);
    z-index: 40;
}

.annotation-menu[hidden] { display: none; }

.annotation-menu button {
    width: 100%;
    border: 0;
    background: transparent;
    color: #111827;
    text-align: left;
    padding: 9px 10px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

.annotation-menu button:hover { background: #f3f4f6; }
.annotation-menu button.danger { color: var(--danger); }

.page-shell.page-deleted .page-toolbar {
    background: #fef2f2;
}


.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.cookie-banner {
    position: fixed;
    left: 18px;
    right: 18px;
    bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
    z-index: 9999;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0; line-height: 1.45; color: var(--muted); }
.cookie-banner div { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cookie-banner a { color: var(--primary); font-weight: 800; text-decoration: none; }

.annotation-menu,
.annotation-menu *,
.annotation-menu-btn,
.resize-handle {
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.annotation-menu-btn {
    font-size: 18px !important;
}

@media (max-width: 900px) {
    .cookie-banner { align-items: flex-start; flex-direction: column; }
}

/* SEO landing pages */
.seo-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1f1556 0%, #3b1c92 50%, #f8fafc 50%);
    color: #111827;
}
.seo-wrapper {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 60px;
}
.seo-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
    gap: 28px;
    align-items: center;
    padding: 42px 0 28px;
    color: white;
}
.seo-hero h1 {
    font-size: clamp(2.1rem, 5vw, 4.4rem);
    line-height: .98;
    margin: 8px 0 18px;
    letter-spacing: -0.05em;
}
.seo-hero p {
    font-size: 1.08rem;
    line-height: 1.7;
    max-width: 780px;
    color: rgba(255,255,255,.82);
}
.seo-card, .seo-section {
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(148, 163, 184, .32);
    border-radius: 26px;
    box-shadow: 0 18px 60px rgba(15, 23, 42, .16);
}
.seo-card {
    padding: 26px;
    color: #111827;
}
.seo-card strong { display: block; margin-bottom: 12px; font-size: 1.15rem; }
.seo-card ul { margin: 0; padding-left: 20px; line-height: 1.9; color: #475569; }
.seo-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.seo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.seo-section {
    padding: 26px;
}
.seo-section h2 { margin: 0 0 12px; font-size: 1.5rem; }
.seo-section p, .seo-section li { line-height: 1.75; color: #475569; }
.seo-section ol, .seo-section ul { padding-left: 22px; }
.seo-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.seo-links a {
    display: block;
    padding: 14px 16px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    color: #3b1c92;
    font-weight: 800;
    text-decoration: none;
}
.seo-links a:hover { background: #ede9fe; }
.faq-item { border-top: 1px solid #e5e7eb; padding-top: 14px; margin-top: 14px; }
.faq-item strong { display: block; margin-bottom: 6px; }
.seo-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: white;
}
.seo-topbar a { color: white; text-decoration: none; font-weight: 800; }
.seo-topbar .ghost-link { border-color: rgba(255,255,255,.25); }
.home-seo-links {
    width: min(1120px, calc(100% - 32px));
    margin: 24px auto 0;
}
@media (max-width: 900px) {
    .seo-hero { grid-template-columns: 1fr; }
    .seo-grid { grid-template-columns: 1fr; }
    .seo-topbar { flex-direction: column; align-items: flex-start; }
}
