@import url("https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@400;500;700;900&display=swap");

:root {
    --bg: #f6f7f4;
    --panel: #ffffff;
    --ink: #20231f;
    --muted: #697067;
    --line: #dfe4dc;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --danger: #b42318;
    --button: #ff7849;
    --button-hover: #f26435;
    --shadow: 0 12px 30px rgba(31, 41, 35, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Zen Maru Gothic", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic", "Segoe UI", sans-serif;
    line-height: 1.55;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.topbar-inner {
    width: min(1440px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 190px minmax(320px, 560px) 120px;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    padding: 14px clamp(16px, 4vw, 44px);
}

.brand {
    display: flex;
    align-items: center;
    width: 190px;
    min-width: 150px;
    font-weight: 800;
    font-size: 18px;
}

.brand img {
    display: block;
    width: 100%;
    height: auto;
}

.search {
    display: flex;
    min-width: 0;
}

.search-zone {
    display: grid;
    gap: 8px;
    justify-self: center;
    width: min(560px, 100%);
    min-width: 0;
}

.search input,
input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
}

textarea {
    resize: vertical;
}

button,
.download-button {
    border: 0;
    border-radius: 8px;
    padding: 11px 16px;
    background: var(--button);
    color: #fff;
    font-weight: 900;
    font: inherit;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(255, 120, 73, 0.24);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

button:hover,
.download-button:hover {
    background: var(--button-hover);
    box-shadow: 0 10px 22px rgba(255, 120, 73, 0.3);
}

.search button {
    margin-left: 8px;
    white-space: nowrap;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: end;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    min-height: 26px;
}

.quick-tags span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.quick-tags a {
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8faf7;
    color: #44524b;
    font-size: 12px;
}

main {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 28px clamp(16px, 4vw, 44px) 48px;
}

.flash {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.flash.success {
    border-color: #9bd6a3;
    color: #1f6f35;
}

.flash.error {
    border-color: #f2a69b;
    color: var(--danger);
}

.gallery-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 30px;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 86px;
}

.ad-slot {
    margin-bottom: 28px;
}

.ad-banner {
    display: grid;
    gap: 6px;
    min-height: 110px;
    align-content: center;
    padding: 18px;
    border: 1px dashed #94a3a0;
    border-radius: 8px;
    background: #eef7f3;
    color: #17433e;
}

.ad-banner span {
    color: var(--muted);
    font-size: 13px;
}

.sidebar h2 {
    margin: 0 0 12px;
    font-size: 15px;
}

.tag-cloud,
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-cloud a,
.tags a,
.tag-overflow-marker {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: #33413b;
    font-size: 13px;
}

.tag-overflow-marker {
    display: none;
    font-weight: 900;
}

.tag-cloud span {
    color: var(--muted);
    font-size: 12px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.section-head h1,
.detail-panel h1,
.admin-panel h1 {
    margin: 0;
    font-size: clamp(24px, 4vw, 38px);
    line-height: 1.18;
    letter-spacing: 0;
}

.section-head p {
    margin: 7px 0 0;
    color: var(--muted);
}

.clear-link,
.edit-link {
    color: var(--accent-dark);
    font-weight: 700;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 14px;
}

.load-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.load-more-button {
    min-width: 180px;
}

.asset-card {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.asset-card.is-new {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 420ms ease, transform 420ms ease;
}

.asset-card.is-new.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .asset-card.is-new {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

.format-badge {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 2;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(32, 35, 31, 0.78);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.format-badge.inline {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    background: rgba(32, 35, 31, 0.72);
}

.thumb {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(45deg, #e8ece7 25%, transparent 25%),
        linear-gradient(-45deg, #e8ece7 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e8ece7 75%),
        linear-gradient(-45deg, transparent 75%, #e8ece7 75%);
    background-color: #f9faf8;
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.thumb img,
.preview-panel img,
.admin-list img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thumb img {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
    object-position: center;
}

.empty,
.admin-panel,
.preview-panel,
.detail-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.empty {
    padding: 32px;
}

.empty h2 {
    margin: 0 0 8px;
}

.empty p {
    margin: 0;
    color: var(--muted);
}

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 28px;
    align-items: start;
}

.preview-panel {
    --preview-panel-height: clamp(560px, 76vh, 900px);
    display: grid;
    height: var(--preview-panel-height);
    min-height: 0;
    overflow: hidden;
    place-items: center;
    padding: 22px;
    background:
        linear-gradient(45deg, #e8ece7 25%, transparent 25%),
        linear-gradient(-45deg, #e8ece7 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e8ece7 75%),
        linear-gradient(-45deg, transparent 75%, #e8ece7 75%);
    background-color: #f9faf8;
    background-size: 22px 22px;
    background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.preview-panel img {
    width: 100%;
    height: calc(var(--preview-panel-height) - 44px);
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center;
}

.detail-panel {
    padding: 22px;
}

.lead {
    color: var(--muted);
}

.specs {
    display: grid;
    gap: 8px;
    margin: 18px 0;
}

.specs div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.specs dt {
    color: var(--muted);
}

.specs dd {
    margin: 0;
    font-weight: 700;
}

.license {
    margin: 18px 0;
    padding: 12px;
    border-radius: 8px;
    background: #f7faf7;
    color: #33413b;
}

.license h2 {
    margin: 0 0 8px;
    font-size: 16px;
}

.license p {
    margin: 0 0 8px;
}

.license p:last-child {
    margin-bottom: 0;
}

.detail-tags {
    margin: 18px 0;
}

.download-actions {
    display: grid;
    gap: 10px;
}

.download-button {
    display: block;
    width: 100%;
    text-align: center;
}

.download-button.secondary {
    background: #4f9ee2;
    box-shadow: 0 8px 18px rgba(79, 158, 226, 0.22);
}

.download-button.secondary:hover {
    background: #398bd2;
    box-shadow: 0 10px 22px rgba(79, 158, 226, 0.28);
}

.compact {
    margin-top: 22px;
}

.preview {
    margin-top: 14px;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
    gap: 22px;
    align-items: start;
    margin-bottom: 22px;
}

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.admin-tabs a {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #33413b;
    font-weight: 700;
}

.admin-panel {
    padding: 22px;
}

.admin-panel.wide {
    width: min(860px, 100%);
}

.import-status {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 16px 0;
}

.import-status span,
.import-status strong {
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: #33413b;
    font-size: 13px;
}

.import-actions {
    margin: 16px 0 20px;
}

.import-list {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.import-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.import-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.import-meta,
.import-state {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.admin-panel.narrow {
    width: min(460px, 100%);
    margin: 40px auto;
}

.admin-panel form {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

label {
    display: grid;
    gap: 6px;
    color: #33413b;
    font-weight: 700;
}

label span,
.hint {
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

code {
    padding: 2px 5px;
    border-radius: 4px;
    background: #eef1ed;
}

.danger-form button {
    background: var(--danger);
}

.admin-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.admin-list a {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 10px;
    align-items: center;
    min-height: 66px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.admin-list img {
    width: 54px;
    height: 54px;
    border-radius: 6px;
    background: #f0f2ef;
}

footer {
    border-top: 1px solid var(--line);
}

.footer-inner {
    width: min(1440px, 100%);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 22px clamp(16px, 4vw, 44px);
    color: var(--muted);
    font-size: 13px;
}

.footer-nav {
    justify-content: end;
}

.static-page {
    width: min(880px, 100%);
    margin: 0 auto;
    padding: clamp(24px, 5vw, 46px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.static-page .eyebrow {
    margin: 0 0 8px;
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.static-page h1 {
    margin: 0;
    font-size: clamp(28px, 5vw, 44px);
    line-height: 1.16;
}

.static-page h2 {
    margin: 0 0 10px;
    font-size: 20px;
}

.static-page section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.static-page ul {
    margin: 0;
    padding-left: 1.2em;
}

.static-page li + li {
    margin-top: 7px;
}

.notice {
    padding: 12px;
    border: 1px solid #f0c36d;
    border-radius: 8px;
    background: #fff8e5;
    color: #6f4c00;
}

.contact-mail {
    color: var(--accent-dark);
    font-size: 20px;
    font-weight: 900;
}

@media (max-width: 900px) {
    .topbar-inner,
    .gallery-shell,
    .detail-layout,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        position: static;
    }

    nav {
        justify-content: start;
    }

    .sidebar {
        position: static;
    }

    .is-collapsed-mobile .mobile-extra-tag {
        display: none;
    }

    .is-collapsed-mobile .tag-overflow-marker {
        display: inline-flex;
    }
}

@media (max-width: 560px) {
    main {
        padding-inline: 12px;
    }

    .search {
        display: grid;
        gap: 8px;
    }

    .search button {
        margin-left: 0;
    }

    .section-head {
        display: grid;
    }

    .footer-inner {
        display: grid;
    }

    .footer-nav {
        justify-content: start;
    }
}
