:root {
    --header-offset: 96px;
    --bg: #eef4f8;
    --bg-accent: #dce8f2;
    --card: #ffffff;
    --surface: #ffffff;
    --surface-soft: #f5f9fc;
    --surface-soft-2: #f8fbff;
    --text: #1f2a37;
    --muted: #546273;
    --line: #cfdae5;
    --line-strong: #c9d8e4;
    --line-soft: #d7e2ea;
    --line-soft-2: #d9e3eb;
    --strong: #115c8d;
    --button: #115c8d;
    --button-hover: #0b4a71;
    --warn: #a1342f;
    --focus: #2c7db2;
    --status-bg: #eaf4fb;
    --status-text: #1a4e72;
}

[data-theme="dark"] {
    --bg: #202124;
    --bg-accent: #2b2d30;
    --card: #2b2d30;
    --surface: #2b2d30;
    --surface-soft: #333538;
    --surface-soft-2: #3d4042;
    --text: #f2f2f2;
    --muted: #b0b0b0;
    --line: #444;
    --line-strong: #555;
    --line-soft: #4a4a4a;
    --line-soft-2: #505050;
    --strong: #5dade2;
    --button: #2f7fb5;
    --button-hover: #256a99;
    --warn: #ff8c86;
    --focus: #7bb5d4;
    --status-bg: #2b3d4f;
    --status-text: #b8d7e8;
}

html.theme-transition,
html.theme-transition * {
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: linear-gradient(180deg, var(--bg), var(--bg-accent));
}

body {
    margin: 0;
    padding-top: var(--header-offset);
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, var(--bg), var(--bg-accent));
    min-height: 100vh;
    overscroll-behavior-y: none;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--button);
    color: #fff;
    padding: 0.45rem 0.65rem;
    z-index: 50;
    border-radius: 0 0 8px 0;
    text-decoration: none;
}

.skip-link:focus {
    left: 0;
}

h1,
h2,
legend {
    margin: 0;
}

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem 1.4rem;
    background: color-mix(in srgb, var(--card) 92%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(6px);
    transition: transform 0.25s ease;
}

.topbar.is-hidden {
    transform: translateY(calc(-100% - 4px));
}

.brand-group {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
}

.site-switcher {
    position: relative;
    margin-top: 0.15rem;
}

.site-switcher > summary {
    list-style: none;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.site-switcher > summary::-webkit-details-marker {
    display: none;
}

.site-switcher > summary:hover {
    background: var(--surface-soft-2);
}

.site-switcher > summary {
    transition: background 0.11s ease, transform 0.11s ease;
}

.site-switcher[open] > summary {
    transform: translateY(1px);
}

.burger-icon {
    display: inline-grid;
    gap: 0.18rem;
}

.burger-icon span {
    display: block;
    width: 0.9rem;
    height: 2px;
    background: var(--text);
    border-radius: 99px;
}

.site-switcher-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 0.35rem);
    min-width: 140px;
    display: grid;
    gap: 0.2rem;
    padding: 0.35rem;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: var(--card);
    box-shadow: 0 10px 24px rgba(12, 45, 65, 0.16);
    z-index: 110;
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
    transform-origin: top left;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.site-switcher[open] .site-switcher-menu {
    animation: quick-menu-in 0.12s ease-out;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.site-switcher-menu a {
    text-decoration: none;
    color: var(--text);
    background: var(--surface-soft-2);
    border: 1px solid var(--line-soft-2);
    border-radius: 7px;
    padding: 0.35rem 0.45rem;
    font-size: 0.85rem;
}

.site-switcher-menu a:hover {
    background: var(--surface-soft);
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.74rem;
    color: var(--muted);
}

.topbar h1 {
    margin-top: 0.35rem;
    font-size: clamp(1.3rem, 3vw, 2.1rem);
    line-height: 1.15;
    color: var(--text);
}

.top-links {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    align-items: center;
}

.page-content-card {
    max-width: 860px;
    margin: 1rem auto;
}

.top-links a,
.footer-note a {
    color: var(--strong);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.top-links a:hover,
.footer-note a:hover {
    border-bottom-color: var(--strong);
}

.theme-toggle-btn {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--strong);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
    cursor: pointer;
}

.theme-toggle-btn:hover {
    background: var(--surface-soft);
}

.status-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 1rem 0.75rem;
    min-height: 1.4rem;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.3rem 0.55rem;
    background: transparent;
    color: transparent;
    font-size: 0.9rem;
    gap: 0.5rem;
}

.status-message-text {
    flex: 1;
    display: block;
}

.status-message-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: 0;
    transition: all 0.2s;
    line-height: 1;
    font-weight: 300;
}

.status-message-close:hover {
    color: var(--text);
}

.status-message-close:active {
    transform: scale(0.95);
}

.status-message.is-visible {
    background: var(--status-bg);
    color: var(--status-text);
    border-color: color-mix(in srgb, var(--status-text) 35%, transparent);
}

.status-message.is-visible .status-message-close {
    display: flex;
    color: var(--status-text);
}

.status-message.is-visible .status-message-close:hover {
    color: var(--strong);
}

.status-message.error {
    background: #ffecec;
    color: #8d2020;
    border-color: #e3a3a3;
}

.status-message.error .status-message-close {
    display: flex;
    color: #8d2020;
}

.status-message.error .status-message-close:hover {
    color: #6b1a1a;
}

[data-theme="dark"] .status-message.error {
    background: #452024;
    color: #ffc7c7;
    border-color: #8c4a4d;
}

[data-theme="dark"] .status-message.error .status-message-close {
    color: #ffc7c7;
}

[data-theme="dark"] .status-message.error .status-message-close:hover {
    color: #ffe4e4;
}

.layout {
    display: grid;
    grid-template-columns: minmax(320px, 1.4fr) minmax(280px, 1fr);
    gap: 1rem;
    padding: 0 1rem 1rem;
}

.left-column {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(12, 45, 65, 0.06);
    padding: 1rem;
}

.is-hidden {
    display: none;
}

.form-card h2,
.preview-card h2 {
    margin-bottom: 0.45rem;
    color: var(--text);
}

.preview-card {
    position: relative;
}

.hint {
    color: var(--muted);
    margin: 0 0 0.8rem;
    font-size: 0.94rem;
}

.hint.warn {
    color: var(--warn);
    font-weight: 700;
}

.collection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
}

.collection-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 0.55rem;
    flex-wrap: wrap;
}

.sort-label {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    color: var(--muted);
    font-weight: 700;
}

.sort-label select {
    min-width: 220px;
    width: auto;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}

.autosave-hint {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
}

.icon-toggle-btn {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    border-radius: 999px;
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    font-size: 0.82rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .icon-toggle-btn,
[data-theme="dark"] .icon-toggle-btn i {
    color: #ffffff;
}

.icon-toggle-btn:hover {
    background: var(--surface-soft);
}

.icon-toggle-btn i {
    font-size: 0.95rem;
    line-height: 1;
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
}

.editor-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.editor-menu {
    margin-left: auto;
}

.history-modal-card {
    width: min(680px, 96vw);
}

.preset-save-modal-card {
    width: min(520px, 96vw);
}

.preset-save-actions {
    justify-content: flex-end;
    gap: 0.5rem;
}

#presetSaveName {
    margin-top: 0.2rem;
}

.history-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.history-list {
    list-style: none;
    margin: 0.6rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.45rem;
    max-height: 48vh;
    overflow: auto;
}

.history-item {
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    padding: 0.5rem 0.6rem;
    background: var(--surface-soft-2);
    display: grid;
    gap: 0.4rem;
}

.history-item-meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.83rem;
}

.history-item-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.history-item-actions button {
    padding: 0.32rem 0.7rem;
    font-size: 0.8rem;
}

.preset-item {
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    background: var(--surface-soft-2);
    display: grid;
    gap: 0.35rem;
}

.preset-item button {
    width: 100%;
    border-radius: 8px;
    text-align: left;
    border-color: var(--line-strong);
    color: var(--text);
    background: var(--surface);
}

.preset-item button:hover {
    background: var(--surface-soft);
}

.preset-item-meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.mode-segment {
    width: min(360px, 100%);
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    overflow: hidden;
}

.mode-segment-btn {
    border: 0;
    border-radius: 0;
    padding: 0.5rem 0.55rem;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
}

.mode-segment-btn + .mode-segment-btn {
    border-left: 1px solid var(--line-strong);
}

.mode-segment-btn.is-active {
    background: var(--button);
    color: #ffffff;
}

.mode-segment-btn:hover {
    background: var(--surface-soft-2);
}

.mode-segment-btn.is-active:hover {
    background: var(--button-hover);
}

.inline-toggle {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: var(--muted);
    margin-bottom: 0.6rem;
    width: fit-content;
}

.inline-toggle input {
    width: auto;
    margin: 0;
}

.inline-toggle-offset {
    margin-left: 1.2rem;
}

.profile-box {
    margin-bottom: 0.75rem;
}

.empty-state {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.project-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.55rem;
}

.project-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.55rem;
    align-items: start;
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    padding: 0.5rem;
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease, background 0.12s ease;
}

.project-item.active {
    border-color: #80accb;
    box-shadow: 0 0 0 2px rgba(94, 151, 189, 0.15);
}

.project-item.dragging {
    opacity: 0.45;
    transform: scale(0.99);
}

.project-item-left {
    display: grid;
    grid-template-columns: minmax(1.35rem, auto) auto;
    align-items: center;
    gap: 0.32rem;
}

.project-item-controls {
    display: grid;
    gap: 0.08rem;
    align-items: center;
    justify-items: center;
}

.project-order-indicator {
    font-size: 0.96rem;
    font-weight: 800;
    color: var(--muted);
    letter-spacing: 0.02em;
    min-width: 1.35rem;
    text-align: center;
    line-height: 1;
}

.drag-handle {
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    width: 1.5rem;
    min-height: 1.65rem;
    padding: 0;
    cursor: grab;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-bars {
    display: grid;
    gap: 0.2rem;
    width: 0.9rem;
}

.drag-bars span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--strong) 76%, var(--muted));
}

.project-step-btn {
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    width: 1.25rem;
    min-height: 0.82rem;
    font-size: 0.62rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.project-step-btn:hover,
.drag-handle:hover {
    color: var(--strong);
}

.project-step-btn:focus-visible,
.drag-handle:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--strong) 65%, transparent);
    outline-offset: 2px;
    border-radius: 4px;
}

.project-item-main {
    min-width: 0;
}

.project-item-title {
    margin: 0;
    font-size: 0.9rem;
    color: var(--strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-item-meta {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.35;
}

.item-menu {
    position: relative;
}

.item-menu > summary {
    list-style: none;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 0.1rem 0.45rem;
    background: var(--surface-soft);
    cursor: pointer;
    font-weight: 700;
    color: var(--muted);
    transition: background 0.11s ease, color 0.11s ease, transform 0.11s ease;
}

.item-menu > summary::-webkit-details-marker {
    display: none;
}

.item-menu[open] > summary {
    background: var(--surface-soft-2);
    transform: translateY(1px);
}

.item-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    z-index: 2;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 0.3rem;
    display: grid;
    gap: 0.25rem;
    min-width: 138px;
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.item-menu[open] .item-menu-panel {
    animation: quick-menu-in 0.11s ease-out;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.item-menu-panel button {
    width: 100%;
    border-radius: 6px;
    padding: 0.35rem 0.45rem;
    border: 1px solid var(--line-strong);
    background: var(--surface-soft-2);
    color: var(--text);
    text-align: left;
    font-size: 0.82rem;
    white-space: nowrap;
}

.item-menu-panel button:hover {
    background: var(--surface-soft);
}

.delete-action,
.item-menu-panel button.delete-action,
.history-item-actions button.delete-action {
    color: var(--warn) !important;
    border-color: color-mix(in srgb, var(--warn) 38%, var(--line-strong)) !important;
    background: color-mix(in srgb, var(--warn) 8%, var(--surface-soft-2)) !important;
}

.delete-action:hover,
.item-menu-panel button.delete-action:hover,
.history-item-actions button.delete-action:hover {
    background: color-mix(in srgb, var(--warn) 13%, var(--surface-soft)) !important;
}

fieldset {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem;
    margin: 0 0 0.9rem;
}

legend {
    color: var(--text);
    font-weight: 700;
    padding: 0 0.35rem;
}

.grid {
    display: grid;
    gap: 0.7rem;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.one {
    grid-template-columns: minmax(0, 1fr);
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-weight: 600;
    font-size: 0.93rem;
}

.label-title {
    display: inline-flex;
    align-items: baseline;
    gap: 0.2rem;
}

.required-mark {
    color: var(--warn);
    font-weight: 800;
    line-height: 1;
}

label small,
small {
    color: var(--muted);
    font-weight: 500;
}

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

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

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    background: var(--surface-soft-2);
    color: var(--text);
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 2rem;
    background-image:
        linear-gradient(45deg, transparent 50%, color-mix(in srgb, var(--strong) 70%, var(--muted)) 50%),
        linear-gradient(135deg, color-mix(in srgb, var(--strong) 70%, var(--muted)) 50%, transparent 50%),
        linear-gradient(to right, transparent, transparent);
    background-position:
        calc(100% - 16px) calc(50% - 1px),
        calc(100% - 10px) calc(50% - 1px),
        0 0;
    background-size:
        6px 6px,
        6px 6px,
        100% 100%;
    background-repeat: no-repeat;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background-position 0.16s ease;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    border: 0 !important;
    white-space: nowrap !important;
}

.custom-select-trigger {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    padding: 0.55rem 2rem 0.55rem 0.65rem;
    background: var(--surface-soft-2);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    text-align: left;
    position: relative;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.custom-select-trigger::after {
    content: "";
    position: absolute;
    right: 0.72rem;
    top: 50%;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid color-mix(in srgb, var(--strong) 70%, var(--muted));
    border-bottom: 2px solid color-mix(in srgb, var(--strong) 70%, var(--muted));
    transform: translateY(-60%) rotate(45deg);
    transition: transform 0.16s ease;
    pointer-events: none;
}

.custom-select:hover .custom-select-trigger {
    border-color: color-mix(in srgb, var(--strong) 45%, var(--line-strong));
}

.custom-select.is-open .custom-select-trigger,
.custom-select-trigger:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--strong) 18%, transparent);
}

.custom-select.is-open .custom-select-trigger::after {
    transform: translateY(-35%) rotate(-135deg);
}

.custom-select-list {
    list-style: none;
    margin: 0;
    padding: 0.28rem;
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    z-index: 120;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--card);
    box-shadow: 0 14px 24px rgba(12, 45, 65, 0.16);
    max-height: 220px;
    overflow: auto;
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.custom-select.is-open .custom-select-list {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.custom-select-option {
    padding: 0.42rem 0.5rem;
    border-radius: 7px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.88rem;
}

.custom-select-option:hover,
.custom-select-option.is-active {
    background: var(--surface-soft);
}

.custom-select-option.is-selected {
    background: color-mix(in srgb, var(--strong) 14%, var(--surface-soft-2));
    color: color-mix(in srgb, var(--strong) 88%, var(--text));
    font-weight: 700;
}

.custom-select-option.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

select:hover {
    border-color: color-mix(in srgb, var(--strong) 45%, var(--line-strong));
}

select:focus,
select:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--strong) 18%, transparent);
    background-position:
        calc(100% - 16px) calc(50% + 1px),
        calc(100% - 10px) calc(50% + 1px),
        0 0;
}

input.not-inferred {
    border-color: color-mix(in srgb, var(--warn) 60%, var(--line-strong) 40%);
    background: color-mix(in srgb, var(--warn) 8%, var(--surface-soft-2) 92%);
}

input.not-inferred::placeholder {
    color: color-mix(in srgb, var(--warn) 72%, var(--muted) 28%);
}

#undoDelete[aria-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

a:focus,
summary:focus,
.project-item:focus {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.caption-input-group {
    flex: 1;
    min-width: 200px;
}

.caption-input {
    font-size: 0.85rem !important;
    padding: 0.4rem 0.5rem !important;
    background: var(--surface-soft) !important;
}

.evidence-captions-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

#evidenceCaptions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.inline-group {
    margin-top: 0.7rem;
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 0.6rem;
    align-items: center;
}

.display-theme-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.7rem;
    align-items: end;
}

.display-mode-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-weight: 600;
    font-size: 0.93rem;
}

.display-mode-label {
    margin: 0;
}

.theme-compact {
    min-width: 168px;
    max-width: 210px;
}

.theme-compact select {
    width: auto;
    min-width: 168px;
    max-width: 210px;
    justify-self: start;
}

.file-list {
    margin: 0.5rem 0 0;
    padding-left: 1.1rem;
    color: var(--muted);
}

.error-summary {
    min-height: 1.35rem;
    color: var(--warn);
    margin: 0.2rem 0 0.5rem;
    font-weight: 600;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

button {
    border: 1px solid var(--button);
    border-radius: 999px;
    padding: 0.5rem 0.95rem;
    background: var(--surface-soft);
    color: var(--strong);
    cursor: pointer;
    font-weight: 700;
}

button:hover {
    background: var(--surface-soft-2);
}

button.primary {
    background: var(--button);
    color: #ffffff;
}

button.primary:hover {
    background: var(--button-hover);
}

.preview-document {
    --preview-surface: #ffffff;
    --preview-surface-soft-2: #f8fbff;
    --preview-text: #1f2a37;
    --preview-muted: #546273;
    --preview-line: #cfdae5;
    --preview-line-soft: #d7e2ea;
    --preview-line-soft-2: #d9e3eb;
    --preview-strong: #115c8d;
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 0.95rem;
    background: var(--preview-surface);
    color: var(--preview-text);
    max-height: 78vh;
    overflow: auto;
}

.preview-document h3 {
    margin: 0.9rem 0 0.35rem;
    color: var(--preview-strong);
    border-bottom: 1px solid var(--preview-line);
    padding-bottom: 0.2rem;
}

.preview-document h3:first-child {
    margin-top: 0;
}

.preview-document p {
    margin: 0.25rem 0 0.55rem;
    line-height: 1.45;
}

.summary-header h3 {
    margin: 0;
    color: var(--item-strong, var(--preview-strong));
    border: none;
    padding: 0;
}

.summary-header {
    margin-bottom: 0.55rem;
}

.summary-top {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.6rem;
    align-items: start;
}

.profile-corner {
    text-align: right;
    font-size: 0.78rem;
    color: var(--item-muted, var(--preview-muted));
    line-height: 1.3;
    max-width: 220px;
}

.portfolio-header {
    border: 1px solid var(--item-line-soft, var(--preview-line-soft));
    border-left: 3px solid var(--item-strong, var(--preview-strong));
    border-radius: 12px;
    padding: 0.75rem 0.8rem;
    margin-bottom: 0.75rem;
    background: linear-gradient(
        135deg,
        var(--item-surface, var(--preview-surface)) 0%,
        color-mix(
            in srgb,
            var(--item-strong, var(--preview-strong)) 8%,
            var(--item-surface, var(--preview-surface)) 92%
        ) 100%
    );
}

.portfolio-header-name {
    margin: 0;
    color: var(--item-strong, var(--preview-strong));
    font-size: 1.18rem;
    font-weight: 800;
    line-height: 1.2;
}

.portfolio-header-meta {
    margin: 0.3rem 0 0;
    color: var(--item-muted, var(--preview-muted));
    font-size: 0.86rem;
    line-height: 1.35;
}

.project-sheet {
    border: 1px solid var(--item-line-soft, var(--preview-line-soft));
    border-left: 3px solid var(--item-strong, var(--preview-strong));
    border-radius: 12px;
    padding: 0.75rem;
    margin-bottom: 0.8rem;
    background: var(--item-surface, var(--preview-surface));
    box-shadow: inset 4px 0 0 color-mix(in srgb, var(--item-strong, var(--preview-strong)) 30%, transparent);
}

.project-sheet:last-child {
    margin-bottom: 0;
}

.print-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem 0.8rem;
    align-items: start;
}

.print-col {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.summary-section {
    border: 1px solid var(--item-line-soft-2, var(--preview-line-soft-2));
    border-radius: 10px;
    padding: 0.5rem 0.55rem;
    background: color-mix(
        in srgb,
        var(--item-surface, var(--preview-surface)) 94%,
        var(--item-strong, var(--preview-strong)) 6%
    );
}

.summary-section h3 {
    margin: 0 0 0.3rem;
    font-size: 0.95rem;
    border: none;
    padding: 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--item-strong, var(--preview-strong));
}

.summary-section .summary-body {
    margin: 0;
}

.evidence-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.35rem;
    margin-top: 0.1rem;
}

.evidence-image-grid.single-image {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
}

.evidence-image-grid img {
    display: block;
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    border: 1px solid var(--item-line-soft, var(--preview-line-soft));
    border-radius: 8px;
    background: var(--item-surface-soft-2, var(--preview-surface-soft-2));
}

.evidence-figure {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.evidence-image-grid.single-image .evidence-figure {
    width: min(100%, 520px);
}

.evidence-image-grid.single-image img {
    max-height: 240px;
}

.evidence-caption {
    font-size: 0.8rem;
    color: var(--item-muted, var(--preview-muted));
    line-height: 1.3;
    padding: 0.3rem 0.2rem;
    text-align: center;
    word-break: break-word;
}

.preview-meta {
    font-family: "IBM Plex Mono", monospace;
    color: var(--item-muted, var(--preview-muted));
    font-size: 0.85rem;
}

.portfolio-header[data-item-theme="academic"] .portfolio-header-name,
.project-sheet[data-item-theme="academic"] .summary-header h3,
.project-sheet[data-item-theme="academic"] .summary-section h3 {
    font-family: "Georgia", "Times New Roman", serif;
    text-transform: none;
    letter-spacing: 0.01em;
}

.project-sheet[data-item-theme="academic"] {
    box-shadow: inset 6px 0 0 color-mix(in srgb, var(--item-strong, var(--strong)) 45%, transparent);
}

.project-sheet[data-item-theme="tech"],
.project-sheet[data-item-theme="tech"] .summary-section {
    border-radius: 4px;
}

.project-sheet[data-item-theme="tech"] .summary-section h3 {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.88rem;
    letter-spacing: 0.06em;
}

.project-sheet[data-item-theme="tech"] .evidence-image-grid img {
    border-width: 2px;
}

.project-sheet[data-item-theme="minimalist"] {
    box-shadow: none;
    border-radius: 6px;
}

.project-sheet[data-item-theme="minimalist"] .summary-section {
    background: var(--item-surface, var(--surface));
    border-style: solid;
}

.portfolio-header[data-item-theme="artistic"] .portfolio-header-name,
.project-sheet[data-item-theme="artistic"] .summary-header h3,
.project-sheet[data-item-theme="artistic"] .summary-section h3 {
    font-style: italic;
}

.project-sheet[data-item-theme="science"] .summary-section {
    border-style: dashed;
}

.project-sheet[data-item-theme="outdoor"] {
    box-shadow: inset 4px 0 0 color-mix(in srgb, var(--item-strong, var(--strong)) 38%, transparent);
}

.portfolio-header[data-item-theme="academic"],
.project-sheet[data-item-theme="academic"] {
    border-left-style: double;
    border-left-width: 4px;
}

.portfolio-header[data-item-theme="tech"],
.project-sheet[data-item-theme="tech"] {
    border-left-style: solid;
    border-left-width: 4px;
}

.portfolio-header[data-item-theme="artistic"],
.project-sheet[data-item-theme="artistic"] {
    border-left-style: dashed;
    border-left-width: 4px;
}

.portfolio-header[data-item-theme="science"],
.project-sheet[data-item-theme="science"] {
    border-left-style: solid;
    border-top: 2px solid var(--item-strong, var(--strong));
}

.portfolio-header[data-item-theme="outdoor"],
.project-sheet[data-item-theme="outdoor"] {
    border-left-style: dotted;
    border-left-width: 4px;
}

.portfolio-header[data-item-theme="minimalist"],
.project-sheet[data-item-theme="minimalist"] {
    border-left-color: #222;
    border-left-style: solid;
    border-left-width: 3px;
}

.footer-note {
    text-align: center;
    padding: 0.5rem 0 1.3rem;
    color: var(--muted);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 140;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: color-mix(in srgb, var(--bg) 48%, transparent);
    backdrop-filter: blur(2px);
}

.modal-backdrop.is-hidden {
    display: none;
}

.modal-backdrop:not(.is-hidden) {
    animation: modal-backdrop-in 0.2s ease-out;
}

.modal-card {
    width: min(620px, 96vw);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 14px 34px rgba(12, 45, 65, 0.2);
    animation: modal-card-in 0.2s ease-out;
}

.modal-card h2 {
    color: var(--strong);
    margin-bottom: 0.5rem;
}

.modal-card ol {
    margin: 0;
    padding-left: 1.15rem;
    color: var(--text);
    line-height: 1.45;
}

.modal-actions {
    margin-top: 0.85rem;
    display: flex;
    justify-content: flex-end;
}

#historyModal .modal-actions {
    gap: 0.65rem;
}

.confirm-modal-message {
    margin-top: 0.1rem;
    margin-bottom: 0.2rem;
    line-height: 1.45;
}

@keyframes quick-menu-in {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modal-backdrop-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modal-card-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-switcher-menu,
    .item-menu-panel,
    .modal-card,
    .modal-backdrop:not(.is-hidden) {
        animation: none !important;
        transition: none !important;
    }

    select {
        transition: none !important;
        transform: none !important;
        box-shadow: none !important;
    }

    .custom-select-trigger,
    .custom-select-trigger::after,
    .custom-select-list {
        transition: none !important;
    }
}

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

    .preview-document {
        max-height: none;
    }

    .status-message {
        margin: 0 1rem 0.7rem;
    }
}

@media (max-width: 680px) {
    .topbar {
        flex-direction: column;
    }

    .brand-group {
        width: 100%;
    }

    .top-links {
        width: 100%;
    }

    .collection-meta-row {
        align-items: flex-start;
    }

    .sort-label {
        width: 100%;
    }

    .sort-label select {
        min-width: 0;
        width: 100%;
    }

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

    .inline-group {
        grid-template-columns: 1fr;
    }

    .display-theme-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .theme-compact,
    .theme-compact select {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    .inline-toggle-offset {
        margin-left: 0;
    }

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

    .print-col {
        gap: 0.45rem;
    }

    .summary-top {
        grid-template-columns: 1fr;
    }

    .profile-corner {
        text-align: left;
        max-width: none;
    }
}

@media print {
    @page {
        size: A4;
        margin: 8mm;
    }

    * {
        transform: none !important;
        filter: none !important;
        text-shadow: none !important;
        box-shadow: none !important;
        animation: none !important;
        transition: none !important;
    }

    html,
    body,
    p,
    li,
    span,
    a,
    h1,
    h2,
    h3,
    strong,
    em,
    label,
    legend,
    input,
    textarea,
    select,
    button {
        font-family: Arial, Helvetica, sans-serif !important;
        font-variant-ligatures: none !important;
        text-rendering: optimizeLegibility;
    }

    body {
        background: #fff;
        font-size: 10pt;
        line-height: 1.25;
    }

    .topbar,
    .left-column,
    .preview-card > h2,
    #printFitHint,
    .status-message,
    .footer-note {
        display: none;
    }

    .layout {
        display: block;
        padding: 0;
    }

    .preview-card {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .skills-list {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .skills-list li {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.3rem 0.6rem;
        background: var(--pill-bg);
        border: 1px solid var(--pill-border);
        border-radius: 20px;
        font-size: 0.85rem;
        color: var(--pill-text);
    }

    .skill-badge {
        font-size: 0.75rem;
        font-weight: 700;
        background: var(--strong);
        color: var(--surface);
        padding: 0.15rem 0.35rem;
        border-radius: 10px;
        margin-left: 0.2rem;
    }
    .preview-document {
        border: none;
        max-height: none;
        overflow: visible;
        padding: 0;
    }

    .summary-header {
        margin-bottom: 0.35rem;
        break-after: avoid;
    }

    .portfolio-header {
        border: 1px solid var(--item-line-soft, var(--line-soft));
        border-left: 3px solid var(--item-strong, var(--strong));
        border-radius: 6px;
        padding: 0.35rem 0.45rem;
        margin: 0 0 3mm;
        break-after: avoid;
        background: linear-gradient(
            135deg,
            var(--item-surface, var(--surface)) 0%,
            color-mix(
                in srgb,
                var(--item-strong, var(--strong)) 8%,
                var(--item-surface, var(--surface)) 92%
            ) 100%
        );
    }

    .portfolio-header-name {
        font-size: 12pt;
    }

    .portfolio-header-meta {
        font-size: 8.6pt;
    }

    .project-sheet {
        border: 1px solid var(--item-line-soft, var(--line-soft));
        border-left: 3px solid var(--item-strong, var(--strong));
        border-radius: 6px;
        padding: 0.35rem;
        margin: 0 0 4mm;
        break-inside: avoid-page;
        page-break-inside: avoid;
        background: var(--item-surface, var(--surface));
        box-shadow: inset 3px 0 0 color-mix(in srgb, var(--item-strong, var(--strong)) 30%, transparent);
    }

    .preview-document.split-pages .project-sheet {
        margin: 0;
        break-after: page;
        page-break-after: always;
    }

    .preview-document.split-pages .project-sheet:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .summary-header h3 {
        font-size: 14pt;
        line-height: 1.1;
        color: var(--item-strong, var(--strong));
    }

    .profile-corner {
        font-size: 8.1pt;
        max-width: 42mm;
    }

    .preview-meta {
        font-size: 8.6pt;
        margin: 0.15rem 0;
    }

    .print-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.35rem 0.5rem;
        align-items: start;
    }

    .print-col {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }

    .summary-section {
        border: 1px solid var(--item-line-soft-2, var(--line-soft-2));
        border-radius: 6px;
        padding: 0.3rem 0.35rem;
        break-inside: avoid;
        page-break-inside: avoid;
        background: color-mix(
            in srgb,
            var(--item-surface, var(--surface)) 94%,
            var(--item-strong, var(--strong)) 6%
        );
    }

    .summary-section h3 {
        font-size: 9.6pt;
        margin: 0 0 0.15rem;
        color: var(--item-strong, var(--strong));
    }

    .summary-section .summary-body {
        margin: 0;
        font-size: 8.6pt;
        line-height: 1.2;
    }

    .evidence-image-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.2rem;
    }

    .evidence-image-grid.single-image {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
    }

    .evidence-image-grid.single-image .evidence-figure {
        width: min(100%, 72mm);
    }

    .evidence-image-grid img {
        border: 1px solid var(--item-line-soft, var(--line-soft));
        border-radius: 4px;
        max-height: 35mm;
        background: var(--item-surface-soft-2, var(--surface-soft-2));
    }

    .evidence-image-grid.single-image img {
        max-height: 45mm;
    }

    .project-sheet.compact-print .summary-section.optional {
        display: none;
    }

    .portfolio-header[data-item-theme="academic"],
    .project-sheet[data-item-theme="academic"] {
        border-left-style: double;
        border-left-width: 4px;
    }

    .portfolio-header[data-item-theme="tech"],
    .project-sheet[data-item-theme="tech"] {
        border-left-style: solid;
        border-left-width: 4px;
    }

    .portfolio-header[data-item-theme="artistic"],
    .project-sheet[data-item-theme="artistic"] {
        border-left-style: dashed;
        border-left-width: 4px;
    }

    .portfolio-header[data-item-theme="science"],
    .project-sheet[data-item-theme="science"] {
        border-left-style: solid;
        border-top: 2px solid var(--item-strong, var(--strong));
    }

    .portfolio-header[data-item-theme="outdoor"],
    .project-sheet[data-item-theme="outdoor"] {
        border-left-style: dotted;
        border-left-width: 4px;
    }

    .portfolio-header[data-item-theme="minimalist"],
    .project-sheet[data-item-theme="minimalist"] {
        border-left-color: #222;
        border-left-style: solid;
        border-left-width: 3px;
    }
}
