:root {
    color-scheme: light;
    --fim-ink: #182126;
    --fim-muted: #5a686c;
    --fim-paper: #ffffff;
    --fim-page: #edf2ef;
    --fim-soft: #f5f8f6;
    --fim-line: #c9d4ce;
    --fim-line-strong: #9eaea6;
    --fim-teal: #0b766d;
    --fim-teal-dark: #075a53;
    --fim-mint: #dff3ec;
    --fim-amber: #d9941f;
    --fim-amber-soft: #fff3d7;
    --fim-coral: #b8493a;
    --fim-coral-soft: #fff0ed;
    --fim-blue: #315f7a;
    --fim-shadow: 0 12px 30px rgba(24, 33, 38, 0.09);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-width: 320px;
    background: var(--fim-page);
}

body {
    margin: 0;
    color: var(--fim-ink);
    background: var(--fim-page);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
    line-height: 1.65;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button,
.fim-drop-zone,
.fim-photo-item,
.fim-mobile-tabs button,
.fim-segmented label,
.fim-layout-picker label {
    -webkit-tap-highlight-color: transparent;
}

button {
    min-height: 42px;
    border: 1px solid var(--fim-teal);
    border-radius: 6px;
    padding: 8px 13px;
    color: #ffffff;
    background: var(--fim-teal);
    font-weight: 700;
    cursor: pointer;
}

button:hover:not(:disabled) {
    border-color: var(--fim-teal-dark);
    background: var(--fim-teal-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.fim-drop-zone:focus-visible,
.fim-photo-item:focus-visible,
.fim-segmented label:has(input:focus-visible),
.fim-layout-picker label:has(input:focus-visible),
#previewCanvas:focus-visible {
    outline: 3px solid rgba(217, 148, 31, 0.46);
    outline-offset: 2px;
}

button:disabled {
    color: #89938f;
    border-color: #cbd3cf;
    background: #e4e9e6;
    cursor: not-allowed;
}

button.secondary {
    color: var(--fim-ink);
    border-color: var(--fim-line-strong);
    background: #ffffff;
}

button.secondary:hover:not(:disabled) {
    color: var(--fim-teal-dark);
    border-color: var(--fim-teal);
    background: #f3fbf8;
}

button.danger {
    color: var(--fim-coral);
    border-color: #d6a49b;
    background: #ffffff;
}

button.danger:hover:not(:disabled) {
    color: #ffffff;
    border-color: var(--fim-coral);
    background: var(--fim-coral);
}

button.compact {
    min-height: 34px;
    padding: 5px 9px;
    font-size: 13px;
}

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

.fim-shell {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.fim-header {
    padding: 0 2px 18px;
}

.fim-breadcrumb {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    color: var(--fim-teal-dark);
    font-weight: 700;
    text-decoration: none;
}

.fim-breadcrumb:hover {
    text-decoration: underline;
}

.fim-kicker {
    margin: 0;
    color: var(--fim-teal-dark);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
}

.fim-header .fim-kicker {
    margin-top: 10px;
}

.fim-header h1 {
    margin: 5px 0 6px;
    font-size: 40px;
    line-height: 1.22;
    letter-spacing: 0;
}

.fim-header h1 span + span::before {
    content: "";
}

.fim-lead {
    max-width: 820px;
    margin: 0;
    color: var(--fim-muted);
    font-size: 17px;
}

.fim-tool {
    overflow: hidden;
    border: 1px solid var(--fim-line-strong);
    border-radius: 8px;
    background: var(--fim-paper);
    box-shadow: var(--fim-shadow);
}

.fim-load-band {
    display: grid;
    grid-template-columns: minmax(390px, 1fr) auto 160px;
    gap: 16px;
    align-items: stretch;
    padding: 14px 16px;
    border-bottom: 1px solid var(--fim-line);
    background: var(--fim-soft);
}

.fim-drop-zone {
    display: flex;
    min-height: 88px;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    border: 2px dashed var(--fim-line-strong);
    border-radius: 7px;
    padding: 11px 16px;
    background: #ffffff;
    cursor: pointer;
}

.fim-drop-zone:hover,
.fim-drop-zone.is-dragging {
    border-color: var(--fim-teal);
    background: #f0faf7;
}

.fim-drop-zone strong {
    color: var(--fim-teal-dark);
    font-size: 16px;
}

.fim-drop-zone span,
.fim-drop-zone small {
    color: var(--fim-muted);
}

.fim-drop-zone small {
    font-size: 12px;
}

.fim-load-actions {
    display: grid;
    min-width: 154px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.fim-load-actions #chooseButton {
    grid-column: 1 / -1;
}

.fim-load-actions button {
    min-height: 0;
    padding-inline: 10px;
    white-space: nowrap;
}

.fim-load-summary {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    border-left: 1px solid var(--fim-line);
    padding-left: 16px;
}

.fim-load-summary span,
.fim-load-summary small {
    color: var(--fim-muted);
    font-size: 12px;
}

.fim-load-summary strong {
    font-size: 21px;
    line-height: 1.3;
}

.fim-load-status {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 9px;
    padding: 8px 16px 4px;
    color: var(--fim-ink);
    background: #ffffff;
    font-size: 14px;
}

.fim-browser-note {
    min-height: 32px;
    margin: 0;
    padding: 1px 16px 9px;
    color: var(--fim-muted);
    border-bottom: 1px solid var(--fim-line);
    background: #ffffff;
    font-size: 13px;
}

.fim-spinner {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border: 2px solid #c8ddd6;
    border-top-color: var(--fim-teal);
    border-radius: 50%;
    animation: fim-spin 0.75s linear infinite;
}

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

.fim-mobile-tabs {
    display: none;
}

.fim-workspace {
    display: grid;
    height: clamp(690px, calc(100vh - 120px), 790px);
    min-height: 690px;
    max-height: 790px;
    grid-template-columns: minmax(235px, 0.72fr) minmax(470px, 1.55fr) minmax(310px, 0.88fr);
}

.fim-panel {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    background: #ffffff;
}

.fim-panel + .fim-panel {
    border-left: 1px solid var(--fim-line);
}

.fim-panel-heading {
    display: flex;
    min-height: 66px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--fim-line);
}

.fim-panel-heading h2 {
    margin: 2px 0 0;
    font-size: 18px;
    line-height: 1.35;
}

.fim-panel-heading > span,
.fim-panel-heading > strong {
    flex: 0 0 auto;
    color: var(--fim-muted);
    font-size: 13px;
}

.fim-panel-help,
.fim-preview-help {
    margin: 0;
    color: var(--fim-muted);
    font-size: 12px;
}

.fim-panel-help {
    padding: 10px 12px;
    border-bottom: 1px solid var(--fim-line);
    background: var(--fim-soft);
}

.fim-photo-list {
    display: grid;
    min-height: 0;
    margin: 0;
    padding: 10px;
    overflow: auto;
    list-style: none;
    gap: 8px;
}

.fim-photo-item {
    display: grid;
    width: 100%;
    min-width: 0;
    min-height: 0;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border: 1px solid var(--fim-line);
    border-radius: 7px;
    padding: 8px;
    color: var(--fim-ink);
    background: #ffffff;
    cursor: pointer;
    text-align: left;
}

.fim-photo-item:hover {
    border-color: var(--fim-line-strong);
    background: var(--fim-soft);
}

.fim-photo-item.is-selected {
    border-color: var(--fim-teal);
    background: #f0faf7;
    box-shadow: inset 4px 0 0 var(--fim-teal);
}

.fim-photo-thumb {
    display: block;
    width: 64px;
    height: 64px;
    border: 1px solid var(--fim-line);
    border-radius: 5px;
    object-fit: cover;
    background: var(--fim-soft);
}

.fim-photo-meta {
    min-width: 0;
}

.fim-photo-position {
    display: block;
    color: var(--fim-teal-dark);
    font-size: 11px;
    font-weight: 800;
}

.fim-photo-name {
    display: block;
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fim-photo-details {
    display: block;
    color: var(--fim-muted);
    font-size: 11px;
    line-height: 1.45;
}

.fim-empty {
    margin: auto 12px;
    padding: 22px 12px;
    color: var(--fim-muted);
    text-align: center;
    font-size: 13px;
}

.fim-preview-panel {
    background: #d8e0dc;
}

.fim-preview-heading {
    background: #ffffff;
}

.fim-preview-stage {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    padding: 15px;
    overflow: hidden;
    background:
        linear-gradient(45deg, #d1d9d5 25%, transparent 25%),
        linear-gradient(-45deg, #d1d9d5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d1d9d5 75%),
        linear-gradient(-45deg, transparent 75%, #d1d9d5 75%),
        #e4e9e6;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}

.fim-selection-outline {
    position: absolute;
    z-index: 2;
    border: 3px solid var(--fim-amber);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.88);
    pointer-events: none;
}

#previewCanvas {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    border: 1px solid #aebbb5;
    background: #f6f4ef;
    box-shadow: 0 8px 24px rgba(24, 33, 38, 0.16);
    cursor: grab;
    touch-action: none;
}

#previewCanvas.is-dragging {
    cursor: grabbing;
}

.fim-preview-empty {
    max-width: 310px;
    margin: 0;
    padding: 18px;
    color: var(--fim-muted);
    border: 1px solid var(--fim-line-strong);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.92);
    text-align: center;
    font-size: 13px;
}

.fim-preview-help {
    min-height: 38px;
    flex: 0 0 auto;
    padding: 8px 12px;
    border-top: 1px solid var(--fim-line);
    background: #ffffff;
    text-align: center;
}

.fim-settings-scroll {
    min-height: 0;
    padding: 0 13px 18px;
    overflow: auto;
}

.fim-control-group {
    min-width: 0;
    margin: 0;
    padding: 14px 0;
    border: 0;
    border-bottom: 1px solid var(--fim-line);
}

.fim-control-group:last-child {
    border-bottom: 0;
}

.fim-control-group legend {
    width: 100%;
    margin: 0 0 9px;
    padding: 0;
    color: var(--fim-ink);
    font-size: 14px;
    font-weight: 800;
}

.fim-control-group:disabled {
    opacity: 0.62;
}

.fim-control-note {
    margin: 7px 0 0;
    color: var(--fim-muted);
    font-size: 12px;
}

.fim-segmented,
.fim-layout-picker {
    display: grid;
    gap: 5px;
}

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

.fim-layout-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.fim-segmented label,
.fim-layout-picker label {
    min-width: 0;
    cursor: pointer;
}

.fim-segmented input,
.fim-layout-picker input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.fim-segmented span,
.fim-layout-picker span {
    display: flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--fim-line-strong);
    border-radius: 5px;
    padding: 5px;
    color: var(--fim-ink);
    background: #ffffff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.fim-segmented input:checked + span,
.fim-layout-picker input:checked + span {
    color: #ffffff;
    border-color: var(--fim-teal);
    background: var(--fim-teal);
}

.fim-selected-name {
    display: block;
    overflow-wrap: anywhere;
    margin-bottom: 10px;
    color: var(--fim-teal-dark);
    font-size: 13px;
}

.fim-range-row {
    display: grid;
    gap: 4px;
    margin-top: 10px;
}

.fim-range-row > span {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--fim-muted);
    font-size: 12px;
    font-weight: 700;
}

.fim-range-row output {
    color: var(--fim-ink);
}

.fim-range-row input[type="range"] {
    width: 100%;
    accent-color: var(--fim-teal);
}

.fim-button-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-top: 12px;
}

.fim-button-grid button {
    min-width: 0;
    padding-inline: 7px;
    font-size: 12px;
    white-space: nowrap;
}

.fim-field {
    display: grid;
    gap: 5px;
}

.fim-field > span,
.fim-label-inputs span {
    color: var(--fim-muted);
    font-size: 12px;
    font-weight: 700;
}

.fim-field input,
.fim-label-inputs input {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    border: 1px solid var(--fim-line-strong);
    border-radius: 5px;
    padding: 7px 9px;
    color: var(--fim-ink);
    background: #ffffff;
}

.fim-label-inputs {
    display: grid;
    gap: 7px;
    margin-top: 9px;
}

.fim-label-inputs label {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr);
    gap: 7px;
    align-items: center;
}

.fim-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 9px;
}

.fim-suggestions button {
    color: var(--fim-teal-dark);
    border-color: #9abfb5;
    background: var(--fim-mint);
}

.fim-color-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.fim-color-row label {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
    color: var(--fim-muted);
    font-size: 12px;
    font-weight: 700;
}

.fim-color-row input[type="color"] {
    width: 42px;
    height: 34px;
    flex: 0 0 auto;
    border: 1px solid var(--fim-line-strong);
    border-radius: 5px;
    padding: 2px;
    background: #ffffff;
}

.fim-save-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 12px;
}

.fim-ad-reserve {
    display: flex;
    min-height: 110px;
    align-items: center;
    justify-content: center;
    margin: 24px 0;
    color: #73817a;
    border-top: 1px solid var(--fim-line);
    border-bottom: 1px solid var(--fim-line);
    background: rgba(255, 255, 255, 0.52);
    font-size: 11px;
    letter-spacing: 0.12em;
}

.fim-info-band {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--fim-line-strong);
    border-bottom: 1px solid var(--fim-line-strong);
    background: #ffffff;
}

.fim-info-band > div {
    min-width: 0;
    padding: 20px;
}

.fim-info-band > div + div {
    border-left: 1px solid var(--fim-line);
}

.fim-info-band h2,
.fim-comments-placeholder h2 {
    margin: 4px 0 8px;
    font-size: 18px;
    line-height: 1.4;
}

.fim-info-band p,
.fim-info-band ol,
.fim-comments-placeholder p {
    margin: 0;
    color: var(--fim-muted);
    font-size: 14px;
}

.fim-info-band ol {
    padding-left: 1.45em;
}

.fim-comments-placeholder {
    padding: 24px 2px;
    border-bottom: 1px solid var(--fim-line);
}

.fim-return-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    padding: 22px 0;
}

.fim-return-links a,
.fim-footer a {
    color: var(--fim-teal-dark);
    font-weight: 700;
}

.fim-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-top: 18px;
    color: var(--fim-muted);
    border-top: 1px solid var(--fim-line-strong);
    font-size: 13px;
}

@media (max-width: 1100px) {
    .fim-shell {
        width: min(960px, calc(100% - 28px));
    }

    .fim-load-band {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .fim-load-summary {
        grid-column: 1 / -1;
        min-height: 50px;
        display: grid;
        grid-template-columns: auto auto 1fr;
        gap: 10px;
        align-items: center;
        border-top: 1px solid var(--fim-line);
        border-left: 0;
        padding: 8px 0 0;
    }

    .fim-mobile-tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        border-bottom: 1px solid var(--fim-line);
        background: var(--fim-soft);
    }

    .fim-mobile-tabs button {
        min-width: 0;
        border: 0;
        border-right: 1px solid var(--fim-line);
        border-radius: 0;
        color: var(--fim-muted);
        background: transparent;
    }

    .fim-mobile-tabs button:last-child {
        border-right: 0;
    }

    .fim-mobile-tabs button[aria-selected="true"] {
        color: var(--fim-teal-dark);
        background: #ffffff;
        box-shadow: inset 0 -3px 0 var(--fim-teal);
    }

    .fim-workspace {
        display: block;
        height: auto;
        min-height: 0;
        max-height: none;
    }

    .fim-panel {
        min-height: 620px;
        border-left: 0 !important;
    }

    body[data-mobile-panel="photos"] .fim-panel:not(.fim-photos-panel),
    body[data-mobile-panel="preview"] .fim-panel:not(.fim-preview-panel),
    body[data-mobile-panel="settings"] .fim-panel:not(.fim-settings-panel) {
        display: none;
    }

    .fim-photo-list,
    .fim-settings-scroll {
        overflow: visible;
    }

    .fim-preview-panel {
        min-height: min(760px, calc(100vh - 70px));
    }

    .fim-settings-panel {
        min-height: 0;
    }

    .fim-settings-scroll {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0 22px;
        padding-bottom: 18px;
    }
}

@media (max-width: 700px) {
    .fim-shell {
        width: min(100% - 20px, 560px);
        padding-top: 12px;
    }

    .fim-header {
        padding-bottom: 14px;
    }

    .fim-header h1 {
        font-size: 28px;
        line-height: 1.3;
    }

    .fim-header h1 span {
        display: block;
    }

    .fim-lead {
        font-size: 15px;
    }

    .fim-load-band {
        display: block;
        padding: 12px;
    }

    .fim-drop-zone {
        min-height: 100px;
        padding: 12px;
    }

    .fim-load-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 8px;
    }

    .fim-load-summary {
        display: grid;
        grid-template-columns: auto auto 1fr;
        margin-top: 9px;
    }

    .fim-load-status {
        min-height: 48px;
        padding-inline: 12px;
    }

    .fim-browser-note {
        padding-inline: 12px;
    }

    .fim-mobile-tabs {
        position: sticky;
        top: 0;
        z-index: 12;
    }

    .fim-mobile-tabs button {
        min-height: 46px;
        padding-inline: 5px;
        font-size: 13px;
        white-space: nowrap;
    }

    .fim-panel {
        min-height: 540px;
    }

    .fim-preview-panel {
        min-height: max(560px, calc(100vh - 58px));
    }

    .fim-preview-stage {
        align-items: flex-start;
        padding: 10px;
    }

    .fim-settings-scroll {
        display: block;
    }

    .fim-photo-item {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .fim-photo-thumb {
        width: 72px;
        height: 72px;
    }

    .fim-info-band {
        display: block;
    }

    .fim-info-band > div + div {
        border-top: 1px solid var(--fim-line);
        border-left: 0;
    }

    .fim-footer {
        display: grid;
    }
}

@media (max-width: 380px) {
    .fim-shell {
        width: calc(100% - 16px);
    }

    .fim-load-actions button,
    .fim-button-grid button,
    .fim-save-buttons button {
        font-size: 12px;
    }

    .fim-load-summary {
        grid-template-columns: 1fr auto;
    }

    .fim-load-summary small {
        grid-column: 1 / -1;
    }

    .fim-layout-picker span {
        min-height: 40px;
        padding-inline: 2px;
        font-size: 11px;
    }

    .fim-color-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 340px) {
    .fim-header h1 {
        font-size: 26px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fim-spinner {
        animation-duration: 1.5s;
    }
}
