/* ── Base ───────────────────────────────────────────── */
html {
    font-size: 16px;
    min-height: 100%;
    position: relative;
}

body {
    background-color: #ffffff;
    color: #333333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin-bottom: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: "Onest", sans-serif;
    font-weight: 700;
    color: #141413;
}

/* ── Layout ─────────────────────────────────────────── */
.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 32px 0 60px;
}

.main-content-full {
    flex: 1;
    padding: 0;
    overflow: hidden;
}

/* ── Hero ───────────────────────────────────────────── */
.hero {
    text-align: center;
    margin-bottom: 28px;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #141413;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.hero p {
    font-size: 0.95rem;
    color: #666;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ── Section Title ──────────────────────────────────── */
.section-label {
    font-family: "Onest", sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #999;
    margin-bottom: 10px;
}

/* ── Download Buttons ───────────────────────────────── */
.download-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
}

.btn-download {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    background-color: #faf9f5;
    color: #141413;
    border: 1px solid rgba(31, 30, 29, 0.15);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    text-decoration: none;
    transition: box-shadow 0.2s ease, transform 0.15s ease, background-color 0.15s ease;
    box-shadow: none;
}

.btn-download:hover {
    background-color: #f3f1ea;
    box-shadow: none;
    transform: translateY(-1px);
    color: #141413;
    text-decoration: none;
}

.btn-download .file-icon {
    width: 30px;
    height: 30px;
    background: #fff;
    border: 1px solid rgba(31, 30, 29, 0.12);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
    color: #d97757;
}

.btn-download .file-size {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 500;
    color: #999;
    background: rgba(31, 30, 29, 0.06);
    padding: 2px 7px;
    border-radius: 5px;
}

/* ── Divider ────────────────────────────────────────── */
.section-divider {
    border: none;
    border-top: 1px solid rgba(31, 30, 29, 0.1);
    margin: 20px 0;
}

/* ── Custom Generator ───────────────────────────────── */
.generator-box {
    background-color: #faf9f5;
    border: 1px solid rgba(31, 30, 29, 0.12);
    border-radius: 14px;
    padding: 20px 24px;
}

.generator-box label {
    font-family: "Onest", sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    color: #333;
    margin-bottom: 6px;
    display: block;
}

.size-display {
    font-family: "Onest", sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #141413;
    margin-bottom: 8px;
}

.form-range {
    accent-color: #141413;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.73rem;
    color: #aaa;
    margin-top: 2px;
    margin-bottom: 16px;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input-row .form-control {
    border: 1px solid rgba(31, 30, 29, 0.2);
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 0.9rem;
    background: #fff;
    color: #141413;
}

.input-row .form-control:focus {
    border-color: rgba(31, 30, 29, 0.4);
    box-shadow: none;
    outline: none;
}

.btn-generate {
    padding: 9px 24px;
    background-color: #141413;
    color: #fff;
    border: none;
    border-radius: 9px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
}

.btn-generate:hover {
    background-color: #2a2a28;
    transform: translateY(-1px);
}

.btn-generate:disabled,
.htpdf-btn-primary:disabled {
    opacity: .7;
    cursor: not-allowed;
    transform: none;
}

/* ── Download spinner ────────────────────────────────── */
@keyframes dl-spin {
    to { transform: rotate(360deg); }
}

.dl-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: dl-spin .65s linear infinite;
    margin-right: 7px;
    vertical-align: middle;
    flex-shrink: 0;
}

.input-hint {
    font-size: 0.73rem;
    color: #aaa;
    margin-top: 6px;
}

/* ── Description ────────────────────────────────────── */
.site-description {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(31, 30, 29, 0.1);
    color: #666;
    font-size: 0.82rem;
    line-height: 1.6;
}

.site-description h2 {
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 4px;
}

/* ── Tools Grid ─────────────────────────────────────── */
.tools-divider {
    border: none;
    border-top: 1px solid rgba(31, 30, 29, 0.1);
    margin: 28px 0 20px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 10px;
}

.tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 8px;
    border: 1px solid rgba(31, 30, 29, 0.12);
    border-radius: 12px;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
}

.tool-card.tool-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background-color: #faf9f5;
}

.tool-card:not(.tool-disabled):hover {
    background-color: #f3f1ea;
    transform: translateY(-2px);
    text-decoration: none;
}

a.tool-card {
    text-decoration: none;
    background-color: #fff;
    border-color: rgba(31, 30, 29, 0.2);
}

a.tool-card .tool-icon {
    color: #141413;
}

a.tool-card .tool-name {
    color: #141413;
}

.tool-icon {
    width: 32px;
    height: 32px;
    color: #555;
}

.tool-icon svg {
    width: 100%;
    height: 100%;
}

.tool-name {
    font-size: 0.68rem;
    font-weight: 600;
    color: #444;
    text-align: center;
    line-height: 1.3;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (max-width: 768px) {
    .tools-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.tools-grid-small {
    grid-template-columns: repeat(auto-fill, minmax(100px, 100px));
}

/* ── Tool feature card ─────────────────────────────────────────── */
.tools-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-feature-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: #fff;
    border: 1px solid rgba(31,30,29,.09);
    border-radius: 12px;
    padding: 20px 24px;
}

.tool-feature-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: #f3f2ee;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
}

.tool-feature-icon svg {
    width: 22px;
    height: 22px;
}

.tool-feature-body {
    flex: 1;
    min-width: 0;
}

.tool-feature-name {
    font-size: .85rem;
    font-weight: 600;
    color: #141413;
    margin-bottom: 4px;
}

.tool-feature-desc {
    font-size: .8rem;
    color: #777;
    line-height: 1.6;
}

.tool-feature-desc code {
    font-size: .78rem;
    background: #f3f2ee;
    padding: 1px 5px;
    border-radius: 4px;
    color: #555;
}

.tool-feature-btn {
    flex-shrink: 0;
    display: inline-block;
    padding: 8px 18px;
    background: #141413;
    color: #fff;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s;
}

.tool-feature-btn:hover {
    background: #2a2a28;
    color: #fff;
}

@media (max-width: 600px) {
    .tool-feature-card {
        flex-wrap: wrap;
    }
    .tool-feature-btn {
        width: 100%;
        text-align: center;
    }
}

/* ── AI / Developer Section ────────────────────────── */
.ai-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 0;
}

.ai-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #fff;
    border: 1px solid rgba(31,30,29,.09);
    border-radius: 12px;
    padding: 16px 18px;
}

.ai-card-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.ai-card-icon.mcp  { background: #ede9fe; color: #6d28d9; }
.ai-card-icon.api  { background: #e0f2fe; color: #0369a1; }

.ai-card-icon svg { width: 18px; height: 18px; }

.ai-card-body { flex: 1; min-width: 0; }

.ai-card-title {
    font-size: .82rem;
    font-weight: 600;
    color: #141413;
    margin-bottom: 2px;
}

.ai-card-subtitle {
    font-size: .75rem;
    color: #999;
    margin-bottom: 6px;
}

.ai-card-desc {
    font-size: .77rem;
    color: #777;
    line-height: 1.55;
}

.ai-card-links {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.ai-card-link {
    font-size: .75rem;
    font-weight: 500;
    color: #141413;
    text-decoration: none;
    border-bottom: 1px solid rgba(31,30,29,.25);
    padding-bottom: 1px;
    transition: border-color .15s, color .15s;
}

.ai-card-link:hover {
    color: #444;
    border-color: #141413;
}

@media (max-width: 600px) {
    .ai-section { grid-template-columns: 1fr; }
}

/* ── Two Column Layout ──────────────────────────────── */
.two-col {
    display: flex;
    gap: 0;
    align-items: stretch;
}

.col-left {
    flex: 1;
    padding-right: 32px;
    display: flex;
    flex-direction: column;
}

.col-left .download-list {
    flex: 1;
}

.col-left .download-list .btn-download {
    flex: 1;
}

.col-right {
    flex: 1;
    padding-left: 32px;
    display: flex;
    flex-direction: column;
}

.col-right .generator-box {
    flex: 1;
}

.col-divider {
    width: 1px;
    background-color: rgba(31, 30, 29, 0.1);
    align-self: stretch;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .two-col {
        flex-direction: column;
    }
    .col-left {
        padding-right: 0;
        padding-bottom: 24px;
    }
    .col-right {
        padding-left: 0;
    }
    .col-divider {
        width: 100%;
        height: 1px;
        margin: 8px 0;
    }
}

/* ── HTML to PDF — App Shell ─────────────────────────── */
.htpdf-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 42px); /* full viewport minus footer */
    margin: 0 -12px; /* extend past container padding */
}

.htpdf-error {
    background: #fff3f3;
    border: 1px solid rgba(220,50,50,.2);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: .88rem;
    color: #c00;
    margin-bottom: 12px;
}

/* Top Bar */
.htpdf-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(31,30,29,.1);
    background: #fff;
    flex-shrink: 0;
    gap: 12px;
}

.htpdf-topbar-left,
.htpdf-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.htpdf-back {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .82rem;
    color: #888;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.htpdf-back:hover { background: rgba(31,30,29,.06); color: #333; }

.htpdf-title {
    font-family: "Onest", sans-serif;
    font-weight: 700;
    font-size: .95rem;
    color: #141413;
}

.htpdf-badge {
    font-size: .7rem;
    font-weight: 500;
    background: rgba(31,30,29,.07);
    color: #666;
    padding: 2px 8px;
    border-radius: 20px;
}

.htpdf-btn-secondary {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid rgba(31,30,29,.18);
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.htpdf-btn-secondary:hover { background: rgba(31,30,29,.06); color: #222; }

.htpdf-btn-preview-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid rgba(31,30,29,.18);
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.htpdf-btn-preview-toggle.active {
    background: #141413;
    color: #fff;
    border-color: #141413;
}

.htpdf-btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    background: #141413;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.htpdf-btn-primary:hover { background: #2a2a28; }

/* Editor + Preview body */
.htpdf-body {
    display: grid;
    grid-template-columns: 1fr 4px 1fr;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Panels */
.htpdf-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.htpdf-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 38px;
    border-bottom: 1px solid rgba(31,30,29,.08);
    background: #faf9f5;
    flex-shrink: 0;
}

.htpdf-panel-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
}

.htpdf-hint {
    font-size: .72rem;
    color: #bbb;
}

.htpdf-refresh-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    color: #888;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 5px;
    transition: background .15s, color .15s;
}
.htpdf-refresh-btn:hover { background: rgba(31,30,29,.07); color: #333; }

/* Editor textarea */
.htpdf-editor {
    flex: 1;
    width: 100%;
    padding: 16px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: .82rem;
    line-height: 1.7;
    border: none;
    outline: none;
    resize: none;
    background: #fff;
    color: #1e1e1e;
    tab-size: 2;
}

/* Preview iframe */
.htpdf-preview-frame {
    flex: 1;
    border: none;
    width: 100%;
    background: #fff;
}

/* Resizer handle */
.htpdf-resizer {
    background: rgba(31,30,29,.08);
    cursor: col-resize;
    transition: background .15s;
    position: relative;
}
.htpdf-resizer:hover,
.htpdf-resizer:active { background: rgba(31,30,29,.2); }

/* ── HTML to PDF page ───────────────────────────────── */
.html-input {
    width: 100%;
    min-height: 320px;
    padding: 14px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    border: 1px solid rgba(31, 30, 29, 0.2);
    border-radius: 10px;
    background: #fff;
    color: #141413;
    resize: vertical;
    outline: none;
    margin-bottom: 14px;
}

.html-input:focus {
    border-color: rgba(31, 30, 29, 0.4);
}

.html-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.btn-clear, .btn-sample {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(31, 30, 29, 0.2);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-clear:hover, .btn-sample:hover {
    background: rgba(31, 30, 29, 0.06);
    color: #333;
}

.html-actions .btn-generate {
    margin-left: auto;
}

.error-banner {
    background: #fff3f3;
    border: 1px solid rgba(220, 50, 50, 0.2);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.88rem;
    color: #c00;
}

.btn-preview {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(31, 30, 29, 0.2);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #444;
    cursor: pointer;
    transition: background 0.15s ease;
    display: inline-flex;
    align-items: center;
}

.btn-preview:hover {
    background: rgba(31, 30, 29, 0.06);
    color: #111;
}

/* ── Preview Modal ───────────────────────────────────── */
.preview-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.preview-modal.open {
    display: flex;
}

.preview-modal-inner {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 860px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0,0,0,0.2);
    overflow: hidden;
}

.preview-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(31, 30, 29, 0.1);
    flex-shrink: 0;
}

.preview-modal-title {
    font-family: "Onest", sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: #141413;
}

.preview-modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.preview-modal-close:hover {
    background: rgba(31, 30, 29, 0.08);
    color: #333;
}

.preview-frame {
    flex: 1;
    border: none;
    width: 100%;
    min-height: 500px;
}

.back-link {
    margin-top: 16px;
    font-size: 0.85rem;
}

.back-link a {
    color: #888;
    text-decoration: none;
}

.back-link a:hover {
    color: #333;
}

/* ── Header ─────────────────────────────────────────── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: #faf9f5;
    border-bottom: 1px solid rgba(31,30,29,.08);
}

.site-header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-size: .88rem;
    font-weight: 700;
    color: #141413;
    text-decoration: none;
    letter-spacing: -.01em;
}

.site-logo:hover {
    color: #141413;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.site-nav-link {
    font-size: .82rem;
    font-weight: 500;
    color: #666;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}

.site-nav-link:hover {
    background: rgba(31,30,29,.06);
    color: #141413;
}

.site-nav-link.active {
    color: #141413;
    background: rgba(31,30,29,.07);
}

/* ── Footer ─────────────────────────────────────────── */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 0;
    background-color: #ffffff;
    border-top: 1px solid rgba(31, 30, 29, 0.1);
    text-align: center;
    font-size: 0.82rem;
    color: #aaa;
    z-index: 100;
}

.site-footer a {
    color: #888;
    text-decoration: none;
}

.site-footer a:hover {
    color: #333;
}

/* ── PDF to Markdown ─────────────────────────────────────────────────────── */
.p2md-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex: 1;
    margin: 16px;
    border: 2px dashed rgba(31,30,29,.18);
    border-radius: 10px;
    padding: 32px 20px;
    text-align: center;
    transition: border-color .2s, background .2s;
    cursor: default;
}
.p2md-upload-area.drag-over {
    border-color: #141413;
    background: rgba(20,20,19,.04);
}
.p2md-upload-icon svg {
    width: 40px;
    height: 40px;
    color: #aaa;
}
.p2md-upload-label {
    margin: 0;
    font-size: .9rem;
    color: #666;
}
.p2md-upload-hint {
    font-size: .8rem;
    color: #aaa;
    margin: 0;
}
.p2md-file-info {
    padding: 20px 16px;
}
.p2md-file-name {
    font-weight: 600;
    font-size: .95rem;
    word-break: break-all;
    margin-bottom: 4px;
}
.p2md-file-size {
    font-size: .82rem;
    color: #888;
}
.p2md-error {
    margin: 0 16px 16px;
    padding: 10px 14px;
    background: #fff3f3;
    border: 1px solid rgba(220,50,50,.2);
    border-radius: 8px;
    color: #c0392b;
    font-size: .85rem;
}
.p2md-preview-wrap {
    flex: 1;
    display: flex;
    min-height: 0;
}
.p2md-preview {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    padding: 16px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
    font-size: .84rem;
    line-height: 1.65;
    background: #faf9f5;
    color: #141413;
    white-space: pre;
}
.w-100 { width: 100%; }
.mt-3 { margin-top: 12px; }
