/* ft-paper design tokens — https://camillehdl.dev/palette */
:root {
    --paper: #fff1e5;
    --paper-raised: #fff9f2;
    --surface-1: #f7e7d8;
    --surface-2: #f2dfce;
    --surface-3: #efdcca;
    --rule: #b8afa5;

    --ink: #262a33;
    --ink-2: #4a4f59;
    --ink-muted: #6b6259;
    --ink-faint: #7d746b;
    --ink-disabled: #b8afa5;

    --claret: #990f3d;
    --oxford: #0f5499;
    --jade: #00733a;
    --mandarin: #99521f;
    --crimson: #cc0000;
    --teal: #0d7680;
    --velvet: #593380;

    --font-display: "Caveat", cursive;
    --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    --space-xs: 0.35rem;
    --space-sm: 0.65rem;
    --space-md: 1.1rem;
    --space-lg: 1.75rem;
    --space-xl: 2.75rem;
    --space-2xl: 4rem;

    --measure: 42rem;
    --page-width: 72rem;
    --radius: 6px;
    --focus: 3px solid var(--oxford);
}

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

html {
    font-size: 112.5%;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.55;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-body);
    font-weight: 600;
    line-height: 1.25;
    color: var(--ink);
}

h1 {
    font-size: 2.4rem;
    margin: 0 0 var(--space-md);
}

h2 {
    font-size: 1.35rem;
    margin: 0 0 var(--space-sm);
}

h3 {
    font-size: 1.1rem;
    margin: 0 0 var(--space-sm);
}

p {
    margin: 0 0 var(--space-md);
}

a {
    color: var(--oxford);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
}

a:hover {
    color: var(--claret);
}

:focus {
    outline: none;
}

:focus-visible {
    outline: var(--focus);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    left: var(--space-md);
    top: -4rem;
    z-index: 20;
    padding: var(--space-xs) var(--space-sm);
    background: var(--paper-raised);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}

.skip-link:focus {
    top: var(--space-sm);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header {
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
}

.site-header-inner {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.site-wordmark {
    font-family: var(--font-display);
    font-size: 1.85rem;
    line-height: 1;
    color: var(--claret);
    text-decoration: none;
}

.site-wordmark:hover {
    color: var(--claret);
}

.site-meta {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.site-meta a {
    color: var(--ink-2);
}

.page {
    flex: 1;
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg) 7rem;
}

.page--preview {
    max-width: none;
    padding: var(--space-md) var(--space-md) 7rem;
}

.lede {
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: var(--ink-2);
    max-width: var(--measure);
}

.wordmark-hero {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 4.5rem);
    line-height: 1;
    color: var(--claret);
    text-align: center;
    margin: 0 0 var(--space-lg);
}

/* Steps */
.steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.steps-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    list-style: none;
    margin: 0;
    padding: 0;
}

.steps-list li {
    color: var(--ink-faint);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.steps-list li.is-done,
.steps-list li.is-current {
    color: var(--ink);
}

.steps-list a {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: inherit;
    text-decoration: none;
}

.steps-list a:hover {
    color: var(--claret);
    text-decoration: underline;
}

.steps-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 50%;
    border: 1px solid var(--rule);
    font-size: 0.8rem;
    font-family: var(--font-ui);
}

.is-current .steps-num {
    background: var(--claret);
    border-color: var(--claret);
    color: var(--paper-raised);
}

.is-done .steps-num {
    background: var(--surface-2);
    color: var(--ink);
}

.steps-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.5rem;
    padding: 0.4rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--rule);
    background: var(--paper-raised);
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    background: var(--surface-1);
    color: var(--ink);
}

.btn-primary {
    background: var(--claret);
    border-color: var(--claret);
    color: var(--paper-raised);
}

.btn-primary:hover {
    background: #7a0c31;
    border-color: #7a0c31;
    color: var(--paper-raised);
}

.btn-quiet {
    background: transparent;
    border-color: transparent;
    color: var(--oxford);
}

.btn-quiet:hover {
    background: var(--surface-1);
    color: var(--claret);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    color: var(--ink-disabled);
    border-color: var(--rule);
    background: var(--surface-1);
    cursor: not-allowed;
}

.is-invisible {
    visibility: hidden;
}

/* Dropzone */
.dropzone {
    display: block;
    width: 100%;
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    background: var(--paper-raised);
    border: 2px dashed var(--rule);
    border-radius: 10px;
    cursor: pointer;
    color: var(--ink-2);
}

.dropzone:hover,
.dropzone.is-active,
.dropzone:focus-visible {
    border-color: var(--oxford);
    background: #fff;
}

.dropzone-title {
    font-family: var(--font-body);
    font-size: 1.55rem;
    color: var(--ink);
    margin: 0 0 var(--space-sm);
}

.dropzone-hint {
    color: var(--ink-muted);
    margin: 0 0 var(--space-lg);
}

.dropzone .btn {
    cursor: pointer;
}

/* File list */
.file-panel {
    margin-top: var(--space-xl);
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: var(--space-lg);
    text-align: left;
}

.file-panel-summary {
    color: var(--ink-muted);
    margin: 0 0 var(--space-md);
    font-size: 0.95rem;
}

.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.file-list li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-top: 1px solid var(--surface-2);
}

.file-list li:first-child {
    border-top: 0;
    padding-top: 0;
}

.file-list-title {
    font-weight: 600;
    color: var(--ink);
}

.file-list-meta {
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.status-note {
    margin-top: var(--space-md);
    color: var(--ink-2);
    font-size: 0.95rem;
}

/* Recipe groups */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    gap: var(--space-lg);
}

.recipe-group {
    background: var(--paper-raised);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    padding: var(--space-lg);
}

.recipe-group h2 {
    font-size: 1.25rem;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--rule);
}

.recipe-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.recipe-list li + li {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--surface-1);
}

.recipe-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
}

.recipe-row label {
    cursor: pointer;
}

.recipe-row input {
    margin-top: 0.35rem;
    accent-color: var(--claret);
    width: 1.1rem;
    height: 1.1rem;
}

.recipe-label {
    font-weight: 600;
    color: var(--ink);
}

.recipe-complement {
    display: block;
    color: var(--ink-muted);
    font-size: 0.9rem;
    font-weight: 400;
}

.preview-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    margin: 0 0 var(--space-lg);
    padding: 0.55rem 0.85rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--paper-raised);
    border: 1px solid var(--surface-2);
    border-radius: var(--radius);
}

.preview-toggle input {
    accent-color: var(--oxford);
    width: 1.1rem;
    height: 1.1rem;
}

/* Preview / diff */
.preview-layout {
    display: grid;
    grid-template-columns: 18rem minmax(0, 1fr);
    gap: var(--space-md);
    align-items: start;
}

@media (min-width: 1400px) {
    .preview-layout {
        grid-template-columns: 20rem minmax(0, 1fr);
    }
}

.preview-aside {
    background: var(--paper-raised);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    padding: var(--space-md);
    max-height: calc(100vh - 8rem);
    overflow: auto;
}

.preview-aside > .btn {
    margin-bottom: var(--space-md);
}

.preview-aside .recipe-group {
    border: 0;
    padding: var(--space-md) 0;
    background: transparent;
}

.preview-main {
    min-width: 0;
}

.page--preview .notice {
    margin-bottom: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
}

.preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

@media (max-width: 800px) {
    .preview-layout {
        grid-template-columns: 1fr;
    }

    .preview-aside {
        max-height: 50vh;
    }
}

/* Forms */
.field {
    display: block;
    margin: var(--space-sm) 0;
}

.field-label {
    display: block;
    color: var(--ink-2);
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}

.field input[type="text"],
.field select,
.select-file select {
    width: 100%;
    min-height: 2.4rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    font: inherit;
}

.field input[type="text"]:focus-visible,
.field select:focus-visible,
.select-file select:focus-visible {
    border-color: var(--oxford);
}

.select-file {
    display: block;
    margin: var(--space-sm) 0 var(--space-md);
}

.select-file-label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.replace-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

@media (max-width: 640px) {
    .replace-row {
        grid-template-columns: 1fr;
    }
}

/* Results */
.download-list {
    display: grid;
    gap: var(--space-md);
}

.download-option {
    background: var(--paper-raised);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    padding: var(--space-lg);
}

.download-option p {
    color: var(--ink-2);
    margin-bottom: var(--space-md);
}

.merge-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.merge-option {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    min-height: 2.5rem;
}

.merge-option input {
    accent-color: var(--oxford);
    width: 1.1rem;
    height: 1.1rem;
}

.notice {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius);
    border: 1px solid var(--rule);
    background: var(--surface-1);
    color: var(--ink);
    margin-bottom: var(--space-lg);
}

.notice-warning {
    border-left: 4px solid var(--mandarin);
}

.notice-error {
    border-left: 4px solid var(--crimson);
}

.notice-success {
    border-left: 4px solid var(--jade);
}

.notice-info {
    border-left: 4px solid var(--oxford);
}

/* Changelog / extras */
.extras {
    margin-top: var(--space-2xl);
    max-width: var(--page-width);
    margin-left: auto;
    margin-right: auto;
    padding: 0 var(--space-lg) var(--space-2xl);
}

.extras details {
    background: var(--paper-raised);
    border: 1px solid var(--surface-2);
    border-radius: 8px;
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-sm);
}

.extras summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ink);
}

.extras summary:hover {
    color: var(--claret);
}

.extras .hint {
    color: var(--mandarin);
}

.csv-example {
    overflow-x: auto;
}

.csv-example pre {
    background: var(--surface-1);
    padding: var(--space-md);
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.csv-example table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: var(--space-md) 0;
}

.csv-example th,
.csv-example td {
    border: 1px solid var(--surface-2);
    padding: 0.4rem 0.55rem;
    text-align: left;
    vertical-align: top;
}

.csv-example th {
    background: var(--surface-1);
}

/* Quick download actions */
.quick-actions {
    position: fixed;
    right: var(--space-lg);
    bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
    z-index: 10;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-xl);
    color: var(--ink-muted);
}

.spinner {
    width: 1.4rem;
    height: 1.4rem;
    border: 2px solid var(--surface-2);
    border-top-color: var(--claret);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: none;
        border-top-color: var(--claret);
        border-right-color: var(--claret);
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.diff-chrome {
    background: var(--paper-raised);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    overflow: auto;
    max-height: calc(100vh - 9rem);
}

.diff-chrome table {
    width: 100%;
    font-size: 0.82rem;
}
