:root {
    --ink: #102029;
    --muted: #64748b;
    --line: #d8e1e8;
    --panel: #ffffff;
    --page: #eef3f5;
    --teal: #0f766e;
    --teal-dark: #164e63;
    --amber: #92400e;
    --amber-bg: #fffbeb;
    --green-bg: #dcfce7;
    --green: #166534;
    font-family: Aptos, Segoe UI, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10;
    padding: 10px 16px;
    background: var(--teal-dark);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus {
    left: 8px;
    top: 8px;
}

:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--page);
}

.site-header,
.site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.brand {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand span {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--teal);
    color: #fff;
    font-weight: 900;
    font-size: 12px;
}

.brand span::before {
    content: "FT";
}

.brand strong {
    font-size: 16px;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.site-nav a,
.site-footer a {
    color: #334155;
    text-decoration: none;
    font-weight: 800;
}

.site-nav a {
    padding: 10px 12px;
    border-radius: 6px;
}

.site-nav a.active,
.site-nav a:hover {
    color: var(--teal-dark);
    background: #dff7f2;
}

.hero,
.section-wrap,
.directory-page,
.content-page,
.tool-page > .tool-hero,
.tool-page > .tool-details {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
    align-items: stretch;
    padding: 44px 0 22px;
}

.hero-copy,
.hero-panel,
.page-title,
.tool-hero,
.section-wrap,
.content-page .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.07);
}

.hero-copy,
.hero-panel,
.page-title,
.tool-hero,
.section-wrap {
    padding: 28px;
}

.hero h1,
.page-title h1,
.tool-hero h1,
.content-page h1 {
    font-size: 42px;
    line-height: 1.08;
    max-width: 820px;
}

.hero p,
.page-title p,
.tool-hero p {
    color: #475569;
    font-size: 17px;
    line-height: 1.55;
    max-width: 760px;
}

.hero-panel {
    display: grid;
    align-content: center;
    gap: 12px;
}

.hero-panel p {
    color: #475569;
    line-height: 1.55;
}

.tool-search {
    margin-top: 22px;
}

.tool-search label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 800;
}

.tool-search div {
    display: flex;
    gap: 8px;
}

.tool-search input {
    flex: 1;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 14px;
    font: inherit;
}

.tool-search button {
    border: 0;
    border-radius: 6px;
    /* Height must not depend on flex stretch: under 560px the wrapper becomes a
       grid, which left this button 19px tall and barely tappable. */
    min-height: 46px;
    padding: 0 18px;
    background: var(--teal-dark);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

.section-wrap {
    margin-top: 20px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-note {
    margin: -6px 0 16px;
    color: var(--muted);
    line-height: 1.55;
}

.section-heading a {
    /* Meet the WCAG 2.5.8 minimum target size rather than the 21px line box. */
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    color: var(--teal-dark);
    font-weight: 900;
    text-decoration: none;
}

.section-heading a:hover {
    text-decoration: underline;
}

.tool-grid,
.category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.tool-card,
.category-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: inherit;
    text-decoration: none;
}

.tool-card {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
    align-items: start;
}

.tool-card .small-button {
    grid-column: 1 / -1;
}

.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #dff7f2;
    color: var(--teal-dark);
    font-weight: 900;
}

.tool-card h3,
.category-card h3 {
    margin: 0 0 6px;
}

.tool-card p,
.category-card p,
.content-page p,
.tool-details p {
    color: #475569;
    line-height: 1.55;
}

.tool-card small {
    color: var(--muted);
}

.small-button.disabled {
    pointer-events: none;
    color: var(--muted);
}

.category-card {
    padding: 18px;
}

.split-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

.steps-list {
    margin: 0;
    padding-left: 22px;
    color: #334155;
    line-height: 1.8;
}

.faq-preview .faq-answer {
    border-top: 1px solid var(--line);
    padding: 12px 0;
}

.faq-preview h3 {
    margin: 0;
    font-size: 15px;
}

.directory-page,
.content-page {
    padding: 24px 0;
}

.directory-grid {
    margin-top: 18px;
}

.tool-page {
    padding-bottom: 24px;
}

.tool-hero {
    margin-top: 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 18px;
}

.tool-meta {
    display: grid;
    gap: 10px;
    align-content: center;
}

.tool-meta span {
    border: 1px solid var(--line);
    background: #f8fafc;
    border-radius: 6px;
    padding: 10px 12px;
    font-weight: 800;
}

.tool-shell {
    margin-top: 20px;
}

.related-list {
    display: grid;
    gap: 8px;
}

.related-list a {
    color: var(--teal-dark);
    font-weight: 800;
    text-decoration: none;
}

.site-footer {
    margin-top: 24px;
    padding: 24px 0 34px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    color: #475569;
}

.site-footer p {
    margin: 6px 0 0;
}

.site-footer nav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.site-footer nav a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px;
}

.shell.single {
    grid-template-columns: 1fr;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.07);
    padding: 24px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--teal);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

code {
    font-family: Consolas, Monaco, monospace;
    background: #eef6f4;
    border: 1px solid #cfe4df;
    border-radius: 4px;
    padding: 1px 4px;
}

h1 {
    font-size: 30px;
    line-height: 1.15;
}

h2 {
    font-size: 16px;
    margin-bottom: 12px;
}

.ghost-link,
.small-button {
    /* These are primary actions (a tool card's "Open tool", a history row's
       "Download"), so they need a target taller than their 21px line box.
       WCAG 2.5.8 asks for at least 24x24 CSS pixels. */
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    color: var(--teal-dark);
    text-decoration: none;
    font-weight: 700;
}

.ghost-link:hover,
.small-button:hover {
    text-decoration: underline;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header-actions form {
    margin: 0;
}

.danger-link {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    border: 0;
    background: transparent;
    color: #991b1b;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    padding: 0;
}

.success-banner {
    border: 1px solid #86efac;
    background: var(--green-bg);
    color: var(--green);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-weight: 700;
}

.upload-form {
    display: grid;
    gap: 14px;
}

.dropzone {
    min-height: 230px;
    border: 2px dashed #9fb4bd;
    border-radius: 8px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 24px;
    cursor: pointer;
    background: #f8fafc;
    transition: border-color .18s, background .18s;
}

.dropzone input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
}

.dropzone.is-over {
    border-color: var(--teal);
    background: #ecfdf5;
}

.dropzone strong,
.dropzone small,
.drop-icon {
    display: block;
}

.dropzone strong {
    margin-top: 12px;
    font-size: 20px;
}

.dropzone small {
    color: var(--muted);
    margin-top: 6px;
}

.drop-icon {
    width: 58px;
    height: 72px;
    border: 2px solid var(--teal);
    color: var(--teal);
    display: grid;
    place-items: center;
    font-weight: 800;
    border-radius: 6px;
    background: #ffffff;
}

.file-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #ffffff;
}

.file-card span {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

.file-card button,
/* Was split across two separate .primary-button blocks with an unrelated rule
   between them; merged so the whole button style is in one place. */
.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    background: var(--teal);
    color: #ffffff;
    padding: 13px 18px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 800;
    text-decoration: none;
}

.file-card button {
    color: #991b1b;
    background: #fee2e2;
    padding: 9px 12px;
}

.primary-button:disabled {
    cursor: wait;
    opacity: .7;
}

.progress-panel,
.result-panel {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.progress-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.progress-heading h2 {
    margin-bottom: 0;
}

#progressPercent {
    color: var(--teal-dark);
    font-size: 18px;
}

.progress-bar {
    height: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #e2e8f0;
}

.progress-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--teal);
    transition: width .25s ease;
}

.progress-status {
    margin: 8px 0 14px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

#progressSteps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none;
}

#progressSteps li {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--muted);
}

#progressSteps li.active {
    border-color: var(--teal);
    color: var(--teal-dark);
    background: #ecfdf5;
    font-weight: 800;
}

#progressSteps li.done {
    color: var(--green);
    background: var(--green-bg);
}

.result-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #f8fafc;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.metric {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 20px;
}

.download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 6px;
    background: var(--teal-dark);
    color: #ffffff;
    text-decoration: none;
    font-weight: 800;
}

.warning-list,
.note-list {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: 6px;
}

.warning-list {
    background: var(--amber-bg);
    border: 1px solid #facc15;
    color: var(--amber);
}

.note-list {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
}

.preview-panel {
    margin: 14px 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
}

.preview-panel summary {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 800;
    color: var(--teal-dark);
}

.preview-panel pre {
    margin: 0;
    max-height: 320px;
    overflow: auto;
    border-top: 1px solid var(--line);
    padding: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    font: 13px/1.5 Consolas, "Liberation Mono", monospace;
    color: #0f172a;
}

.info-panel ul {
    padding-left: 18px;
    margin-top: 0;
    color: #334155;
}

.info-panel li {
    margin-bottom: 8px;
}

.history-list {
    display: grid;
    gap: 8px;
}

.history-list a {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
    color: inherit;
    text-decoration: none;
    background: #f8fafc;
}

.history-list small,
.history-table small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.table-wrap {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

.history-table th {
    background: var(--teal);
    color: #ffffff;
}

.empty-state {
    padding: 18px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
}

.mode-toggle {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.mode-toggle label {
    cursor: pointer;
}

.mode-toggle input {
    position: absolute;
    opacity: 0;
}

.mode-toggle span {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 6px;
    font-weight: 800;
    color: var(--muted);
}

.mode-toggle input:checked + span {
    background: var(--teal);
    color: #ffffff;
}

.organizer-workspace {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.workspace-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.workspace-head h2 {
    margin-bottom: 0;
}

.ghost-button {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--teal-dark);
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 800;
}

.organizer-controls {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.organizer-controls p {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

.merge-file-list {
    display: grid;
    gap: 8px;
}

.merge-file-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    padding: 10px;
    cursor: grab;
}

.merge-file-card small {
    color: var(--muted);
}

.merge-file-card.is-empty {
    border-color: #facc15;
    background: var(--amber-bg);
}

.merge-file-card.is-empty small {
    color: var(--amber);
    font-weight: 700;
}

.removed-pages {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
    padding: 12px;
}

.removed-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.removed-pages p {
    margin: 6px 0 10px;
    color: var(--muted);
    font-size: 13px;
}

.removed-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.removed-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
    padding: 4px 6px 4px 12px;
    font-size: 12px;
    color: #334155;
}

.removed-chip button {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--teal-dark);
    min-height: 26px;
    padding: 0 10px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}

.removed-chip button:hover {
    background: #e2e8f0;
}

.drag-handle {
    background: #e2e8f0;
    color: #334155;
    border-radius: 5px;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 800;
}

.split-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.split-grid label {
    display: grid;
    gap: 5px;
    color: #334155;
    font-weight: 800;
}

.split-grid input,
.split-grid select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
}

.check-row {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: auto;
    min-height: auto;
}

.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.page-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

.page-card.is-selected {
    border-color: var(--teal);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, .14);
}

.thumb-wrap {
    height: 210px;
    display: grid;
    place-items: center;
    background: #e2e8f0;
    overflow: hidden;
}

.thumb-wrap img {
    max-width: 100%;
    max-height: 100%;
    transition: transform .18s ease;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .18);
}

.page-card-meta {
    padding: 10px 10px 0;
}

.page-card-meta small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
}

.page-actions button,
.select-page {
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #f8fafc;
    color: #334155;
    min-height: 32px;
    padding: 0 8px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}

.select-page {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.page-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(15, 23, 42, .72);
    display: grid;
    place-items: center;
    padding: 24px;
}

.page-preview-modal[hidden] {
    display: none;
}

.page-preview-modal button {
    position: fixed;
    top: 18px;
    right: 18px;
    border: 0;
    border-radius: 6px;
    padding: 10px 14px;
    background: #ffffff;
    color: #0f172a;
    cursor: pointer;
    font-weight: 800;
}

.page-preview-modal img {
    max-width: min(100%, 980px);
    max-height: 88vh;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

@media (max-width: 900px) {
    .site-header,
    .site-footer {
        width: min(100% - 20px, 720px);
    }

    .site-header,
    .site-footer,
    .tool-hero {
        display: grid;
    }

    .site-nav,
    .site-footer nav {
        justify-content: start;
    }

    .hero,
    .tool-grid,
    .category-grid,
    .split-section {
        grid-template-columns: 1fr;
    }

    .hero,
    .section-wrap,
    .directory-page,
    .content-page,
    .tool-page > .tool-hero,
    .tool-page > .tool-details {
        width: min(100% - 20px, 720px);
    }

    .shell {
        grid-template-columns: 1fr;
        width: min(100% - 20px, 720px);
        margin: 16px auto;
    }

    .metrics,
    .split-grid,
    #progressSteps {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 18px;
    }

    .workspace-head {
        display: grid;
    }

    .merge-file-card {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .page-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .thumb-wrap {
        height: 180px;
    }
}

@media (max-width: 560px) {
    .panel-header,
    .file-card {
        display: grid;
    }

    h1 {
        font-size: 25px;
    }

    .hero h1,
    .page-title h1,
    .tool-hero h1,
    .content-page h1 {
        font-size: 30px;
    }

    .tool-search div {
        display: grid;
    }
}
