:root {
    --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

    --page-bg: linear-gradient(145deg, #0b1c3a 0%, #10366a 42%, #1f6bb5 100%);
    --surface: rgba(255, 255, 255, 0.96);
    --surface-soft: rgba(255, 255, 255, 0.9);
    --surface-inverse: rgba(15, 23, 42, 0.28);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-on-dark: #e2e8f0;

    --line: rgba(148, 163, 184, 0.3);
    --focus: #1d4ed8;

    --brand-500: #2563eb;
    --brand-600: #1d4ed8;
    --brand-100: #dbeafe;
    --success: #0f766e;
    --danger: #b91c1c;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --shadow-sm: 0 10px 26px rgba(2, 6, 23, 0.14);
    --shadow-md: 0 18px 48px rgba(2, 6, 23, 0.2);

    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--page-bg);
    -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

input,
textarea,
button,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

.page-main {
    min-height: calc(100vh - 180px);
}

.container {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 0 24px;
}

.narrow-copy {
    max-width: 760px;
}

.stack-lg {
    display: grid;
    gap: var(--space-8);
}

/* Header */
.navbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(8, 19, 40, 0.8);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.nav-flex {
    min-height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-6);
}

.logo a {
    font-size: 30px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #f8fafc;
}

nav {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    flex-wrap: wrap;
}

.site-nav {
    transition: max-height 0.2s ease, opacity 0.2s ease;
}

nav a {
    color: var(--text-on-dark);
    font-weight: 600;
    opacity: 0.9;
}

nav a:hover {
    opacity: 1;
}

.btn-login {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.nav-toggle {
    display: none;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.35);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    padding: 8px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
}

.nav-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    background: #e2e8f0;
    border-radius: 999px;
}

/* Page sections */
.hero {
    padding: 42px 0 20px;
    text-align: center;
    color: #f8fafc;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.hero p {
    max-width: 760px;
    margin: 14px auto 0;
    font-size: 1rem;
    color: #dbeafe;
}

.section {
    padding: 26px 0;
}

.section-title {
    margin: 0 0 20px;
    text-align: center;
    font-size: clamp(1.5rem, 2.8vw, 2rem);
    color: #f8fafc;
}

.section-title-left {
    text-align: left;
    margin-bottom: 0;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.bg-light {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.16), rgba(15, 23, 42, 0.1));
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.grid {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card,
.tool-card,
.category-card {
    display: block;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(203, 213, 225, 0.8);
    padding: 22px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover,
.tool-card:hover,
.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card h3,
.tool-card h3,
.category-card h3 {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.3;
}

.card p,
.tool-card p,
.category-card p {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.popular-tools-section {
    position: relative;
}

.popular-tools-head {
    text-align: center;
    margin-bottom: 16px;
}

.popular-tools-head p {
    margin: -8px 0 0;
    color: #cbd5e1;
    font-size: 0.95rem;
}

.popular-tools-grid {
    gap: 16px;
}

.popular-tool-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.97));
    border: 1px solid rgba(191, 219, 254, 0.55);
    box-shadow: 0 14px 34px rgba(2, 6, 23, 0.16);
    padding: 18px 18px 16px;
    border-radius: 16px;
}

.popular-tool-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.popular-tool-top h3 {
    margin: 0;
}

.popular-tool-arrow {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: #1e3a8a;
    background: #dbeafe;
    border: 1px solid #bfdbfe;
}

.popular-tool-card p {
    margin-top: 8px;
    font-size: 0.9rem;
    min-height: 44px;
}


.inline-link {
    font-size: 0.9rem;
    color: #bfdbfe;
    font-weight: 600;
}

.inline-link:hover {
    color: #ffffff;
}

.empty-copy {
    margin: 0;
    color: #dbeafe;
}

.icon {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
}

.icon-sm {
    width: 34px;
    height: 34px;
}

.card.icon-card {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
}

.search-box input {
    width: min(680px, 100%);
    margin: 16px auto 0;
    border: 1px solid rgba(148, 163, 184, 0.6);
    border-radius: 999px;
    padding: 12px 16px;
    background: rgba(248, 250, 252, 0.98);
    box-shadow: var(--shadow-sm);
}

.search-box {
    width: min(680px, 100%);
    margin: 0 auto;
}

.search-results {
    margin-top: 12px;
    display: none;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.search-results.is-visible {
    display: flex;
}

.search-result-empty {
    padding: 4px 10px;
    color: #dbeafe;
    font-size: 0.88rem;
}

.tool-chips {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
}

.tool-chips span {
    background: var(--surface-inverse);
    color: #dbeafe;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
}

.tool-chips .tool-chip-link {
    display: inline-flex;
    align-items: center;
    background: var(--surface-inverse);
    color: #dbeafe;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
}

.cta {
    text-align: center;
    padding: 68px 20px;
    color: #f8fafc;
}

.cta h2 {
    margin: 0;
    font-size: clamp(1.7rem, 3.8vw, 2.4rem);
}

.btn-primary {
    display: inline-block;
    margin-top: 18px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.footer {
    text-align: center;
    padding: 24px 20px 30px;
    color: #dbeafe;
    font-size: 0.88rem;
}

.footer-links {
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
}

.footer-links a {
    color: #dbeafe;
}

/* Tool framework */
.tool-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(203, 213, 225, 0.8);
    box-shadow: var(--shadow-md);
    padding: 24px;
    margin-bottom: 22px;
}

.tool-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.tool-tabs .tab {
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    background: #e2e8f0;
    color: #334155;
    font-weight: 700;
}

.tool-tabs .tab.active {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
}

.tool-panel {
    display: none;
}

.tool-panel.active {
    display: block;
}

.tool-textarea,
.tool-text-input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: var(--text-primary);
    background: #ffffff;
}

.tool-textarea {
    min-height: 220px;
    resize: vertical;
}

.tool-textarea:focus,
.tool-text-input:focus {
    outline: 2px solid color-mix(in srgb, var(--focus) 28%, transparent);
    border-color: var(--focus);
}

.json-textarea {
    font-family: var(--font-mono);
    white-space: pre;
    overflow-wrap: normal;
    word-break: normal;
    overflow-x: auto;
    tab-size: 4;
}

.tool-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.reading-time {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    flex: 1 1 280px;
    min-width: 220px;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.btn-primary-action,
.btn-secondary,
.btn-clear {
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.84rem;
    font-weight: 700;
}

.btn-primary-action {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
}

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

.btn-clear {
    background: #e2e8f0;
    color: #334155;
}

.btn-primary-action:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

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

.btn-clear:hover {
    background: #cbd5e1;
}

.btn-primary-action:disabled,
.btn-secondary:disabled,
.btn-clear:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.tool-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.json-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1fr;
}

.json-grid > div {
    min-width: 0;
}

.base64-options {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 10px 0 0;
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 600;
}

.base64-options label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.base64-file-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

.base64-upload-btn {
    margin-top: 0;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

.uuid-count-select {
    width: 110px;
    min-width: 110px;
    flex: 0 0 auto;
}

.meta-row {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.jwt-signature {
    margin-top: 14px;
}

.hash-result-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr 1fr;
    margin-top: 16px;
}

.hash-result-card {
    border: 1px solid rgba(203, 213, 225, 0.8);
    background: var(--surface-soft);
    border-radius: var(--radius-md);
    padding: 12px;
}

.hash-result-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.hash-result-head strong {
    font-size: 0.9rem;
}

.hash-output {
    min-height: 90px;
}

.status-success {
    color: var(--success);
}

.status-error {
    color: var(--danger);
}

.upload-box {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 28px 20px;
    text-align: center;
    background: #f8fafc;
}

.upload-box p {
    margin: 6px 0;
    color: var(--text-secondary);
}

.upload-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 9px 14px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 700;
}

.upload-hint {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.inline-file-actions {
    margin-top: 10px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-file-actions .upload-btn {
    margin-top: 0;
}

.inline-download {
    white-space: nowrap;
    min-width: 180px;
}

.secondary-upload-btn {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.upload-progress {
    margin: 12px auto 6px;
    width: min(420px, 90%);
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    display: none;
}

.upload-progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    transition: width 0.2s ease;
}

.upload-progress.processing .upload-progress-bar {
    width: 100%;
    animation: upload-pulse 0.9s ease-in-out infinite;
}

.upload-progress-text {
    display: none;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    width: 100%;
}

.upload-box.processing {
    pointer-events: none;
}

@keyframes upload-pulse {
    0% {
        opacity: 0.45;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.45;
    }
}

.stats-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin-bottom: 16px;
}

.stat-card {
    text-align: center;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(203, 213, 225, 0.8);
    background: var(--surface-soft);
}

.stat-card h4 {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.stat-card span {
    display: block;
    margin-top: 6px;
    font-size: 1.5rem;
    font-weight: 800;
}

.privacy-note {
    margin-top: 8px;
    font-size: 0.82rem;
    color: #dbeafe;
    text-align: center;
}

.drop-overlay {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(30, 58, 138, 0.15);
    backdrop-filter: blur(2px);
    z-index: 9999;
}

.drop-overlay.active {
    display: flex;
}

.drop-overlay-content {
    background: #ffffff;
    border: 2px dashed var(--brand-500);
    border-radius: var(--radius-md);
    padding: 32px 40px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.drop-overlay-content strong {
    display: block;
    font-size: 1.25rem;
    color: var(--brand-600);
}

.drop-overlay-content span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Tools index */
.category-group {
    display: grid;
    gap: 14px;
}

.merge-pdf-preview-grid {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.merge-pdf-preview-card {
    background: #eef2f7;
    border: 1px solid #d2dce9;
    border-radius: var(--radius-md);
    padding: 10px;
    position: relative;
    cursor: grab;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.merge-pdf-preview-frame {
    width: calc(100% + 16px);
    height: 230px;
    border: 0;
    border-radius: 10px;
    background: #ffffff;
    pointer-events: none;
    clip-path: inset(0 16px 0 0 round 10px);
}

.merge-pdf-preview-card.is-dragging {
    opacity: 0.55;
    cursor: grabbing;
}

.merge-pdf-preview-card.is-drop-target {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.merge-pdf-preview-name {
    margin-top: 8px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.merge-pdf-preview-meta {
    margin-top: 3px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.merge-pdf-remove-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: 1px solid #64748b;
    border-radius: 999px;
    background: #0f172a;
    color: #ffffff;
    font-size: 19px;
    font-weight: 800;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

.merge-pdf-remove-icon:hover {
    background: #b91c1c;
    border-color: #991b1b;
    color: #ffffff;
}

/* Responsive */
@media (max-width: 960px) {
    .nav-flex {
        align-items: center;
        min-height: 64px;
        gap: 10px;
        padding-top: 10px;
        padding-bottom: 10px;
        justify-content: space-between;
        flex-direction: row;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .site-nav {
        width: 100%;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        display: grid;
        gap: 8px;
        padding-top: 0;
    }

    .site-nav.is-open {
        max-height: 280px;
        opacity: 1;
        padding-top: 8px;
        padding-bottom: 4px;
    }

    .site-nav a {
        display: block;
        width: 100%;
        padding: 8px 10px;
        border-radius: 8px;
        background: rgba(15, 23, 42, 0.25);
    }

    .site-nav .btn-login {
        text-align: center;
        margin-top: 4px;
    }

    .hero {
        padding-top: 30px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .json-grid {
        grid-template-columns: 1fr;
    }

    .hash-result-grid {
        grid-template-columns: 1fr;
    }

    .base64-file-row {
        flex-direction: column;
        align-items: stretch;
    }

    .tool-box {
        padding: 16px;
    }

    .tool-actions {
        align-items: stretch;
    }

    .action-buttons {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .action-buttons > button {
        width: 100%;
        text-align: center;
    }

    .tool-textarea {
        min-height: 180px;
    }
}

@media (max-width: 420px) {
    .action-buttons {
        grid-template-columns: 1fr;
    }
}
