:root {
  color-scheme: dark;
  --bg: #0d1016;
  --panel: #171b24;
  --border: #303644;
  --text: #f4f3f5;
  --muted: #b0b7c6;
  --accent: #d8e6ff;
  --ink: #13233c;
  --danger: #ffb7ad;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { isolation: isolate; margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 2px solid #b9d4ff; outline-offset: 4px; }
.wrap { width: min(1136px, calc(100% - 64px)); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.cover {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: clamp(22rem, 54vw, 32rem);
}

.page-background {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  background: #141724;
}

.cover-image, .page-background::after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cover-image { object-fit: cover; object-position: 50% 46%; }
.page-background::after {
  content: "";
  background: linear-gradient(180deg, #080c149e, #080c1447 28%, #090c16bd 62%, #0d1016eb),
    linear-gradient(90deg, #090c16b0, transparent 84%);
}

.masthead, .toolbar, .tag-toolbar, .section-head, .dialog-head, .dialog-actions,
.viewer-top, .viewer-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.masthead { min-height: 80px; border-bottom: 1px solid #e3ebff33; }
.wordmark { display: inline-flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; font-weight: 650; }
.mark { display: grid; grid-template-columns: repeat(2, 6px); gap: 3px; rotate: 45deg; }
.mark i { width: 6px; height: 6px; border-radius: 2px; background: #e9f1ff; }
.mark i:last-child { opacity: .48; }
.cover-title { align-self: center; padding-block: 3rem 5rem; }
.cover-title h1 {
  font: 400 clamp(3.6rem, 9vw, 7.4rem)/.98 Georgia, "Times New Roman", serif;
  letter-spacing: -.065em;
  text-wrap: balance;
  text-shadow: 0 3px 28px #06070bab;
}
.cover-title p { margin-top: 1rem; color: #e5e6ed; font-size: clamp(1rem, 2.6vw, 1.2rem); }
.cover-title .form-status { color: var(--danger); font-size: .9rem; }
main.wrap { position: relative; margin-top: -3rem; padding-bottom: 6rem; }
.tag-panel { padding: 1.35rem 1.55rem; border: 1px solid var(--border); border-radius: 18px; background: #171b25; box-shadow: 0 14px 40px #0004; }
.tag-toolbar { flex-wrap: wrap; }
.tag-toolbar h2 { font-size: 1.1rem; font-weight: 650; }
.tag-categories { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.tag-categories button {
  padding: .35rem .65rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
}
.tag-categories button:hover { color: var(--text); }
.tag-categories button[aria-pressed="true"] { border-color: #3c4557; background: #242b38; color: var(--text); }
.tag-cloud { display: flex; align-items: baseline; flex-wrap: wrap; gap: .55rem; }
.tag-cloud:not(:empty) { margin-top: 1rem; }
.tag-cloud:empty + p:not(:empty) { margin-top: .45rem; }
.tag {
  display: inline-flex;
  align-items: baseline;
  gap: .45em;
  padding: .36em .62em;
  border: 1px solid #374357;
  border-radius: .55rem;
  background: #1e2736;
  color: #d7e7ff;
  overflow-wrap: anywhere;
  text-align: left;
  line-height: 1.15;
}
.tag[data-kind="year"] { border-color: #51465d; background: #2b2538; color: #eadbf9; }
.tag[data-kind="location"] { border-color: #3a514c; background: #20302e; color: #cde9e0; }
.tag:hover { border-color: #92a8ca; }
.tag[aria-pressed="true"] { background: var(--accent); color: var(--ink); border-color: transparent; }
.tag-count { font-size: .775rem; opacity: .82; }
.album { margin-top: clamp(2.3rem, 5vw, 3.5rem); }
.section-head h2 { font: 400 clamp(2rem, 4.3vw, 3rem)/1.1 Georgia, "Times New Roman", serif; letter-spacing: -.033em; overflow-wrap: anywhere; }
.section-head p { margin-top: .4rem; }
.section-head { flex-wrap: wrap; }
.album-actions, .card-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.card-actions { flex-shrink: 0; }
.visibility-notice { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin-top: 1rem; }
.visibility-notice p { color: var(--muted); }
.visibility-notice p[data-error="true"] { color: var(--danger); }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.15rem; margin-top: 1.15rem; }
.photo-grid:empty { margin-top: 0; }
.photo-card { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.photo-open { display: block; padding: 0; width: 100%; border: 0; background: #090b11; }
.photo-open:focus-visible { outline-offset: -4px; }
.photo-open img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: contain; }
.photo-open:hover img { opacity: .88; }
.card-info { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: .5rem; padding: .8rem .9rem; }
.card-copy { min-width: 0; overflow-wrap: anywhere; }
.card-copy h3 { font-size: 1rem; font-weight: 620; }
.card-copy p { margin-top: .12rem; }
.album-state { min-height: 228px; margin-top: 1.15rem; padding: 2rem 1rem; border: 1px dashed #394151; border-radius: 14px; text-align: center; background: #11151d; }
.album-state h3 { font-size: 1.1rem; margin-top: .8rem; }
.album-state p { margin-top: .35rem; }
.album-state button { margin-top: 1rem; }
.empty-frame { display: inline-block; width: 31px; height: 25px; position: relative; overflow: hidden; border: 1px solid #8595b0; border-radius: 5px; }
.empty-frame::before { content: ""; position: absolute; top: 4px; right: 5px; width: 4px; height: 4px; border-radius: 50%; background: #8595b0; }
.empty-frame::after { content: ""; position: absolute; width: 20px; height: 20px; left: 2px; bottom: -13px; rotate: 45deg; border: 1px solid #8595b0; }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: .46rem .78rem;
  border: 1px solid #46526a;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: .875rem;
  font-weight: 620;
}
.button:hover, .icon-button:hover { background: #2b3548; }
.quiet { background: #101723c7; }
.primary { background: var(--accent); border-color: transparent; color: var(--ink); }
.primary:hover { background: #eef4ff; }
.subtle { background: #1b2230; }
.icon-button { min-width: 40px; padding: .2rem; font-size: 1.55rem; line-height: 1; }
.card-info .button { min-height: 32px; padding: .24rem .48rem; }

dialog { max-height: calc(100dvh - 1.5rem); color: var(--text); border: 1px solid #46526a; border-radius: 15px; background: var(--panel); }
dialog::backdrop { background: #05080bd9; }
.panel-dialog { width: min(32rem, calc(100% - 1.4rem)); padding: 1.35rem; }
.upload-dialog { width: min(42rem, calc(100% - 1.4rem)); }
.dialog-head { margin-bottom: 1rem; align-items: start; }
.dialog-head h2 { font-size: 1.35rem; }
.dialog-actions { justify-content: flex-end; margin-top: .8rem; }
label, legend { display: block; margin-bottom: .3rem; font-size: .9rem; font-weight: 620; }
input:not([type="file"]) { display: block; width: 100%; min-height: 42px; padding: .45rem .6rem; border: 1px solid #4d5970; border-radius: 7px; background: #101520; }
fieldset { min-width: 0; margin: 1rem 0 0; padding: 1rem; border: 1px solid #414b60; border-radius: 9px; }
.fields { display: grid; grid-template-columns: .55fr 1.45fr; gap: .75rem; margin-top: 1rem; }
.names { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.name-cell { display: flex; gap: .25rem; }
.name-cell .icon-button { font-size: 1.15rem; min-width: 32px; }
.add-name { margin-top: .55rem; }
.form-status { margin-top: .6rem; color: var(--muted); font-size: .9rem; }
.form-status:empty { display: none; }
.form-status[data-error="true"], .upload-errors { color: var(--danger); }
.drop-area { display: grid; gap: .22rem; padding: 1.4rem .8rem; border: 1px dashed #7a8da9; border-radius: 9px; text-align: center; color: var(--accent); background: #212b3c; cursor: pointer; }
.drop-area span { font-weight: 400; }
.drop-area[data-over="true"], .drop-area:hover { background: #2d3b52; }
#upload-files { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; }
.drop-area:has(+ input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
#upload-progress { margin-top: 1rem; width: 100%; accent-color: #abc7f9; }
.upload-errors { margin-block: .7rem; padding-left: 1.3rem; max-height: 9rem; overflow: auto; overflow-wrap: anywhere; }
.viewer { width: min(1100px, calc(100% - 1.4rem)); padding: .95rem; background: #10141b; }
.viewer-stage { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; gap: .5rem; align-items: center; margin-block: .7rem; }
.viewer-stage img { display: block; justify-self: center; width: auto; max-width: 100%; max-height: min(70dvh, 860px); object-fit: contain; }
.viewer-info { align-items: start; padding-inline: 3rem; overflow-wrap: anywhere; }
.viewer-info h2 { font-size: 1.14rem; }

@media (min-width: 1260px) {
  .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .wrap { width: calc(100% - 32px); }
  .masthead { min-height: 68px; }
  .cover { min-height: 24rem; }
  .cover-title { padding-block: 3rem 5.3rem; }
  .tag-panel { padding: 1.15rem; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .viewer-info { padding-inline: .25rem; }
}
@media (max-width: 390px) {
  .toolbar { gap: .3rem; }
  .toolbar .button { padding-inline: .48rem; }
  .names { grid-template-columns: minmax(0, 1fr); }
}
