/* ==================== HTML TO PDF ==================== */
/* Standalone stylesheet for /html-to-pdf. Everything is namespaced under
   .h2p-container (or the h2p- prefix) so no other tool page is affected. */

body {
    background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #0f1419 100%) !important;
    color: var(--text-primary);
    overflow-x: clip;
}

.h2p-container {
    /* Workspace stays wide; content sections below cap at 1200px like PDF Editor */
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 24px;
    padding-left: max(24px, env(safe-area-inset-left, 0px));
    padding-right: max(24px, env(safe-area-inset-right, 0px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    color: var(--text-primary);
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Title + How-to / guide / FAQ / related match other tools (1200px) */
.h2p-container .header-section,
.h2p-container .instructions-section,
.h2p-container .features-guide-section,
.h2p-container .faq-section,
.h2p-related-tools {
    max-width: 1200px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* ---------- Header ---------- */
.h2p-container .header-section {
    text-align: center;
    margin-bottom: 34px;
}

.h2p-container .header-section h1 {
    color: var(--text-primary);
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-weight: 800;
}

.h2p-container .header-section h1 i {
    color: #f79112;
}

.h2p-container .subtitle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin: 0 0 14px;
}

.h2p-trust-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
}

.h2p-trust-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(247, 145, 18, 0.4);
    background: rgba(247, 145, 18, 0.1);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.h2p-trust-pill i {
    color: #f79112;
    font-size: 0.85rem;
}

/* ---------- Workspace card ---------- */
.h2p-workspace {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--primary-light);
    border-radius: 20px;
    padding: 26px;
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
    backdrop-filter: blur(10px);
    width: 100%;
    box-sizing: border-box;
}

/* ---------- Buttons ---------- */
.h2p-container .h2p-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.93rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid var(--primary-light);
    background: transparent;
    color: var(--text-primary);
    -webkit-tap-highlight-color: rgba(247, 145, 18, 0.2);
    touch-action: manipulation;
    white-space: nowrap;
}

.h2p-container .h2p-btn:hover {
    background: var(--primary-light);
    border-color: #f79112;
    transform: translateY(-2px);
}

.h2p-container .h2p-btn-primary {
    background: var(--accent-color);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(74, 144, 226, 0.35);
}

.h2p-container .h2p-btn-primary:hover {
    background: #f79112;
    border-color: transparent;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(247, 145, 18, 0.6);
}

.h2p-container .h2p-btn:disabled,
.h2p-container .h2p-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.h2p-container .h2p-btn-danger:hover {
    background: rgba(220, 53, 69, 0.18);
    border-color: #dc3545;
}

.h2p-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    align-items: center;
}

.h2p-actions-spacer {
    flex: 1 1 auto;
}

/* Sample template dropdown */
.h2p-menu {
    position: relative;
    display: inline-block;
}

.h2p-menu-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 250px;
    background: #17202e;
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 60;
    display: none;
}

.h2p-menu.open .h2p-menu-list {
    display: block;
}

.h2p-menu-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    font-family: inherit;
    transition: background 0.2s ease;
}

.h2p-menu-item:hover {
    background: rgba(247, 145, 18, 0.15);
}

.h2p-menu-item i {
    color: #f79112;
    margin-top: 3px;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.h2p-menu-item span {
    display: block;
    font-weight: 600;
}

.h2p-menu-item small {
    display: block;
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.78rem;
    line-height: 1.35;
}

/* ---------- Settings panel ---------- */
.h2p-settings {
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    margin-bottom: 18px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
}

.h2p-settings-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.3s ease;
    text-align: left;
}

.h2p-settings-toggle:hover {
    background: rgba(247, 145, 18, 0.1);
}

.h2p-settings-toggle > i:first-child {
    color: #f79112;
}

.h2p-settings-chevron {
    margin-left: auto;
    transition: transform 0.3s ease;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.h2p-settings.open .h2p-settings-chevron {
    transform: rotate(180deg);
}

.h2p-settings-body {
    padding: 18px;
    border-top: 2px solid var(--primary-light);
}

.h2p-settings-group + .h2p-settings-group {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
}

.h2p-settings-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f79112;
    margin-bottom: 12px;
}

.h2p-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.h2p-field label,
.h2p-field .h2p-field-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.h2p-field select,
.h2p-field input[type="text"],
.h2p-field input[type="number"] {
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    border: 2px solid var(--primary-light);
    background-color: #1a2332;
    color: #e8eaed;
    font-size: 0.93rem;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.h2p-field select {
    padding-right: 34px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e8eaed' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.h2p-field select:focus,
.h2p-field input:focus {
    outline: none;
    border-color: #f79112;
    box-shadow: 0 0 0 3px rgba(247, 145, 18, 0.2);
}

.h2p-field select option {
    background-color: #1a2332;
    color: #e8eaed;
}

.h2p-field-wide {
    grid-column: 1 / -1;
}

.h2p-field-hint {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.h2p-field-hint code {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

.h2p-quad {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.h2p-quad input {
    text-align: center;
}

.h2p-quad-label {
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Toggle switch */
.h2p-field-toggle {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.h2p-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
    flex-shrink: 0;
}

.h2p-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.h2p-switch-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--primary-light);
    border-radius: 26px;
    transition: 0.3s;
}

.h2p-switch-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.h2p-switch input:checked + .h2p-switch-slider {
    background: rgba(247, 145, 18, 0.3);
    border-color: #f79112;
}

.h2p-switch input:checked + .h2p-switch-slider::before {
    transform: translateX(22px);
    background: #f79112;
}

/* ---------- Mobile tabs ---------- */
.h2p-mobile-tabs {
    display: none;
    gap: 0;
    margin-bottom: 12px;
    border: 2px solid var(--primary-light);
    border-radius: 10px;
    overflow: hidden;
}

.h2p-mobile-tab {
    flex: 1;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.h2p-mobile-tab.active {
    background: rgba(247, 145, 18, 0.2);
    color: var(--text-primary);
    box-shadow: inset 0 -2px 0 #f79112;
}

/* ---------- Split layout ---------- */
.h2p-split {
    /* Both panes share the preview/paper height. Extra code scrolls inside
       the editor; multipage papers raise both panes together. */
    --h2p-body-h: clamp(420px, 74vh, 900px);
    --h2p-bar-h: 52px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.h2p-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    width: 100%;
}

/* ---------- Code editor ---------- */
.h2p-code-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: var(--h2p-bar-h);
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.h2p-code-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 8px 8px 0 0;
    border: 2px solid var(--primary-light);
    border-bottom-width: 2px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.h2p-code-tab:hover {
    color: var(--text-primary);
    border-color: rgba(247, 145, 18, 0.6);
}

.h2p-code-tab.active {
    background: rgba(247, 145, 18, 0.18);
    border-color: #f79112;
    color: var(--text-primary);
}

.h2p-code-tab .h2p-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f79112;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.h2p-code-tab.has-content .h2p-dot {
    opacity: 1;
}

.h2p-code-tools {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.h2p-icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: rgba(247, 145, 18, 0.2);
    touch-action: manipulation;
}

.h2p-icon-btn:hover {
    border-color: #f79112;
    background: rgba(247, 145, 18, 0.15);
    color: #f79112;
}

.h2p-icon-btn.active {
    border-color: #f79112;
    background: rgba(247, 145, 18, 0.22);
    color: #f79112;
}

.h2p-editor-wrap {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    min-height: var(--h2p-body-h);
    height: var(--h2p-body-h);
    border: 2px solid var(--primary-light);
    border-radius: 10px;
    background: #0d1117;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.h2p-editor-wrap.focused {
    border-color: #f79112;
    box-shadow: 0 0 0 3px rgba(247, 145, 18, 0.2);
}

.h2p-editor-wrap.dragover {
    border-color: #f79112;
    box-shadow: 0 0 0 3px rgba(247, 145, 18, 0.25);
}

.h2p-gutter {
    flex: 0 0 auto;
    width: 52px;
    padding: 14px 8px 14px 0;
    text-align: right;
    background: #0a0e14;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    color: #4b5563;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    overflow: hidden;
    user-select: none;
    white-space: pre;
    box-sizing: border-box;
}

.h2p-code {
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 14px 14px 14px 12px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #e6edf3;
    background: transparent;
    border: none;
    resize: none;
    tab-size: 2;
    box-sizing: border-box;
    white-space: pre;
    overflow: auto;
    outline: none;
}

.h2p-code::placeholder {
    color: #4b5563;
}

.h2p-code-panel {
    display: none;
    flex: 0 0 auto;
    min-height: 0;
    flex-direction: column;
    width: 100%;
}

.h2p-code-panel.active {
    display: flex;
}

/* ---------- Preview pane ---------- */
.h2p-preview-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    box-sizing: border-box;
    min-height: var(--h2p-bar-h);
    margin-bottom: 10px;
    padding: 7px 10px;
    border: 2px solid var(--primary-light);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    min-height: 50px;
}

.h2p-zoom-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
}

.h2p-zoom-value {
    min-width: 52px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.h2p-preview-status {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.h2p-preview-status .h2p-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f79112;
    box-shadow: 0 0 0 0 rgba(247, 145, 18, 0.6);
}

.h2p-preview-status.busy .h2p-live-dot {
    background: #f79112;
    animation: h2pPulse 1.1s ease-out infinite;
}

@keyframes h2pPulse {
    0% { box-shadow: 0 0 0 0 rgba(247, 145, 18, 0.6); }
    100% { box-shadow: 0 0 0 8px rgba(247, 145, 18, 0); }
}

.h2p-preview-scroll {
    flex: 0 0 auto;
    min-height: var(--h2p-body-h);
    height: auto;
    overflow: hidden;
    border: 2px solid var(--primary-light);
    border-radius: 10px;
    background:
        radial-gradient(circle at 25% 15%, rgba(74, 144, 226, 0.08), transparent 45%),
        #10151d;
    padding: 22px 18px;
    box-sizing: border-box;
}

.h2p-paper-outer {
    margin: 0 auto;
    transform-origin: top center;
    overflow: hidden;
    /* JS sets width/height to the zoomed paper box so parents size correctly. */
}

.h2p-paper {
    position: relative;
    background: #ffffff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
    border-radius: 2px;
    overflow: hidden;
    transform-origin: top left;
}

.h2p-paper-frame {
    display: block;
    border: 0;
    background: transparent;
    width: 100%;
    overflow: hidden;
}

/* Margin guides + page break rules drawn over the paper */
.h2p-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.h2p-margin-box {
    position: absolute;
    border: 1px dashed rgba(74, 144, 226, 0.5);
    display: none;
}

.h2p-overlay.show-margins .h2p-margin-box {
    display: block;
}

.h2p-break {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 2px dashed rgba(247, 145, 18, 0.85);
}

.h2p-break::after {
    content: attr(data-label);
    position: absolute;
    right: 6px;
    top: 4px;
    background: #f79112;
    color: #14181f;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 0 0 6px 6px;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.h2p-break-shade {
    position: absolute;
    left: 0;
    right: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(247, 145, 18, 0.09) 0px,
        rgba(247, 145, 18, 0.09) 6px,
        transparent 6px,
        transparent 12px
    );
}

.h2p-overlay.hide-breaks .h2p-break,
.h2p-overlay.hide-breaks .h2p-break-shade {
    display: none;
}

.h2p-preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    min-height: 340px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

.h2p-preview-empty i {
    font-size: 2.6rem;
    color: rgba(247, 145, 18, 0.5);
}

/* ---------- Status bar ---------- */
.h2p-statusbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.h2p-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}

.h2p-stat i {
    color: #f79112;
    font-size: 0.8rem;
}

.h2p-stat strong {
    color: var(--text-primary);
    font-weight: 700;
}

.h2p-statusbar .h2p-autosave {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------- Warnings / errors ---------- */
.h2p-alert {
    display: none;
    align-items: flex-start;
    gap: 10px;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.55;
}

.h2p-alert.show {
    display: flex;
}

.h2p-alert i {
    margin-top: 2px;
    flex-shrink: 0;
}

.h2p-alert-warn {
    background: rgba(247, 145, 18, 0.12);
    border: 1px solid rgba(247, 145, 18, 0.45);
    color: #ffd8a8;
}

.h2p-alert-warn i {
    color: #f79112;
}

.h2p-alert-error {
    background: rgba(220, 53, 69, 0.12);
    border: 1px solid rgba(220, 53, 69, 0.45);
    color: #ffc9cf;
}

.h2p-alert-error i {
    color: #ff6b7a;
}

.h2p-alert ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.h2p-alert li {
    margin-bottom: 3px;
}

/* ---------- Progress overlay ---------- */
.h2p-progress {
    position: fixed;
    inset: 0;
    background: rgba(8, 11, 16, 0.82);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.h2p-progress.show {
    display: flex;
}

.h2p-progress-card {
    background: #17202e;
    border: 2px solid var(--primary-light);
    border-radius: 18px;
    padding: 30px 34px;
    width: 100%;
    max-width: 430px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.h2p-progress-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f79112 0%, #ff6b35 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    box-shadow: 0 8px 24px rgba(247, 145, 18, 0.4);
}

.h2p-progress-icon i {
    animation: h2pSpin 1.4s linear infinite;
}

@keyframes h2pSpin {
    to { transform: rotate(360deg); }
}

.h2p-progress-title {
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.h2p-progress-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    min-height: 20px;
}

.h2p-progress-track {
    height: 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.h2p-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #f79112, #ff6b35);
    transition: width 0.25s ease;
}

/* ---------- Toast ---------- */
.h2p-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translate(-50%, 20px);
    background: #17202e;
    border: 2px solid #f79112;
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 2100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    max-width: calc(100vw - 32px);
}

.h2p-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.h2p-toast i {
    color: #f79112;
}

.h2p-toast.ok {
    border-color: #f79112;
}

.h2p-toast.ok i {
    color: #f79112;
}

.h2p-toast.err {
    border-color: #dc3545;
}

.h2p-toast.err i {
    color: #ff6b7a;
}

/* ---------- Static content sections ---------- */
.h2p-container .instructions-section,
.h2p-container .features-guide-section,
.h2p-container .faq-section {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--primary-light);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
    backdrop-filter: blur(10px);
    content-visibility: auto;
    contain-intrinsic-size: auto 700px;
}

.h2p-container .instructions-section h2,
.h2p-container .faq-section h2 {
    color: var(--text-primary);
    font-size: 2rem;
    margin-bottom: 30px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-weight: 800;
}

.h2p-container .features-guide-section h2 {
    color: var(--text-primary);
    font-size: 1.75rem;
    margin-bottom: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 800;
    flex-wrap: wrap;
}

.h2p-container .instructions-section h2 i,
.h2p-container .features-guide-section h2 i,
.h2p-container .faq-section h2 i {
    color: #f79112;
}

.h2p-container .steps-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px;
}

.h2p-container .step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 18px;
    padding: 22px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.h2p-container .step-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(247, 145, 18, 0.3);
    border-color: #f79112;
    background: rgba(255, 255, 255, 0.05);
}

.h2p-container .step-number {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #f79112 0%, #ff6b35 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(247, 145, 18, 0.4);
}

.h2p-container .step-content h3 {
    color: var(--text-primary);
    margin: 0 0 10px;
    font-size: 1.2rem;
    font-weight: 700;
}

.h2p-container .step-content p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.h2p-container .features-lead {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.65;
    margin-bottom: 28px;
    text-align: center;
}

.h2p-container .on-device-highlight {
    background: linear-gradient(135deg, rgba(247, 145, 18, 0.18) 0%, rgba(34, 197, 94, 0.12) 100%);
    border: 2px solid rgba(247, 145, 18, 0.55);
    border-radius: 14px;
    padding: 22px 24px;
    margin-bottom: 32px;
    text-align: center;
}

.h2p-container .on-device-highlight h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.h2p-container .on-device-highlight h3 i {
    color: #22c55e;
}

.h2p-container .on-device-highlight p {
    color: var(--text-secondary);
    font-size: 1.02rem;
    line-height: 1.7;
    margin: 0 0 10px;
}

.h2p-container .on-device-highlight p:last-child {
    margin-bottom: 0;
}

.h2p-container .on-device-highlight strong {
    color: #f79112;
}

.h2p-container .feature-block {
    margin-bottom: 28px;
}

.h2p-container .feature-block h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.h2p-container .feature-block h3 i {
    color: #f79112;
    flex-shrink: 0;
    margin-top: 3px;
}

.h2p-container .feature-block p,
.h2p-container .feature-block ul {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    margin: 0 0 12px;
}

.h2p-container .feature-block ul {
    padding-left: 1.4rem;
}

.h2p-container .feature-block li {
    margin-bottom: 6px;
}

.h2p-container .feature-block p:last-child {
    margin-bottom: 0;
}

.h2p-container .feature-block code,
.h2p-container .features-outro code {
    background: rgba(255, 255, 255, 0.08);
    color: #ffc98a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: 'Consolas', 'Monaco', monospace;
}

.h2p-container .feature-block a,
.h2p-container .features-outro a {
    color: #f79112;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid rgba(247, 145, 18, 0.45);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.h2p-container .feature-block a:hover,
.h2p-container .features-outro a:hover {
    color: #ffad4a;
    border-bottom-color: rgba(255, 173, 74, 0.8);
}

.h2p-container .features-outro {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.7;
    margin: 24px 0 0;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* Support matrix table inside the guide */
.h2p-support-table-wrap {
    overflow-x: auto;
    margin: 14px 0 4px;
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}

.h2p-support-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
    font-size: 0.93rem;
}

.h2p-support-table th,
.h2p-support-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    color: var(--text-secondary);
    vertical-align: top;
}

.h2p-support-table th {
    background: rgba(247, 145, 18, 0.14);
    color: var(--text-primary);
    font-weight: 700;
    white-space: nowrap;
}

.h2p-support-table tr:last-child td {
    border-bottom: none;
}

.h2p-support-table .h2p-yes {
    color: #22c55e;
    font-weight: 700;
    white-space: nowrap;
}

.h2p-support-table .h2p-partial {
    color: #f79112;
    font-weight: 700;
    white-space: nowrap;
}

/* Feature screenshots — same pattern as PDF Editor blog shots */
.h2p-shot {
    margin: 22px 0 28px;
}

.h2p-shot + .h2p-shot {
    margin-top: 8px;
}

.h2p-shot img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--primary-light);
    background: rgba(0, 0, 0, 0.25);
}

.h2p-shot figcaption {
    margin: 14px 4px 6px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* FAQ */
.h2p-container .faq-container {
    max-width: 900px;
    margin: 0 auto;
}

.h2p-container .faq-item-pdf {
    margin-bottom: 15px;
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.3s ease;
}

.h2p-container .faq-item-pdf:hover {
    border-color: #f79112;
}

.h2p-container .faq-question-pdf {
    padding: 15px 15px 15px 40px;
    background-color: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    position: relative;
    font-size: 1.1em;
    transition: all 0.3s ease;
}

.h2p-container .faq-question-pdf::before {
    content: '+';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5em;
    font-weight: normal;
    line-height: 1;
    transition: transform 0.3s ease;
    color: #f79112;
}

.h2p-container .faq-item-pdf.active .faq-question-pdf {
    background-color: rgba(247, 145, 18, 0.2);
    border-bottom: 2px solid #f79112;
}

.h2p-container .faq-item-pdf.active .faq-question-pdf::before {
    content: '-';
    transform: translateY(-50%) rotate(180deg);
}

.h2p-container .faq-answer-pdf {
    background-color: rgba(255, 255, 255, 0.03);
    padding: 0 15px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.5s ease;
}

.h2p-container .faq-item-pdf.active .faq-answer-pdf {
    padding: 15px;
    max-height: 1200px;
}

.h2p-container .faq-answer-pdf p {
    margin: 0;
    font-size: 1.05em;
    line-height: 1.65;
    color: var(--text-secondary);
}

.h2p-container .faq-answer-pdf p + p {
    margin-top: 10px;
}

.h2p-container .faq-answer-pdf code {
    background: rgba(255, 255, 255, 0.08);
    color: #ffc98a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: 'Consolas', 'Monaco', monospace;
}

.h2p-container .faq-answer-pdf a {
    color: #f79112;
    font-weight: 600;
    text-decoration: none;
}

.h2p-container .faq-answer-pdf a:hover {
    text-decoration: underline;
}

/* Related PDF tools — standalone section matching PDF Editor */
.h2p-related-tools {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--primary-light);
    border-radius: 20px;
    padding: 36px 32px;
    margin-top: 28px;
    margin-bottom: 40px;
    backdrop-filter: blur(10px);
}

.h2p-related-tools h2 {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 10px;
}

.h2p-related-tools h2 i {
    color: #f79112;
}

.h2p-related-tools > p {
    color: var(--text-secondary);
    margin: 0 0 22px;
    line-height: 1.55;
}

.h2p-related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.h2p-related-card {
    display: block;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid var(--primary-light);
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.25s ease, background 0.25s ease, transform 0.2s ease;
}

.h2p-related-card:hover {
    border-color: #f79112;
    background: rgba(247, 145, 18, 0.1);
    transform: translateY(-2px);
}

.h2p-related-card i {
    color: #f79112;
    margin-right: 8px;
}

.h2p-related-card strong {
    display: block;
    margin: 4px 0 6px;
    font-size: 1.02rem;
    color: var(--text-primary);
}

.h2p-related-card span {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

@media (max-width: 900px) {
    .h2p-related-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .h2p-related-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== Responsive ==================== */
@media (max-width: 1400px) {
    .h2p-split {
        --h2p-body-h: clamp(420px, 70vh, 760px);
    }
}

@media (max-width: 1100px) {
    .h2p-workspace {
        display: flex;
        flex-direction: column;
    }

    .h2p-settings {
        order: 1;
    }

    .h2p-mobile-tabs {
        display: flex;
        order: 2;
    }

    .h2p-split {
        grid-template-columns: 1fr;
        gap: 0;
        order: 3;
    }

    .h2p-statusbar {
        order: 4;
    }

    /* Action buttons sit under Code / Paper preview on phones & tablets */
    .h2p-actions-row {
        order: 5;
        margin-top: 16px;
        margin-bottom: 0;
    }

    .h2p-alert {
        order: 6;
    }

    .h2p-pane {
        display: none;
    }

    .h2p-pane.active {
        display: flex;
    }

    .h2p-code-tabs,
    .h2p-preview-bar {
        min-height: 0;
    }
}

@media (max-width: 992px) {
    .h2p-container {
        padding: 16px;
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
    }

    .h2p-container .header-section {
        margin-bottom: 26px;
    }

    .h2p-container .header-section h1 {
        font-size: 2rem;
        flex-direction: column;
        gap: 10px;
    }

    .h2p-container .subtitle {
        font-size: 1.05rem;
        padding: 0 8px;
    }

    .h2p-workspace {
        padding: 20px 16px;
        border-radius: 16px;
        margin-bottom: 32px;
    }

    .h2p-actions-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .h2p-actions-spacer {
        display: none;
    }

    .h2p-actions-row .h2p-btn,
    .h2p-actions-row .h2p-menu,
    .h2p-actions-row .h2p-menu > .h2p-btn {
        width: 100%;
        min-height: 46px;
    }

    .h2p-actions-row .h2p-btn-primary {
        grid-column: 1 / -1;
    }

    .h2p-settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .h2p-split {
        --h2p-body-h: clamp(360px, 66vh, 640px);
    }

    .h2p-container .steps-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .h2p-container .instructions-section,
    .h2p-container .features-guide-section,
    .h2p-container .faq-section,
    .h2p-related-tools {
        padding: 28px 20px;
        border-radius: 16px;
        margin-bottom: 32px;
    }

    .h2p-related-tools {
        margin-top: 0;
    }

    .h2p-related-tools h2 {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 10px;
    }

    .h2p-container .instructions-section h2,
    .h2p-container .faq-section h2 {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 10px;
    }

    .h2p-container .features-guide-section h2 {
        font-size: 1.4rem;
    }

    .h2p-container .on-device-highlight {
        padding: 18px 16px;
        text-align: left;
    }

    .h2p-container .on-device-highlight h3 {
        justify-content: flex-start;
        font-size: 1.1rem;
    }

    .h2p-container .feature-block h3 {
        font-size: 1.1rem;
    }

    /* Perf: drop expensive effects on tablet/mobile, matching sibling tools */
    .h2p-workspace,
    .h2p-container .instructions-section,
    .h2p-container .features-guide-section,
    .h2p-container .faq-section,
    .h2p-related-tools,
    .h2p-container .step-item {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .h2p-container .step-item:hover,
    .h2p-container .h2p-btn:hover,
    .h2p-related-card:hover,
    .h2p-mobile-tab:hover {
        transform: none;
    }

    .h2p-preview-scroll {
        contain: layout style;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: auto;
    }

    .h2p-paper {
        contain: layout style;
    }

    .h2p-preview-status.busy .h2p-live-dot {
        animation: none;
    }
}

@media (max-width: 768px) {
    .h2p-container {
        padding: 14px;
        padding-left: max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(14px, env(safe-area-inset-right, 0px));
    }

    .h2p-container .header-section h1 {
        font-size: 1.8rem;
    }

    .h2p-container .subtitle {
        font-size: 1rem;
    }

    .h2p-trust-pill {
        font-size: 0.78rem;
        padding: 5px 11px;
    }

    .h2p-split {
        --h2p-body-h: clamp(320px, 62vh, 560px);
    }

    .h2p-preview-scroll {
        padding: 14px 10px;
    }

    .h2p-gutter {
        width: 42px;
        font-size: 12px;
    }

    .h2p-code {
        font-size: 12px;
    }

    .h2p-preview-status {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }

    .h2p-preview-bar {
        gap: 6px;
        padding: 6px 8px;
    }

    .h2p-statusbar {
        gap: 8px 12px;
    }

    .h2p-statusbar .h2p-autosave {
        margin-left: 0;
        width: 100%;
    }

    .h2p-container .faq-question-pdf {
        font-size: 1rem;
        padding: 14px 14px 14px 38px;
    }

    .h2p-container .faq-answer-pdf p {
        font-size: 0.98em;
    }
}

@media (max-width: 480px) {
    .h2p-container {
        padding: 10px;
        padding-left: max(10px, env(safe-area-inset-left, 0px));
        padding-right: max(10px, env(safe-area-inset-right, 0px));
    }

    .h2p-container .header-section {
        margin-bottom: 20px;
    }

    .h2p-container .header-section h1 {
        font-size: 1.5rem;
        gap: 8px;
    }

    .h2p-container .subtitle {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .h2p-workspace {
        padding: 15px 12px;
        border-radius: 14px;
        margin-bottom: 24px;
    }

    .h2p-actions-row {
        grid-template-columns: 1fr;
    }

    .h2p-settings-grid,
    .h2p-quad {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .h2p-field select,
    .h2p-field input[type="text"],
    .h2p-field input[type="number"] {
        font-size: 16px; /* stops iOS zoom-on-focus */
        min-height: 44px;
    }

    .h2p-mobile-tab {
        padding: 13px 8px;
        font-size: 0.9rem;
        min-height: 48px;
        transition: none;
    }

    .h2p-split {
        --h2p-body-h: clamp(300px, 58vh, 460px);
    }

    .h2p-code-tab,
    .h2p-icon-btn,
    .h2p-btn {
        transition: none;
    }

    .h2p-paper {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
        /* Reduce repaints while pinch/scroll zooming on phones */
        transition: none;
    }

    .h2p-menu-list {
        min-width: min(280px, calc(100vw - 48px));
    }

    .h2p-stat {
        font-size: 0.8rem;
    }

    .h2p-container .instructions-section,
    .h2p-container .features-guide-section,
    .h2p-container .faq-section,
    .h2p-related-tools {
        padding: 20px 14px;
        margin-bottom: 24px;
    }

    .h2p-related-tools h2 {
        font-size: 1.35rem;
    }

    .h2p-container .instructions-section h2,
    .h2p-container .faq-section h2 {
        font-size: 1.35rem;
    }

    .h2p-container .features-guide-section h2 {
        font-size: 1.22rem;
    }

    .h2p-container .features-lead,
    .h2p-container .features-outro {
        font-size: 0.97rem;
        text-align: left;
    }

    .h2p-container .feature-block p,
    .h2p-container .feature-block ul {
        font-size: 0.95rem;
    }

    .h2p-progress-card {
        padding: 24px 20px;
        width: min(420px, calc(100vw - 24px));
    }

    .h2p-container .faq-question-pdf {
        font-size: 0.95rem;
        padding: 12px 12px 12px 40px;
        word-wrap: break-word;
        line-height: 1.4;
    }

    .h2p-container .faq-answer-pdf p {
        font-size: 0.9rem;
    }
}

@media (max-width: 360px) {
    .h2p-container .header-section h1 {
        font-size: 1.32rem;
    }

    .h2p-settings-grid,
    .h2p-quad {
        grid-template-columns: 1fr;
    }

    .h2p-quad {
        gap: 6px;
    }

    .h2p-mobile-tab {
        font-size: 0.82rem;
        gap: 5px;
        padding: 12px 4px;
    }

    .h2p-gutter {
        width: 34px;
        font-size: 11px;
    }

    .h2p-code {
        font-size: 11px;
        padding: 10px 8px;
    }

    .h2p-zoom-value {
        min-width: 44px;
        font-size: 0.75rem;
    }
}

/* Short landscape phones — keep the editor usable without scrolling forever */
@media (max-width: 896px) and (max-height: 500px) and (orientation: landscape) {
    .h2p-split {
        --h2p-body-h: clamp(220px, 70vh, 360px);
    }

    .h2p-container .header-section {
        margin-bottom: 12px;
    }

    .h2p-container .subtitle {
        display: none;
    }

    .h2p-trust-row {
        display: none;
    }
}
