:root {
    --text: #2c2c2c;
    --background: #fdfbf7;
    /* Cream/Paper white */
    --url: #8E8D93;
    /* Unused? Muted */
    --highlight: #d4af37;
    /* Muted Gold */
    --banner: #143b58;
    /* Deep Navy */
    --button: #143b58;
    --button-text: #ffffff;
    --error: #a31616;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 32px;
}

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

/* || General page layout */
body {
    background: var(--background);
    color: var(--text);
    margin: 0;
    padding: 0;
    font-family: Garamond, serif;
    font-size: 1.1rem;
    line-height: 1.6;
}

main {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

a {
    color: var(--banner);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--highlight);
}

/* || Navbar */
nav {
    background: var(--banner);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

nav ul {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    max-width: 1200px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

nav li {
    position: relative;
}

nav li a {
    display: block;
    color: white;
    padding: 16px 20px;
    text-decoration: none;
    font-size: 1.1rem;
}

nav li a:hover,
.dropdown:hover .dropbtn {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--highlight);
    text-decoration: none;
}

/* Dropdown */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    /* Align right */
    background-color: white;
    min-width: 180px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1;
    border: 1px solid #eee;
}

.dropdown-content a {
    color: var(--text);
    padding: 12px 16px;
    text-align: left;
    display: block;
}

.dropdown-content a:hover {
    background-color: #f5f5f5;
    color: var(--banner);
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* || Footer */
footer {
    background-color: var(--banner);
    color: #ccc;
    text-align: center;
    padding: 20px;
    margin-top: 40px;
}

/* || Forms & Inputs */
/* || Forms & Inputs */
form {
    padding: 15px;
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    max-width: 800px;
    margin: 0 auto;
}

.input {
    margin-bottom: 0.5em;
}

.input-page {
    max-width: 800px;
    margin: 0 auto;
}

.input-page h1 {
    margin: 0 0 16px;
    color: var(--banner);
}

label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.2em;
    color: var(--banner);
    font-size: 0.95rem;
}

input[type=text],
input[type=password],
textarea,
select {
    width: 100%;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 1rem;
    border: 1px solid #ccc;
    background: #fafafa;
    border-radius: 2px;
    margin: 0;
}

input[type=text]:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--banner);
    background: #fff;
}

button {
    background-color: var(--button);
    color: var(--button-text);
    font-family: inherit;
    font-weight: bold;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 5px;
    border-radius: 2px;
}

button:hover {
    background-color: #0f2d44;
    /* Darker navy */
}

.print-form-page {
    max-width: 980px;
    margin: 0 auto;
}

.print-form-header {
    margin-bottom: var(--spacing-md);
}

.print-form-header h1 {
    margin-bottom: 0;
    color: var(--banner);
}

.print-form-header p {
    margin-top: var(--spacing-xs);
}

.print-form {
    max-width: 980px;
    margin: 0;
}

.print-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-md);
}

.print-form-grid-full {
    grid-column: 1 / -1;
}

.print-form-checkbox {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.print-form-checkbox input[type=checkbox] {
    width: auto;
    align-self: flex-start;
    margin-top: var(--spacing-xs);
}

.print-form-section {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid #e3e0d8;
}

.print-form-section h2 {
    margin-top: 0;
    color: var(--banner);
}

.print-form-repeaters {
    display: grid;
    gap: var(--spacing-sm);
}

.print-form-existing-media {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    background: #faf7f0;
    border: 1px solid #e6dcc7;
}

.print-form-existing-media p {
    margin-top: 0;
}

.print-form-existing-media ul {
    margin-bottom: 0;
}

.print-form-existing-attachments {
    list-style: none;
    padding-left: 0;
}

.print-form-existing-attachments li + li {
    margin-top: var(--spacing-xs);
}

.print-form-retain-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-weight: normal;
    color: var(--text);
}

.print-form-retain-toggle input[type=checkbox] {
    width: auto;
    margin: 0;
}

.print-form-help {
    margin-bottom: 0;
    font-size: 0.95rem;
    color: #5d5a54;
}

.print-form-required {
    color: var(--error);
    margin-left: 2px;
}

.print-form-repeater-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.print-form-chip-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.print-form-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 4px 8px 4px 10px;
    border: 1px solid #d6cfbe;
    border-radius: 999px;
    background: #faf7f0;
}

.print-form-chip-label {
    font-size: 0.95rem;
}

.print-form-chip-remove {
    background: transparent;
    border: none;
    color: var(--error);
    font-size: 1rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}

.print-form-chip-remove:hover {
    color: #8a1a1a;
}

.print-form-repeater-add {
    display: flex;
    gap: var(--spacing-xs);
    align-items: center;
}

.print-form-repeater-draft {
    flex: 1 1 auto;
}

.print-form-repeater-add-button {
    flex: 0 0 auto;
    padding: 6px 12px;
}

.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;
}

.print-form-picture-preview {
    display: block;
    max-width: 240px;
    width: 100%;
    height: auto;
    border: 1px solid #ddd;
    background: #fff;
    padding: var(--spacing-xs);
}

.print-person-picker {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.print-person-picker-input {
    background: #fff;
}

.print-person-picker-menu {
    position: absolute;
    top: calc(100% - 1px);
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    max-height: 220px;
    overflow-y: auto;
    padding: var(--spacing-xs);
    border: 1px solid #ccc;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.print-person-picker-menu[hidden] {
    display: none;
}

.print-person-picker-option {
    width: 100%;
    margin: 0;
    padding: 8px 10px;
    border-radius: 2px;
    text-align: left;
    font-weight: normal;
    background: transparent;
    color: var(--text);
}

.print-person-picker-option:hover,
.print-person-picker-option:focus,
.print-person-picker-option.is-highlighted {
    background: #eef4f8;
    color: var(--banner);
    outline: none;
}

.print-person-picker-note {
    margin: 0;
    font-size: 0.95rem;
    color: #5d5a54;
}

.misc-input-page {
    max-width: 800px;
    margin: 0 auto;
}

.misc-input-header {
    margin-bottom: var(--spacing-md);
}

.misc-input-header h1 {
    margin-bottom: 0;
    color: var(--banner);
}

.misc-input-header p {
    margin-top: var(--spacing-xs);
}

.misc-input-form {
    margin: 0;
}

.misc-input-existing {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    border: 1px solid #ddd;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.misc-input-existing h2 {
    margin-top: 0;
    color: var(--banner);
}

.misc-input-existing ul {
    margin: 0;
    padding-left: 1.2rem;
    columns: 2;
}

.misc-input-existing li {
    break-inside: avoid;
}

.alert-inline {
    margin: 0 auto var(--spacing-md);
    padding: 12px 16px;
    border-radius: 4px;
    border: 1px solid transparent;
    max-width: 800px;
}

.alert-inline--error {
    background: #fbe7e7;
    color: var(--error);
    border-color: #e9b1b1;
}

.alert-inline--success {
    background: #e7f4ea;
    color: #1f5f2a;
    border-color: #b6d9be;
}

/* || Print Input specific */
.print .item {
    margin-bottom: 10px;
}

.print .item-list {
    border: 1px solid #eee;
    padding: 8px;
    background: #fafafa;
}

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

.item-list-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.item-list-controls input {
    flex: 1;
    min-width: 200px;
    margin: 0;
}

.item-list-controls button {
    width: auto;
    margin: 0;
    padding: 8px 15px;
    flex-shrink: 0;
}

.field-hint {
    width: 100%;
    color: #7b5b1f;
    font-size: 0.95rem;
}

.print .list-item {
    width: 100%;
    background: white;
    border: 1px solid #ddd;
    padding: 5px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.print .destroy {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 2px 8px;
    font-size: 0.8rem;
    float: none;
    margin-left: 10px;
}

.print .destroy:hover {
    background: var(--error);
    color: white;
}

/* || List Pages */
.list-page {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list-page-item + .list-page-item {
    margin-top: 10px;
}

.dotted-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e6dfd2;
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.item-left {
    min-width: 0;
    flex: 1;
}

.item-left a,
.list-row-link {
    color: inherit;
    text-decoration: none;
}

.item-right {
    flex-shrink: 0;
    color: var(--banner);
    font-size: 0.95rem;
}

.list-row-link {
    display: block;
}

.list-row-form {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    max-width: none;
    margin: 0;
}

.list-row-button {
    width: 100%;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
}

.dotted-row:hover,
.list-row-link:focus .dotted-row,
.list-row-button:focus .dotted-row,
.list-row-button:hover .dotted-row {
    border-color: var(--highlight);
    box-shadow: 0 4px 8px rgba(20, 59, 88, 0.08);
}

.item-left a:hover,
.list-row-link:hover,
.list-row-button:hover {
    background: transparent;
    color: inherit;
    text-decoration: none;
}


/* || Search Page */
.search fieldset {
    border: none;
    padding: 0;
    display: flex;
    gap: 10px;
}

.search input {
    flex-grow: 1;
}

.search button {
    width: auto;
    margin: 0;
}

/* || Results Grid (Fiche/List) */
.row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.img-frame {
    background: #fff;
    border: 1px solid #eee;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.img-frame:hover {
    border-color: var(--highlight);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.img-frame img {
    max-width: 100%;
    height: auto;
}

/* || Fiche Details */
/* || Fiche Details */
.fiche {
    background: #fff;
    padding: 0;
    /* Remove padding from container, move to children */
    border: 1px solid #eee;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: grid;
    grid-template-columns: 1fr 40%;
    /* Text left, Image right (40%) */
    gap: 0;
    overflow: hidden;
    /* For rounded corners if added */
}

.fiche-image-container {
    /* No background or border - "integrated" look */
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Align to top */
}

.fiche-image-container img {
    max-width: 100%;
    max-height: 80vh;
    /* Constraint requested by user */
    object-fit: contain;
    /* Optional: retain shadow to pop from page, or remove if "flat" desired. Keeping for now. */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.fiche-details {
    padding: 40px;
    border-right: 1px solid #f0f0f0;
    /* Subtle divider from image */
    overflow-y: auto;
    max-height: 90vh;
    /* Allow scrolling details if they are long */
}

.fiche h1 {
    margin-top: 0;
    color: var(--banner);
    border-bottom: 2px solid var(--highlight);
    padding-bottom: 15px;
    margin-bottom: 25px;
    font-size: 2rem;
}

.fiche-description {
    font-style: italic;
    margin-bottom: 30px;
    color: #444;
    border-left: 3px solid var(--highlight);
    padding-left: 15px;
}

/* Definition List Style for Details */
.fiche-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 20px;
    align-items: baseline;
}

.fiche label {
    font-weight: bold;
    color: var(--banner);
    text-align: right;
    min-width: 140px;
}

.fiche label::after {
    content: ":";
}

.fiche p,
.fiche span {
    margin: 0;
    color: var(--text);
}

.fiche ul {
    margin: 0;
    padding-left: 20px;
}


/* || Alerts */
.alert {
    padding: 16px 20px;
    background: #fffaf4;
    color: var(--text);
    margin-bottom: 20px;
    position: fixed;
    top: 84px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 90%;
    max-width: 800px;
    border: 1px solid #e3d8c9;
    border-left: 6px solid var(--error);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(20, 59, 88, 0.12);
    text-align: left;
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.alert-title {
    color: var(--banner);
    font-size: 0.9rem;
    font-weight: bold;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.alert-list {
    margin: 0;
    padding-left: 20px;
}

.alert-list li + li {
    margin-top: 4px;
}

.closebtn {
    background: transparent;
    color: var(--banner);
    border: 1px solid #d7c9b5;
    padding: 4px 10px;
    margin: 0;
    font-size: 0.95rem;
    font-weight: bold;
    line-height: 1.2;
    cursor: pointer;
}

.closebtn:hover {
    background: #f3ece2;
    color: var(--error);
}

/* || Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: var(--banner);
    color: #fff;
    text-align: center;
    padding: 5px 0;
    border-radius: 4px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
}

/* || Mobile Overrides */
/* || Mobile Overrides */
/* || Mobile Overrides */
@media screen and (max-width: 900px) {
    .fiche {
        display: flex;
        flex-direction: column-reverse;
        /* Image on top */
    }

    .fiche-image-container {
        border-right: none;
        border-bottom: 1px solid #eee;
        padding: 20px;
        background: #fafafa;
        /* Add back background on mobile for separation */
    }

    .fiche-image-container img {
        max-height: 50vh;
    }

    .fiche-details {
        padding: 20px;
        max-height: none;
    }

    .fiche-grid {
        grid-template-columns: 1fr;
        /* Stack label and value */
        gap: 5px;
    }

    .fiche label {
        text-align: left;
        margin-top: 10px;
    }

    nav ul {
        flex-direction: column;
        align-items: stretch;
    }

    nav li {
        text-align: center;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .dropdown-content {
        position: static;
        box-shadow: none;
        background: #f0f0f0;
    }

    main {
        padding: 0 10px;
    }

    .misc-input-existing ul {
        columns: 1;
    }

    .print-form-grid {
        grid-template-columns: 1fr;
    }

    .print-form-grid-full {
        grid-column: auto;
    }
}
