:root {
  color-scheme: light;
  --paper: #fbf9f7;
  --card: #ffffff;
  --soft: #f1f8fc;
  --ink: #172b34;
  --muted: #4d6570;
  --line: #cbe6e9;
  --accent: #087698;
  --deep: #172b34;
  --sky: #4bb7df;
  --green: #18795f;
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; }
.skip { position: absolute; inset-inline-start: 1rem; top: -4rem; background: #fff; padding: .7rem; z-index: 10; }
.skip:focus { top: 1rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.masthead { background: var(--paper); border-top: 4px solid var(--sky); border-bottom: 1px solid var(--line); }
.masthead-inner { max-width: 1680px; margin-inline: auto; padding: 1.1rem clamp(1rem, 3vw, 3rem); display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; font-size: .72rem; font-weight: 800; letter-spacing: .16em; line-height: 1.2; text-decoration: none; }
.brand:is(:hover, :focus-visible) { color: var(--accent); }
.brand-mark { font-size: 2rem; color: var(--sky); }
.session-tools { display: flex; align-items: center; gap: .9rem; }
.session-tools form { margin: 0; }
.local-label { display: inline-flex; align-items: center; gap: .6rem; font-size: .75rem; letter-spacing: .08em; color: var(--muted); }
.local-label::before { content: ""; inline-size: 6px; block-size: 6px; border-radius: 50%; background: var(--sky); }
.logout-button { min-height: 40px; padding: .45rem .8rem; border: 1px solid #98bbc5; border-radius: 3px; background: transparent; color: var(--accent); font-size: .75rem; cursor: pointer; }
.logout-button:is(:hover, :focus-visible) { background: var(--accent); border-color: var(--accent); color: #fff; }

.content-width { max-width: 1680px; margin-inline: auto; padding-inline: clamp(1rem, 3vw, 3rem); }
main { overflow: clip; }
.intro { position: relative; background: radial-gradient(ellipse 290px 240px at 7% 125%, #f4f0ec 0 65%, transparent 66%), var(--paper); }
.intro::before { content: ""; position: absolute; inline-size: 92px; block-size: 92px; border-radius: 50%; background: #80d4d4; inset-inline-start: 16%; inset-block-end: -64px; pointer-events: none; }
.intro .content-width { position: relative; display: flex; align-items: center; min-height: 166px; padding-block: 1.5rem; }
.intro-copy { position: relative; z-index: 1; }
h1 { font-size: clamp(2.3rem, 4vw, 3.7rem); letter-spacing: -.06em; line-height: 1.16; margin: 0 0 .35rem; }
.tagline { font-size: clamp(1rem, 1.6vw, 1.25rem); font-weight: 700; line-height: 1.5; color: var(--green); margin: 0; }
.hero-art { position: absolute; inset-block: 0; inset-inline-end: clamp(1rem, 4vw, 4rem); inline-size: min(35vw, 360px); pointer-events: none; }
.hero-art::before { content: ""; position: absolute; inline-size: 300px; block-size: 440px; border-radius: 50%; background: #35a77f; inset-block-start: -105px; inset-inline-end: 0; }
.hero-art::after { content: ""; position: absolute; inline-size: 240px; block-size: 330px; background: #4fbfec; transform: skewX(-38deg); inset-block-end: -250px; inset-inline-end: 115px; }

.catalog-area { position: relative; z-index: 2; background: linear-gradient(to bottom, transparent 420px, #fff 420px); }
.catalog-area::before { content: ""; position: absolute; inset: 0 0 auto; block-size: 420px; background: #fff; pointer-events: none; }
@supports (backdrop-filter: blur(20px)) {
  .catalog-area::before { background: linear-gradient(to bottom, rgb(255 255 255 / 80%), #fff); backdrop-filter: blur(20px); }
}
.catalog-area .content-width { padding-block: clamp(1.5rem, 3vw, 2.5rem) 5rem; }
.catalog-layout { position: relative; display: grid; grid-template-columns: 220px minmax(0, 1fr) 230px; grid-template-areas: "filters results upload"; gap: clamp(1.25rem, 2vw, 2rem); align-items: start; }
body[data-auth-role="viewer"] .editor-only { display: none !important; }
body[data-auth-role="viewer"] .catalog-layout { grid-template-columns: 220px minmax(0, 1120px); grid-template-areas: "filters results"; justify-content: center; }
@media (min-width: 801px) {
  body[data-auth-role="viewer"] .masthead-inner,
  body[data-auth-role="viewer"] .intro .content-width {
    max-width: calc(1340px + clamp(1.25rem, 2vw, 2rem) + clamp(1rem, 3vw, 3rem) + clamp(1rem, 3vw, 3rem));
  }
}
.upload-sidebar { grid-area: upload; }
.filter-sidebar { grid-area: filters; }
.results { grid-area: results; }
.sidebar-heading { display: flex; align-items: center; min-height: 64px; padding-bottom: 1rem; border-bottom: 2px solid var(--ink); font-size: 1.1rem; }
.sidebar, .results { min-width: 0; }
.search-panel { display: block; padding-top: 2rem; }
.search-panel .field + .field { margin-top: .8rem; }
.external-register { padding: 2rem 0 1.5rem; border-bottom: 1px solid var(--line); }
.external-register .filter-title { margin-bottom: 1rem; }
.external-register .field + .field { margin-top: .8rem; }
.image-drop { border: 1px dashed var(--accent); padding: 1rem .5rem; margin-top: .8rem; text-align: center; font-size: .8rem; }
.image-drop.dragging { background: var(--soft); outline: 2px solid var(--accent); }
.image-drop p { margin: 0 0 .6rem; }
.drop-or { display: block; margin-bottom: .6rem; color: var(--muted); font-size: .75rem; }
.choose-files { max-width: 100%; padding: .6rem .8rem; border: 1px solid var(--accent); border-radius: 3px; background: var(--card); color: var(--accent); cursor: pointer; }
.choose-files:not(:disabled):hover { background: var(--accent); color: #fff; }
.choose-files:disabled { opacity: .45; cursor: default; }
#image-upload-progress { width: 100%; margin-top: .7rem; }
.upload-errors { max-height: 10rem; overflow: auto; font-size: .75rem; padding-left: 1rem; overflow-wrap: anywhere; }
.submit:disabled { opacity: .45; cursor: default; }
.form-help, .form-message { font-size: .72rem; line-height: 1.55; color: var(--muted); margin: .7rem 0 0; }
.form-message { min-height: 1.1em; font-weight: 700; }
.form-message.error { color: #a13b35; }
.filter-title { font-size: 1.1rem; letter-spacing: -.02em; margin: 0 0 1.5rem; }
.field { display: grid; gap: .5rem; min-width: 0; }
.field[hidden] { display: none; }
.field label, .filter-group legend { font-size: .84rem; font-weight: 800; }
.field input, .field select { width: 100%; min-height: 45px; background: var(--card); border: 1px solid #98bbc5; border-radius: 3px; padding: .65rem .75rem; color: var(--ink); }
.filter-group { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0 0; padding: 1.2rem 0 0; min-width: 0; }
.filter-group legend { padding: 0 .4rem 0 0; }
.filter-options { display: grid; gap: .1rem; }
.filter-option { display: flex; align-items: center; gap: .65rem; padding: .35rem 0; font-size: .86rem; cursor: pointer; }
.filter-option input { accent-color: var(--accent); inline-size: 1rem; block-size: 1rem; margin: 0; flex: none; }
.filter-option input:checked + span { color: var(--accent); font-weight: 800; }
.submit { display: block; width: 100%; min-height: 46px; margin-top: .65rem; border: 0; background: var(--accent); color: #fff; font-weight: 700; padding: .7rem 1rem; cursor: pointer; }
.submit:hover { filter: brightness(.9); }
.clear-filters { grid-column: 1 / -1; width: 100%; margin-top: .5rem; padding: .6rem; border: 1px solid #98bbc5; background: transparent; color: var(--accent); cursor: pointer; }
.clear-filters:hover { background: var(--soft); }

.results-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; min-block-size: 64px; gap: .75rem; border-bottom: 2px solid var(--ink); padding-bottom: 1rem; }
.results-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: .75rem; }
#results-title { overflow-wrap: anywhere; min-width: 0; }
.results-label { min-width: 0; max-width: 100%; }
.sort-control { display: flex; align-items: center; gap: .5rem; font-size: .75rem; color: var(--muted); }
.sort-control select { min-height: 36px; max-width: 100%; border: 1px solid #98bbc5; border-radius: 3px; padding: .4rem; background: var(--card); color: var(--ink); }
.external-source { overflow-wrap: anywhere; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 0; letter-spacing: -.04em; }
.count { display: flex; align-items: baseline; gap: .35rem; margin: 0; font-size: .8rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.count-number { font-size: 1.3rem; line-height: 1.2; letter-spacing: -.05em; }
.note { font-size: .82rem; color: var(--muted); line-height: 1.7; margin: 1.25rem 0 1.8rem; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }
.card { background: var(--card); border: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; }
.thumb { width: 100%; aspect-ratio: 16 / 9; flex: none; background: var(--soft); display: grid; place-items: center; overflow: hidden; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb > img { position: absolute; inset: 0; }
.thumb .uploaded-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-play { position: absolute; z-index: 1; border: 1px solid #fff; border-radius: 4px; padding: .6rem 1rem; color: #fff; background: #172b34dd; cursor: pointer; }
.video-play[hidden] { display: none; }
a.thumb { text-decoration: none; }
a.thumb:is(:hover, :focus-visible) { box-shadow: inset 0 0 0 3px var(--accent); }
a.thumb:is(:hover, :focus-visible) img { opacity: .8; }
.thumb .symbol { font-size: 3rem; font-weight: 300; color: var(--accent); }
.card-body { padding: 1rem; display: flex; flex-direction: column; gap: .65rem; }
.meta { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.card-selector { inline-size: 1.05rem; block-size: 1.05rem; margin: 0; accent-color: var(--accent); flex: none; }
.badge { font-size: .67rem; font-weight: 800; letter-spacing: .12em; color: var(--green); border: 1px solid #8bcbb6; padding: .25rem .5rem; }
.card h3 { font-size: 1.03rem; line-height: 1.5; height: 1.5em; margin: 0; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.project-name { font-size: .8rem; line-height: 1.5; height: 1.5em; margin: 0; color: var(--accent); font-weight: 700; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.meta-project { flex: 1; min-width: 0; text-align: right; }
.path { font-size: .72rem; line-height: 1.5; height: 1.5em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.action-notice { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 2rem); padding: .75rem 1rem; background: var(--deep); color: #fff; border-radius: 4px; font-size: .85rem; margin: 0; overflow-wrap: anywhere; }
.action-notice:empty { display: none; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-top: auto; padding-top: .5rem; }
.actions .action { text-align: center; white-space: nowrap; padding: .6rem .2rem; }
.actions .action:first-child { grid-column: 1 / -1; padding: .6rem .2rem; background: var(--accent); border: 1px solid var(--accent); color: #fff; }
.actions .action:first-child:disabled { background: #e1e4e5; border-color: #cbd1d3; color: #66747a; opacity: 1; }
.action:disabled { opacity: .45; cursor: default; }
.edit-button { border: 0; background: transparent; color: var(--accent); font-size: 1.2rem; width: 32px; height: 32px; flex: none; cursor: pointer; }
dialog { width: min(480px, calc(100% - 2rem)); border: 1px solid var(--line); padding: 1.5rem; color: var(--ink); }
dialog::backdrop { background: #172b3480; }
#edit-form, #bulk-edit-form { display: grid; gap: 1rem; }
.bulk-field { display: grid; gap: .45rem; }
.bulk-apply { display: flex; align-items: center; gap: .45rem; font-size: .84rem; font-weight: 800; }
.bulk-field > input, .bulk-field > select { width: 100%; min-height: 42px; border: 1px solid #98bbc5; border-radius: 3px; padding: .6rem .7rem; background: var(--card); color: var(--ink); }
.bulk-field > :disabled { opacity: .55; }
.dialog-actions { display: flex; justify-content: end; gap: .75rem; }
.dialog-actions button { padding: .7rem 1rem; cursor: pointer; }
.action { font-size: .77rem; font-weight: 700; text-decoration: none; background: var(--deep); color: #fff; padding: .6rem .75rem; border: 0; cursor: pointer; }
.action.secondary { color: var(--deep); border: 1px solid #98bbc5; background: transparent; }
.actions .action { transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
.actions .action:not(:disabled):is(:hover, :focus-visible) { background: var(--deep); border-color: var(--deep); color: #fff; }
.actions .action:first-child:not(:disabled):is(:hover, :focus-visible) { background: #fff; border-color: var(--accent); color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .actions .action { transition: none; } }
.empty { grid-column: 1 / -1; padding: 3rem; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.pagination { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .65rem; margin-top: 2.5rem; }
.bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .75rem; margin-bottom: 1rem; border: 1px solid #8bcbb6; background: #f5fffb; border-radius: 4px; }
.bulk-help { flex-basis: 100%; margin: 0; font-size: .75rem; color: var(--muted); }
.trash-button { color: #a12d35; border: 1px solid #a12d35; background: white; padding: .6rem; }
.trash-button[hidden] { display: none; }
.thumb.group-thumb { display: flex; flex-direction: column; }
.group-thumb .group-image-open { position: absolute; inset: 0; border: 0; padding: 0; width: 100%; height: 100%; background: transparent; cursor: zoom-in; }
.group-thumb .slide-controls { position: absolute; bottom: .35rem; left: 50%; transform: translateX(-50%); background: #fff; border-radius: 4px; padding: .15rem .3rem; }
.group-thumb .group-video { position: absolute; inset: 0 0 auto; width: 100%; height: calc(100% - 2.8rem); object-fit: contain; background: #000; }
.group-thumb .group-image-open[hidden], .group-thumb .group-video[hidden] { display: none; }
.group-thumb.has-video .slide-controls { gap: .35rem; white-space: nowrap; }
.slide-controls { display: flex; justify-content: center; align-items: center; gap: .75rem; }
.slide-controls button { padding: .3rem .65rem; }
.slide-controls span { white-space: nowrap; font-size: .8rem; }
.image-order { padding: 0; list-style: none; display: grid; gap: .5rem; }
.image-order li { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; border: 1px solid var(--line); padding: .4rem; }
.image-order .image-order-name { flex: 1; min-width: 80px; overflow-wrap: anywhere; font-size: .8rem; }
.image-order img { width: 48px; height: 36px; object-fit: contain; }
.image-order input { width: 100%; min-width: 0; }
.combine-drag-handle { cursor: grab; touch-action: none; user-select: none; min-width: 36px; min-height: 40px; }
.combine-drag-handle:active { cursor: grabbing; }
#combine-order .is-dragging, #edit-group-order .is-dragging { opacity: .5; }
#combine-order .drop-before, #edit-group-order .drop-before { border-top: 3px solid var(--deep); }
#combine-order .drop-after, #edit-group-order .drop-after { border-bottom: 3px solid var(--deep); }
.group-image-open img[hidden], .group-image-open span[hidden] { display: none; }
#image-viewer-slide-title { font-weight: 700; overflow-wrap: anywhere; margin: .5rem 0; }
#image-viewer-external-help { font-size: .85rem; }
#image-viewer { width: min(1000px, 94vw); max-width: 94vw; }
.viewer-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
#image-viewer-image, #image-viewer-video { display: block; width: 100%; height: min(65vh, 750px); object-fit: contain; margin: 1rem 0; }
#image-viewer-image[hidden], #image-viewer-video[hidden] { display: none; }
#image-viewer .slide-controls { flex-wrap: wrap; }
.bulk-actions[hidden] { display: none; }
.selection-toolbar { position: fixed; z-index: 30; bottom: 12px; left: 50%; transform: translateX(-50%); width: min(760px, calc(100% - 24px)); box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .75rem; padding-bottom: max(.75rem, env(safe-area-inset-bottom)); border: 1px solid #8bcbb6; border-radius: 8px; background: #f5fffb; box-shadow: 0 4px 24px #163f4033; }
.selection-toolbar[hidden] { display: none; }
.selection-toolbar .action { width: auto; min-height: 40px; }
.selection-toolbar > span { margin-right: auto; font-weight: 800; }
.selection-toolbar .bulk-help { margin: 0; flex-basis: 100%; }
body.has-selection-toolbar { padding-bottom: 220px; }
body.has-selection-toolbar .action-notice { bottom: 230px; }
.bulk-actions span { margin-right: auto; font-size: .84rem; font-weight: 800; }
.bulk-actions .action { width: auto; min-height: 36px; padding: .45rem .75rem; }
.pagination button { white-space: nowrap; background: var(--card); color: var(--deep); border: 1px solid var(--line); min-height: 43px; padding: .5rem .9rem; cursor: pointer; }
.pagination button:disabled { opacity: .45; cursor: default; }
.page-numbers { display: flex; align-items: center; gap: .35rem; }
.pagination .page-number { min-width: 43px; padding-inline: .6rem; }
.pagination .page-number[aria-current="page"] { opacity: 1; border-color: var(--deep); background: var(--deep); color: #fff; }
.page-jump { display: flex; align-items: center; gap: .4rem; margin-left: .35rem; }
.page-jump label { display: flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 800; }
.page-jump input { width: 4.5rem; min-height: 43px; border: 1px solid #98bbc5; border-radius: 3px; padding: .45rem; color: var(--ink); background: var(--card); }
.page-total { white-space: nowrap; color: var(--muted); font-size: .8rem; }
footer { background: var(--deep); color: #d9edf0; padding: 1.5rem clamp(1rem, 4vw, 4rem); font-size: .78rem; }
footer span { padding: 0 .4rem; }

.login-page { min-height: 100vh; min-height: 100svh; background: var(--paper); }
.login-page::before, .login-page::after { content: ""; position: fixed; pointer-events: none; border-radius: 50%; }
.login-page::before { inline-size: min(52vw, 720px); block-size: min(52vw, 720px); inset-inline-end: max(-18vw, -280px); inset-block-start: max(-22vw, -340px); background: #35a77f; }
.login-page::after { inline-size: min(30vw, 420px); block-size: min(30vw, 420px); inset-inline-start: max(-12vw, -180px); inset-block-end: max(-15vw, -220px); background: #80d4d4; }
.login-shell { position: relative; z-index: 1; display: grid; place-items: center; min-height: 100vh; min-height: 100svh; padding: clamp(1rem, 5vw, 4rem); overflow: hidden; }
.login-panel { width: min(100%, 430px); padding: clamp(1.5rem, 5vw, 3rem); background: rgb(255 255 255 / 94%); border: 1px solid var(--line); border-top: 4px solid var(--sky); box-shadow: 0 24px 70px rgb(23 43 52 / 14%); }
.login-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: clamp(2rem, 7vw, 3.5rem); font-size: .72rem; font-weight: 800; letter-spacing: .16em; line-height: 1.2; }
.login-copy h1 { font-size: clamp(2rem, 8vw, 3rem); }
.login-copy p { margin: 0 0 1.75rem; color: var(--muted); }
.login-form { display: grid; gap: 1rem; }
.login-submit { margin-top: .35rem; min-height: 50px; }
.login-error { margin: 0 0 1rem; padding: .75rem .85rem; border-inline-start: 4px solid #a12d35; background: #fff3f3; color: #81242b; font-size: .88rem; line-height: 1.55; }
.login-retention { margin: 1.25rem 0 0; color: var(--muted); font-size: .75rem; line-height: 1.6; }
.password-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.password-field input { border-start-end-radius: 0; border-end-end-radius: 0; }
.password-visibility { min-width: 64px; min-height: 48px; border: 1px solid #789ca7; border-inline-start: 0; border-radius: 0 3px 3px 0; background: var(--soft); color: var(--accent); font-weight: 700; cursor: pointer; }
.password-visibility:is(:hover, :focus-visible) { background: var(--accent); color: #fff; }

@media (max-width: 1500px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .catalog-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "filters upload" "results results"; }
}
@media (max-width: 800px) {
  .catalog-layout { grid-template-columns: 1fr; grid-template-areas: "filters" "results" "upload"; gap: 2.5rem; }
  body[data-auth-role="viewer"] .catalog-layout { grid-template-columns: 1fr; grid-template-areas: "filters" "results"; }
  .filter-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-panel { padding-top: 1rem; }
  .external-register { padding-top: 1rem; }
}
@media (max-width: 620px) {
  .masthead-inner { padding: 1rem; }
  .intro .content-width { min-height: 0; padding-block: 1.35rem 1.5rem; }
  .hero-art { display: none; }
  #filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
  .filter-title, .search-field, .project-filter-field, .submit { grid-column: 1 / -1; }
  .filter-group { margin-top: 1.3rem; }
  .filter-options { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .results-heading { align-items: start; flex-direction: column; }
  .pagination { gap: .45rem; }
  .pagination button { min-height: 40px; padding: .45rem .65rem; }
  .pagination .page-number { min-width: 40px; }
  .page-jump { flex-basis: 100%; justify-content: center; margin: .35rem 0 0; }
  .page-jump input { min-height: 40px; }
  .local-label { font-size: .68rem; }
  .session-tools { gap: .5rem; }
  .logout-button { padding-inline: .55rem; }
}
