/* ============================================================
   PDF Мастер — pdf.netchess.ru
   Синяя тема (#1565C0) по мотивам кабинета SPK: карточки, мягкие
   тени, градиентные кнопки, тёмно-синий футер.
   ============================================================ */

:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --primary-light: #E3F2FD;
    --grad: linear-gradient(135deg, #1565C0 0%, #1E88E5 100%);
    --grad-hover: linear-gradient(135deg, #0D47A1 0%, #1565C0 100%);
    --success: #2E7D32;
    --grad-success: linear-gradient(135deg, #2E7D32 0%, #43A047 100%);
    --danger: #E53935;
    --text: #1A1A1A;
    --muted: #6B7280;
    --light: #9CA3AF;
    --bg: #F5F6FA;
    --bg-dark: #0A2540;
    --border: #E0E6ED;
    --border-light: #F0F2F5;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(10,37,64,.06), 0 1px 2px rgba(10,37,64,.04);
    --shadow-md: 0 4px 12px rgba(10,37,64,.08);
    --shadow-lg: 0 8px 24px rgba(10,37,64,.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* атрибут hidden всегда сильнее любых display: flex/grid ниже */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 16px; line-height: 1.55; color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
svg { display: block; }

.container { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.h2 { font-size: 26px; font-weight: 700; margin-bottom: 24px; }

/* ---------------- header ---------------- */
.hdr {
    position: sticky; top: 0; z-index: 100;
    background: #fff; border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.hdr__inner { display: flex; align-items: center; gap: 28px; height: 66px; }
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo__badge {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 10px; border-radius: 10px;
    background: var(--grad); color: #fff;
    font-size: 15px; font-weight: 800; letter-spacing: .5px;
    box-shadow: 0 3px 8px rgba(21,101,192,.35);
}
.logo__text { font-size: 19px; font-weight: 700; color: var(--text); }
.logo--light .logo__text { color: #fff; }
.hdr__nav { display: flex; gap: 22px; }
.hdr__nav a { color: var(--text); font-size: 15px; font-weight: 500; }
.hdr__nav a:hover { color: var(--primary); }
.hdr__cta {
    margin-left: auto;
    display: inline-flex; align-items: center;
    padding: 9px 18px; border-radius: 10px;
    background: var(--grad); color: #fff !important;
    font-size: 14px; font-weight: 600;
    box-shadow: 0 4px 12px rgba(21,101,192,.3);
    transition: all .15s ease;
}
.hdr__cta:hover { background: var(--grad-hover); box-shadow: 0 4px 14px rgba(21,101,192,.4); }

/* ---------------- hero ---------------- */
.hero { padding: 64px 0 36px; text-align: center; }
.hero__title { font-size: 42px; font-weight: 800; line-height: 1.18; letter-spacing: -0.5px; }
.grad {
    background: var(--grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.hero__sub { margin: 18px auto 0; max-width: 640px; font-size: 17px; color: var(--muted); }
.hero__badges { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.badge {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 14px; border-radius: 999px;
    background: #fff; border: 1px solid var(--border);
    font-size: 13px; font-weight: 600; color: var(--text);
    box-shadow: var(--shadow-sm);
}
.badge svg { width: 14px; height: 14px; stroke: var(--success); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- chips filter ---------------- */
.tools-section { padding: 26px 0 56px; }
.chips {
    display: inline-flex; flex-wrap: wrap; gap: 4px;
    padding: 4px; margin-bottom: 26px;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
}
.chip {
    padding: 9px 16px; border: none; background: transparent; border-radius: 9px;
    font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
    transition: all .15s ease; white-space: nowrap;
}
.chip:hover { color: var(--primary); background: #F4F8FB; }
.chip.is-active { background: var(--grad); color: #fff; box-shadow: 0 2px 8px rgba(21,101,192,.3); }

/* ---------------- tools grid ---------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 16px; }
.card {
    display: block; background: #fff; position: relative;
    border: 1px solid var(--border-light); border-radius: var(--radius-lg);
    padding: 22px; color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card__badge {
    position: absolute; top: 14px; right: 14px;
    padding: 3px 10px; border-radius: 999px;
    background: #FCE7F3; color: #DB2777;
    font-size: 11px; font-weight: 700; letter-spacing: .3px;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #BBDEFB; }
.card.is-hidden { display: none; }
.card__title { font-size: 17px; font-weight: 700; margin: 14px 0 6px; }
.card__text { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.card--ad { box-shadow: none; }
.card--ad:empty { display: none; }

/* цветные чипы-иконки */
.chip-ico {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.chip-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chip-ico--blue   { background: #DBEAFE; color: #1565C0; }
.chip-ico--indigo { background: #E0E7FF; color: #4338CA; }
.chip-ico--green  { background: #D1FAE5; color: #059669; }
.chip-ico--teal   { background: #CCFBF1; color: #0D9488; }
.chip-ico--orange { background: #FEF3C7; color: #D97706; }
.chip-ico--purple { background: #EDE9FE; color: #7C3AED; }
.chip-ico--navy   { background: #DBEAFE; color: #0D47A1; }
.chip-ico--rose   { background: #FCE7F3; color: #DB2777; }

/* ---------------- how / trust ---------------- */
.how { padding: 46px 0; background: #fff; border-top: 1px solid var(--border-light); }
.how__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.how__step {
    background: var(--bg); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); padding: 22px;
}
.how__num {
    width: 34px; height: 34px; border-radius: 999px;
    background: var(--grad); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; margin-bottom: 12px;
    box-shadow: 0 3px 8px rgba(21,101,192,.3);
}
.how__name { font-weight: 700; margin-bottom: 6px; }
.how__step p { font-size: 14px; color: var(--muted); }
.trust { padding: 46px 0 60px; text-align: center; }
.trust__text { max-width: 680px; margin: 0 auto; color: var(--muted); font-size: 15px; }

/* ---------------- ad slots ---------------- */
.ad-slot { margin: 18px 0; }
.ad-slot:empty { display: none; margin: 0; }
.ad-slot--wide { text-align: center; }

/* ---------------- footer ---------------- */
.ftr { background: var(--bg-dark); color: #fff; padding: 44px 0 0; margin-top: 30px; }
.ftr__grid {
    display: grid; grid-template-columns: 1.3fr 0.8fr 0.8fr 1.1fr;
    gap: 36px; padding-bottom: 32px;
}
.ftr__tagline { margin-top: 14px; font-size: 13px; color: rgba(255,255,255,.62); max-width: 300px; }
.ftr__title {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .8px; color: rgba(255,255,255,.5); margin-bottom: 14px;
}
.ftr__nav { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.ftr__nav a { color: rgba(255,255,255,.85); font-size: 14px; }
.ftr__nav a:hover { color: #64B5F6; }
.ftr__note { font-size: 13px; color: rgba(255,255,255,.62); }
.ftr__bottom {
    border-top: 1px solid rgba(255,255,255,.1); padding: 16px 0;
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    font-size: 13px; color: rgba(255,255,255,.55);
}

/* ---------------- buttons ---------------- */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 22px; border: none; border-radius: 12px;
    background: var(--grad); color: #fff;
    font-size: 14px; font-weight: 600; cursor: pointer;
    box-shadow: 0 4px 12px rgba(21,101,192,.3);
    transition: all .15s ease; text-decoration: none;
}
.btn-primary:hover { background: var(--grad-hover); box-shadow: 0 4px 14px rgba(21,101,192,.4); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-success {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 22px; border: none; border-radius: 12px;
    background: var(--grad-success); color: #fff !important;
    font-size: 14px; font-weight: 600; cursor: pointer;
    box-shadow: 0 4px 12px rgba(67,160,71,.3);
    transition: all .15s ease; text-decoration: none;
}
.btn-success:hover { filter: brightness(1.05); }
.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border: 1px solid var(--border); border-radius: 12px;
    background: #fff; color: var(--text);
    font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s ease;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: #F4F8FB; }
.btn-lg { padding: 14px 30px; font-size: 16px; }

/* ---------------- tool page ---------------- */
.tool-page { padding: 26px 0 40px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 22px; }
.crumbs svg { width: 14px; height: 14px; stroke: var(--light); stroke-width: 2; fill: none; }
.tool-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.tool-head__icon { width: 56px; height: 56px; border-radius: 14px; flex: 0 0 56px; }
.tool-head__icon svg { width: 26px; height: 26px; }
.tool-head__title { font-size: 30px; font-weight: 800; letter-spacing: -0.3px; }
.tool-head__sub { color: var(--muted); font-size: 15px; margin-top: 3px; }

.card-panel {
    background: #fff; border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    padding: 28px;
}

.dropzone {
    border: 2px dashed #C6D5E4; border-radius: var(--radius-lg);
    padding: 44px 24px; text-align: center; cursor: pointer;
    transition: all .15s ease; background: #FAFCFF;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-light); }
.dropzone__icon { width: 44px; height: 44px; margin: 0 auto 14px; stroke: var(--primary); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dropzone__title { font-size: 18px; font-weight: 700; }
.dropzone__sub { font-size: 13px; color: var(--muted); margin: 6px 0 18px; }

.files { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.file-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
    background: #fff; font-size: 14px;
}
.file-row__ico {
    width: 34px; height: 34px; border-radius: 8px; flex: 0 0 34px;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 800; text-transform: uppercase;
}
.file-row__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-row__size { color: var(--light); font-size: 12.5px; white-space: nowrap; }
.file-row__btns { display: flex; gap: 4px; }
.file-row__btn {
    width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 7px;
    background: #fff; color: var(--muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 13px;
    transition: all .12s ease;
}
.file-row__btn:hover { border-color: var(--primary); color: var(--primary); }
.file-row__btn--del:hover { border-color: var(--danger); color: var(--danger); }

.opts { margin-top: 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.opt__label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.opt__input {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--border); border-radius: 10px;
    font: inherit; font-size: 14px; color: var(--text); background: #fff;
}
.opt__input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,101,192,.12); }
.opt__help { font-size: 12px; color: var(--light); margin-top: 5px; }
.opt.is-hidden { display: none; }

.ws__actions { margin-top: 22px; display: flex; gap: 12px; flex-wrap: wrap; }

.prog { margin-top: 26px; text-align: center; padding: 12px 0 4px; }
.spinner {
    width: 38px; height: 38px; margin: 0 auto 14px;
    border: 4px solid var(--primary-light); border-top-color: var(--primary);
    border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.prog__text { font-weight: 600; margin-bottom: 12px; }
.prog__bar { max-width: 420px; margin: 0 auto; height: 8px; border-radius: 999px; background: var(--border-light); overflow: hidden; }
.prog__fill { height: 100%; width: 0%; border-radius: 999px; background: var(--grad); transition: width .25s ease; }
.prog__fill.is-indet { width: 40% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

.result { margin-top: 26px; text-align: center; padding: 8px 0 4px; }
.result__icon {
    width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 999px;
    background: var(--grad-success); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(67,160,71,.35);
}
.result__icon svg { width: 26px; height: 26px; stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.result__title { font-size: 20px; font-weight: 800; }
.result__name { color: var(--muted); font-size: 14px; margin: 4px 0 2px; word-break: break-all; }
.result__note { color: var(--success); font-size: 13.5px; font-weight: 600; margin-bottom: 14px; min-height: 8px; }
.result .btn-ghost { margin-left: 10px; }

.errbox {
    margin-top: 22px; padding: 16px 18px;
    background: #FEF2F2; border: 1px solid #FECACA; border-radius: 12px;
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.errbox__text { color: #B91C1C; font-weight: 600; font-size: 14.5px; }

.tool-how { margin-top: 38px; }
.tool-seo { margin-top: 34px; max-width: 800px; }
.tool-seo p { color: var(--muted); font-size: 15px; margin-bottom: 12px; }
.tool-more { margin-top: 34px; }
.tool-more__links { display: flex; flex-wrap: wrap; gap: 10px; }
.tool-more__links a {
    padding: 8px 16px; border: 1px solid var(--border); border-radius: 999px;
    background: #fff; font-size: 13.5px; font-weight: 600; color: var(--text);
    transition: all .15s ease;
}
.tool-more__links a:hover { border-color: var(--primary); color: var(--primary); background: #F4F8FB; }

/* ---------------- редактор PDF ---------------- */
@font-face {
    font-family: 'DejaVu Sans';
    src: url('/static/vendor/DejaVuSans.ttf') format('truetype');
    font-weight: 400; font-display: swap;
}
@font-face {
    font-family: 'DejaVu Sans';
    src: url('/static/vendor/DejaVuSans-Bold.ttf') format('truetype');
    font-weight: 700; font-display: swap;
}

.edt-toolbar {
    position: sticky; top: 74px; z-index: 50;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 12px 16px !important; margin-bottom: 10px;
}
.edt-tools, .edt-props { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.edt-actions { margin-left: auto; display: flex; gap: 10px; }
.edt-tbtn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 12px; border: 1px solid transparent; border-radius: 9px;
    background: transparent; color: var(--muted);
    font-size: 13px; font-weight: 600; cursor: pointer; transition: all .12s ease;
}
.edt-tbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.edt-tbtn:hover { background: #F4F8FB; color: var(--primary); }
.edt-tbtn.is-active { background: var(--grad); color: #fff; box-shadow: 0 2px 8px rgba(21,101,192,.3); }
.edt-tbtn--sq { padding: 8px 10px; border: 1px solid var(--border); background: #fff; color: var(--text); }
.edt-tbtn--sq:hover { border-color: var(--primary); }
.edt-tbtn--sq.is-active { background: var(--grad); border-color: transparent; color: #fff; }
.edt-inp {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px;
    font: inherit; font-size: 13px; background: #fff;
}
.edt-color {
    width: 34px; height: 34px; padding: 2px; border: 1px solid var(--border);
    border-radius: 9px; background: #fff; cursor: pointer;
}
.edt-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.edt-zoom { font-size: 13px; font-weight: 600; color: var(--muted); min-width: 44px; text-align: center; }
.edt-hint { font-size: 13px; color: var(--light); margin: 0 4px 12px; }

.edt-stage {
    background: #E8ECF3; border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 26px 12px;
    max-height: 78vh; overflow: auto;
}
.edt-pages { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.edt-page {
    position: relative; background: #fff;
    box-shadow: 0 2px 12px rgba(10,37,64,.18);
    flex: 0 0 auto;
}
.edt-page canvas { display: block; position: absolute; inset: 0; }
.edt-overlay { position: absolute; inset: 0; z-index: 5; }
.edt-pages[data-tool="text"] .edt-overlay { cursor: text; }
.edt-pages[data-tool="hl"] .edt-overlay,
.edt-pages[data-tool="white"] .edt-overlay { cursor: crosshair; }
.edt-pages[data-tool="pen"] .edt-overlay { cursor: crosshair; }

.edt-item { position: absolute; touch-action: none; }
.edt-item--hl, .edt-item--white { cursor: move; }
.edt-item--img { cursor: move; }
.edt-item--img img { width: 100%; height: 100%; display: block; user-select: none; }
.edt-item.is-selected { outline: 2px solid var(--primary); outline-offset: 1px; z-index: 8; }
.edt-item--pen { pointer-events: none; }
.edt-pen-svg { position: absolute; inset: 0; pointer-events: none; }

.edt-text {
    font-family: 'DejaVu Sans', Arial, sans-serif;
    line-height: 1.2; white-space: pre-wrap; outline: none;
    min-width: 12px; min-height: 1em; cursor: move; padding: 0;
}
.edt-text:focus { cursor: text; }
.edt-item--text { padding: 1px; }

.edt-handle {
    position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px;
    background: var(--primary); border: 2px solid #fff; border-radius: 4px;
    cursor: nwse-resize; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.edt-busy {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(255,255,255,.85);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}

@media (max-width: 760px) {
    .edt-toolbar { top: 66px; }
    .edt-tbtn span { display: none; }
    .edt-actions { margin-left: 0; width: 100%; }
    .edt-actions .btn-primary { flex: 1; }
}

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
    .hero__title { font-size: 32px; }
    .how__grid { grid-template-columns: 1fr; }
    .ftr__grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .container { padding: 0 16px; }
    .hdr__nav { display: none; }
    .hero { padding: 40px 0 24px; }
    .hero__title { font-size: 27px; }
    .hero__sub br { display: none; }
    .hero__title br { display: none; }
    .chips { width: 100%; }
    .chip { flex: 1; text-align: center; padding: 9px 8px; }
    .card-panel { padding: 18px; }
    .dropzone { padding: 30px 14px; }
    .tool-head__title { font-size: 24px; }
    .ftr__grid { grid-template-columns: 1fr; gap: 26px; }
    .ws__actions .btn-lg { width: 100%; }
    .result .btn-ghost { margin-left: 0; margin-top: 10px; }
}
