* {
  box-sizing: border-box
}

html {
  color-scheme: dark;
  min-height: 100%;
  background: var(--frame)
}

body {
  margin: 0;
  padding: var(--frame-width, clamp(10px, 1.2vw, 18px));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55
}

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

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent
}

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

a:hover {
  color: var(--accent)
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--button);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s
}

button:hover,
.button:hover {
  background: var(--hover);
  color: var(--text)
}

button:disabled {
  opacity: .4;
  cursor: default
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent)
}

.primary:hover {
  background: var(--accent-hover);
  color: var(--accent-ink)
}

.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted)
}

.danger {
  color: #e49e98
}

input:not([type=checkbox]):not([type=file]),
select,
textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--text)
}

input[type=checkbox] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px
}

textarea {
  resize: vertical
}

label {
  font-size: 13px;
  color: var(--muted)
}

label input,
label select,
label textarea {
  margin-top: 6px
}

label:has(input[type=checkbox]) {
  display: flex;
  align-items: center;
  gap: 8px
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px
}

h1,
h2,
h3,
p {
  margin: 0
}

h1 {
  font-size: clamp(29px, 3vw, 44px);
  font-weight: var(--heading-weight);
  letter-spacing: -.045em;
  line-height: 1.15
}

h2 {
  font-weight: 500;
  letter-spacing: -.02em;
  font-size: 21px
}

h3 {
  font-size: 17px;
  font-weight: 500
}

.surface {
  background: var(--background);
  min-height: calc(100dvh - var(--frame-width, clamp(10px, 1.2vw, 18px)) - var(--frame-width, clamp(10px, 1.2vw, 18px)));
  border-radius: var(--surface-radius, 14px);
  display: flex;
  flex-direction: column
}

.wordmark {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -1.2px;
  display: inline-block
}

.wordmark span {
  color: var(--accent)
}

.wordmark small {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 18px
}

.muted,
.description {
  color: var(--muted)
}

.notice {
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--subtle);
  margin-bottom: 20px
}

.error {
  color: var(--error)
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-top: auto;
  padding: 36px 3.5vw 24px;
  color: var(--muted);
  font-size: 12px
}

footer .wordmark {
  font-size: 19px
}

footer nav {
  display: flex;
  gap: 24px
}

.entry {
  width: min(100% - 48px, 370px);
  margin: clamp(70px, 17vh, 170px) auto 100px
}

.entry .wordmark {
  margin-bottom: 36px
}

.entry h1 {
  font-size: 30px;
  margin-bottom: 32px
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px
}

.stack button {
  align-self: flex-start
}

.entry button {
  width: 100%;
  margin-top: 12px
}

.entry label {
  margin-bottom: -7px
}

.prose {
  max-width: 760px;
  padding: 65px 24px;
  margin: 0 auto 70px
}

.prose h1 {
  margin: 35px 0
}

.prose h2 {
  margin: 28px 0 12px
}

.prose p {
  color: var(--muted)
}

.gallery-shell {
  padding: 36px 3.5vw 50px
}

.gallery-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 35px
}

.gallery-header .wordmark {
  font-size: 20px;
  margin-bottom: 35px
}

.gallery-header h1 {
  max-width: 900px
}

.description {
  margin-top: 15px;
  max-width: 650px
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap
}

.album-heading {
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 17px 0 24px
}

.breadcrumbs {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted)
}

.breadcrumbs [aria-current=page] {
  color: var(--text)
}

.breadcrumbs>span {
  opacity: .6
}

.album-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px;
  margin-bottom: 35px
}

.album-card {
  flex: 0 1 260px;
  width: 260px;
  max-width: 100%;
  min-width: 0
}

.album-card img {
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: var(--subtle);
  display: block;
  border-radius: var(--radius)
}

.album-card>span {
  display: flex;
  justify-content: space-between;
  padding: 12px 1px;
  font-size: 15px
}

.album-card>span>span {
  color: var(--muted)
}

.album-placeholder {
  height: 180px;
  display: grid;
  place-items: center;
  font-size: 55px;
  background: var(--subtle);
  color: var(--muted);
  border: 1px solid var(--border)
}

.media-grid {
  columns: 4;
  column-gap: 14px
}

.media-item {
  position: relative;
  break-inside: avoid;
  display: block;
  margin-bottom: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--subtle)
}

.media-item img,
.media-item video {
  display: block;
  width: 100%;
  height: auto
}

.image-link {
  display: block
}

.item-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s
}

.media-item:hover .item-actions,
.media-item:focus-within .item-actions,
.media-item.file .item-actions {
  opacity: 1
}

.item-actions button,
.item-actions a {
  border: 0;
  border-radius: 3px;
  display: grid;
  place-items: center;
  background: #171b19bf;
  color: white;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 19px
}

.media-item.video .item-actions {
  bottom: auto;
  top: 8px
}

.file-content {
  min-height: 205px;
  padding: 30px 25px 55px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 9px;
  border: 1px solid var(--border);
  overflow-wrap: anywhere
}

.file-content strong {
  font-weight: 500;
  font-size: 14px;
  max-width: 100%
}

.file-content>span:last-child {
  font-size: 12px;
  color: var(--muted)
}

.file-icon {
  color: var(--muted);
  font-size: 36px
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 65px 20px
}

.selection-check {
  position: absolute;
  z-index: 2;
  top: 9px;
  left: 9px;
  background: #171b19c9;
  padding: 6px;
  border-radius: 3px
}

.selection-check input {
  display: block;
  margin: 0
}

.media-item:has(input:checked) {
  outline: 3px solid var(--accent);
  outline-offset: -3px
}

.selecting .media-item::after {
  content: "";
  position: absolute;
  inset: 0;
  cursor: pointer
}

.selecting .selection-check {
  z-index: 3
}

.selecting .item-actions {
  display: none
}

.selection-bar {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  box-shadow: 0 5px 20px #0002
}

.selection-bar>span {
  margin-right: auto;
  font-size: 13px
}

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

dialog {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 25px;
  width: min(480px, calc(100vw - 30px));
  max-height: 85dvh
}

dialog::backdrop {
  background: #000b;
  backdrop-filter: blur(3px)
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  gap: 20px
}

.dialog-heading button {
  padding: 3px 12px;
  font-size: 23px
}

.drop-zone {
  margin-top: 20px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px 12px;
  gap: 12px;
  font-size: 30px;
  cursor: pointer
}

.drop-zone span {
  font-size: 13px
}

.drop-zone input {
  max-width: 100%;
  font-size: 12px
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--subtle)
}

progress {
  accent-color: var(--accent);
  width: 100%;
  margin-top: 20px
}

#upload-status {
  font-size: 13px;
  margin-top: 12px
}

dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px 22px;
  font-size: 13px
}

dt {
  color: var(--muted)
}

dd {
  margin: 0;
  overflow-wrap: anywhere
}

/* Custom viewer controls use PhotoSwipe's native button and SVG sizing. */
.pswp__top-bar .pswp__button {
  padding: 0;
  border: 0;
  border-radius: 0;
  flex: 0 0 50px;
}

.pswp__button--folio-download,
.pswp__button--folio-info {
  color: #fff;
}

.pswp__button--folio-download:focus-visible,
.pswp__button--folio-info:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -5px;
}

.pswp__folio-panel {
  position: absolute;
  z-index: 20;
  top: 68px;
  right: 18px;
  width: min(350px, calc(100% - 36px));
  max-height: calc(100dvh - 100px);
  overflow: auto;
  padding: 30px 24px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px #0002;
}

.pswp__folio-panel dl {
  grid-template-columns: 1fr;
  gap: 4px;
}

.pswp__folio-panel dd {
  margin-bottom: 14px;
}

.viewer-info-close {
  position: absolute;
  top: 4px;
  right: 6px;
  padding: 0;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 0;
  font-size: 23px;
}

.admin-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 3.5vw;
  border-bottom: 1px solid var(--border)
}

.admin-main {
  width: min(1280px, 100%);
  padding: 45px 3.5vw 70px;
  margin: 0 auto
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin: 16px 0 30px
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .17em;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 10px
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 35px
}

.metrics>div {
  padding: 22px;
  border-right: 1px solid var(--border)
}

.metrics>div:last-child {
  border-right: 0
}

.metrics strong {
  font-size: 32px;
  font-weight: 400;
  display: block
}

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

.gallery-list {
  margin-bottom: 35px
}

.library-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px 3px;
  border-bottom: 1px solid var(--border)
}

.library-row h2 {
  font-size: 18px
}

.library-row p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px
}

.library-row>div:last-child {
  display: flex;
  align-items: center;
  gap: 18px
}

.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 30px;
  color: var(--muted)
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 25px;
  margin: 22px 0
}

.panel h2 {
  margin-bottom: 20px
}

.panel summary {
  cursor: pointer;
  font-size: 16px;
  font-weight: 500
}

.panel[open] summary {
  margin-bottom: 20px
}

.panel>p {
  font-size: 13px;
  margin: 15px 0
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px
}

.form-grid>label {
  display: block
}

.form-grid .wide {
  grid-column: 1/-1
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px
}

.section-nav {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding: 10px 0 20px;
  margin-bottom: 30px;
  font-size: 13px;
  color: var(--muted)
}

section[id] {
  scroll-margin-top: 30px
}

.share-line {
  display: flex;
  gap: 10px;
  margin-bottom: 25px
}

.share-line input {
  min-width: 0
}

.code-editor {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  tab-size: 4
}

.danger-form {
  margin-top: 15px
}

.table-wrap {
  overflow: auto
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  text-align: left
}

th {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap
}

th,
td {
  padding: 12px 14px 12px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top
}

td a {
  text-decoration: underline;
  text-underline-offset: 3px
}

td {
  overflow-wrap: anywhere;
  max-width: 400px
}

.error-list {
  font-size: 13px;
  color: var(--error);
  padding-left: 20px
}

.activity-chart {
  height: 140px;
  display: flex;
  align-items: end;
  gap: 6px;
  overflow: hidden;
  margin-bottom: 30px
}

.activity-chart>div {
  height: 100%;
  min-width: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center
}

.activity-chart span {
  display: block;
  min-height: 4px;
  width: 100%;
  background: var(--accent);
  opacity: .7
}

.activity-chart small {
  font-size: 8px;
  color: var(--muted);
  margin-top: 5px
}

[hidden] {
  display: none !important
}

@media(min-width:1700px) {
  .media-grid {
    columns: 5
  }
}

@media(max-width:1100px) {
  .media-grid {
    columns: 3
  }

  .gallery-header {
    align-items: start;
    flex-direction: column
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr)
  }

  .metrics>div {
    border-bottom: 1px solid var(--border)
  }
}

@media(max-width:720px) {
  body {
    padding: var(--frame-width, clamp(10px, 1.2vw, 18px))
  }

  .surface {
    min-height: calc(100dvh - var(--frame-width, clamp(10px, 1.2vw, 18px)) - var(--frame-width, clamp(10px, 1.2vw, 18px)))
  }

  .gallery-shell {
    padding: 24px 18px 35px
  }

  .gallery-header {
    padding-bottom: 25px;
    gap: 22px
  }

  .gallery-header .wordmark {
    margin-bottom: 27px
  }

  .toolbar button {
    padding: 8px 11px;
    font-size: 12px
  }

  .media-grid {
    columns: 2;
    column-gap: 9px
  }

  .media-item {
    margin-bottom: 9px
  }

  .item-actions {
    opacity: 1
  }

  .album-grid {
    gap: 14px
  }

  .album-card {
    flex-basis: calc((100% - 14px) / 2);
  }

  .album-card img,
  .album-placeholder {
    height: 135px
  }

  .album-card>span {
    font-size: 13px
  }

  .album-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr)
  }

  .metrics>div {
    padding: 15px
  }

  .admin-main {
    padding: 25px 18px
  }

  .admin-nav {
    padding: 18px
  }

  .wordmark small {
    display: none
  }

  .page-heading {
    align-items: start;
    flex-direction: column
  }

  .form-grid {
    grid-template-columns: 1fr
  }

  .panel {
    padding: 18px
  }

  .share-line {
    flex-wrap: wrap
  }

  .library-row>div:last-child {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: end
  }

  .library-row .muted {
    display: none
  }

  .section-nav {
    gap: 16px
  }

  .selection-bar {
    padding: 9px;
    gap: 8px;
    flex-wrap: wrap
  }

  .selection-bar button {
    font-size: 11px;
    padding: 7px
  }

  .file-content {
    padding: 20px 15px 50px;
    min-height: 160px
  }

  footer {
    padding: 30px 20px 20px
  }

  dl {
    grid-template-columns: 1fr;
    gap: 4px
  }

  dd {
    margin-bottom: 12px
  }

}

@media(prefers-reduced-motion:reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important
  }
}

.library-title {
  display: flex;
  align-items: center;
  gap: 18px
}

.library-title img {
  width: 80px;
  height: 60px;
  object-fit: contain;
  background: var(--subtle);
  border-radius: var(--radius)
}

/* Use the same box metrics for native text, date, and dropdown controls. */
input:not([type=checkbox]):not([type=file]):not([type=hidden]),
select {
  height: 44px;
  font-size: 14px;
  line-height: 1.5;
  min-width: 0;
}

textarea {
  font-size: 14px;
  line-height: 1.5;
}

select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23939b91' stroke-width='1.5'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
}

.expiration-notice {
  color: var(--muted);
  font-size: 12px;
  margin-top: 12px;
}

.unsaved-indicator {
  display: inline-block;
  color: var(--accent);
  font-size: 12px;
  margin: 8px 12px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

#unsaved-dialog p {
  color: var(--muted);
  margin-top: 15px;
}

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

.admin-media-grid figure {
  margin: 0;
  min-width: 0;
  background: var(--subtle);
  border-radius: var(--radius);
}

.admin-media-grid img {
  width: 100%;
  height: 150px;
  object-fit: contain;
}

.admin-media-grid .file-icon {
  display: block;
  text-align: center;
  padding: 26px;
}

.admin-media-grid figcaption {
  padding: 10px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.admin-media-grid small {
  display: block;
  color: var(--muted);
}

#content h3 {
  margin-top: 26px;
}

#upload-status a {
  text-decoration: underline;
}

.activity-metrics {
  grid-template-columns: repeat(3, 1fr);
}

.activity-metrics>div {
  border-bottom: 1px solid var(--border);
}

@media(max-width:720px) {

  input:not([type=checkbox]):not([type=file]):not([type=hidden]),
  select,
  textarea {
    font-size: 16px;
  }

  .activity-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

.admin-tabs [aria-current=page],
.album-tree [aria-current=page] {
  color: var(--text);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

.file-manager {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
  gap: 24px;
  margin-top: 24px;
}

.album-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.album-tree a {
  padding: 8px;
  overflow-wrap: anywhere;
}

.child-albums {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.upload-actions,
.file-delete,
.build-actions {
  margin: 12px 0;
}

.upload-actions summary,
.file-delete summary,
.build-actions summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}

.file-delete {
  padding: 0 10px 10px;
}

.file-delete label {
  font-size: 12px;
}

.file-delete button {
  margin-top: 10px;
  white-space: normal;
}

select[multiple] {
  height: auto;
  background-image: none;
  padding: 10px;
}

[data-generate] {
  margin-top: 8px;
}

#file-selection {
  font-size: 13px;
}

@media(max-width:720px) {
  .file-manager {
    grid-template-columns: minmax(0, 1fr);
  }

  .album-tree {
    max-height: 180px;
    overflow: auto;
    border-bottom: 1px solid var(--border);
  }
}

.file-toolbar,
.file-selection-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.file-selection-toolbar {
  padding: 10px 0;
  border-block: 1px solid var(--border);
  font-size: 13px;
}

.file-selection-toolbar #delete-selected-files {
  margin-left: auto;
}

.admin-media-grid figure {
  position: relative;
}

.file-selection-check {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: var(--radius);
}

.file-selection-check input {
  margin: 0;
}

.admin-media-grid figure:has(input:checked) {
  outline: 2px solid var(--accent);
}

.album-permissions {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.album-permissions legend {
  padding: 0 6px;
  font-size: 14px;
}

.album-permissions p {
  font-size: 12px;
  margin-bottom: 10px;
}

.permission-options {
  max-height: 250px;
  overflow: auto;
}

.permission-options label {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 7px 8px 7px calc(8px + var(--album-depth, 0) * 12px);
  border-radius: var(--radius);
}

.permission-options label:has(input:checked) {
  background: var(--subtle);
  color: var(--text);
}

.permission-options label:has(input:disabled) {
  opacity: .5;
}

.permission-options input {
  margin: 0;
  flex: 0 0 18px;
}
