:root {
  color-scheme: light;
  --surface: #fff;
  --paper: #fff;
  --ink: #242424;
  --muted: #767676;
  --line: #e8e8e8;
  --accent: #242424;
  --blue: var(--accent);
  --blue-soft: #f5f5f5;
  --danger: #b23838;
  --danger-fill: #b23838;
  --on-accent: #fff;
  --accent-hover: #444;
  --shadow: 0 16px 64px #00000014;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--surface); color: var(--ink); }
body:has(dialog[open]) { overflow: hidden; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, .dropzone:focus-within {
  outline: 2px solid #777;
  outline-offset: 3px;
}
h1, h2, h3, p, ul { margin: 0; }
h1 { font-size: clamp(1.8rem, 4.6vw, 2.6rem); line-height: 1.23; font-weight: 550; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; font-weight: 550; }
h3 { font-size: 1rem; font-weight: 550; }
.primary, .secondary, .danger, .text-button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .55rem .9rem;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
}
.primary { background: var(--blue); color: var(--on-accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary, .icon-button { background: var(--paper); color: var(--ink); border-color: var(--line); }
.secondary:hover:not(:disabled), .icon-button:hover { background: var(--blue-soft); }
.secondary[aria-pressed="true"] { color: var(--ink); background: var(--blue-soft); border-color: #999; }
.danger { background: var(--danger-fill); color: #fff; }
.text-button { padding-inline: .52rem; color: var(--blue); background: transparent; }
.text-button:hover { background: var(--blue-soft); }
.icon-button { min-width: 42px; padding: 0; font-size: 1.55rem; font-weight: 400; }
.error, .muted, .form-status { font-size: .88rem; line-height: 1.55; }
.error { color: var(--danger); white-space: pre-wrap; overflow-wrap: anywhere; }
.muted, .form-status { color: var(--muted); }

.landing-page { min-height: 100dvh; display: flex; flex-direction: column; }
.site-header {
  width: min(calc(100% - 80px), 1120px); margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  min-height: 96px; padding-block: max(20px, env(safe-area-inset-top));
}
.brand { color: var(--ink); font-size: 15px; font-weight: 550; text-decoration: none; letter-spacing: .01em; white-space: nowrap; }
.manage-button { min-height: 40px; padding: 8px 0 8px 16px; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 400; }
.manage-button:hover:not(:disabled) { background: transparent; color: var(--ink); }
.site-nav { display: flex; align-items: center; gap: 28px; font-size: 13px; }
.site-nav a { color: var(--muted); padding-block: 10px; text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }
.nav-manage { margin-left: 8px; }
.landing {
  flex: 1; display: grid; align-items: center; width: min(calc(100% - 80px), 760px);
  margin-inline: auto; padding: 60px 0 120px;
}
.entry-grid { border-top: 1px solid var(--line); }
.entry-card {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  min-height: 108px; padding: 24px 4px; color: var(--ink); text-decoration: none;
  border-bottom: 1px solid var(--line); transition: color .18s;
}
.entry-title { font-size: 28px; font-weight: 400; letter-spacing: .02em; }
.entry-arrow { color: #999; font-size: 23px; font-weight: 300; transition: transform .18s; }
.entry-card:hover { color: #777; }
.entry-card:hover .entry-arrow { transform: translate(3px, -3px); }
.inner-page { min-height: 100dvh; }
.inner-page main { width: min(calc(100% - 80px), 1120px); margin: 0 auto; padding: 64px 0 96px; }
.page-intro { margin-bottom: 48px; }
.page-intro h1 { font-size: 30px; font-weight: 450; line-height: 1.35; letter-spacing: 0; }
.text-link { color: var(--ink); text-underline-offset: .25em; }
.text-link:hover { color: var(--muted); }
.pricing-status { color: var(--muted); padding-top: 24px; border-top: 1px solid var(--line); font-size: 14px; }
.hint { padding: .7rem .8rem; color: var(--muted); background: var(--blue-soft); border-radius: 5px; font-size: .8rem; line-height: 1.65; }
.empty { padding: 2.5rem 1rem; color: var(--muted); text-align: center; background: var(--paper); border: 1px dashed var(--line); border-radius: 12px; font-size: .93rem; }
.project-list { list-style: none; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.project-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .3rem 1rem; padding: .9rem 1.15rem; }
.project-row + .project-row { border-top: 1px solid var(--line); }
.project-info { flex: 1 1 180px; min-width: 0; }
.project-name { display: block; overflow-wrap: anywhere; font-size: 1rem; line-height: 1.45; }
.project-meta { display: flex; flex-wrap: wrap; gap: .3rem .8rem; margin-top: .35rem; color: var(--muted); font-size: .8rem; }
.row-actions, .form-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

.panel { width: min(640px, calc(100% - 2rem)); max-height: min(88dvh, 850px); padding: 0; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: auto; }
.panel::backdrop { background: #00000066; }
.panel.small { width: min(420px, calc(100% - 2rem)); }
.panel-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: .75rem 1.35rem; position: sticky; top: 0; z-index: 1; background: var(--paper); }
.panel-body, #upload, #portfolio-upload { display: grid; gap: .82rem; align-items: start; justify-items: stretch; }
.panel-body { padding: 1.35rem; }
.panel-body > button, #login button { justify-self: start; }
label { font-weight: 550; font-size: .9rem; }
input:not([type=file]), textarea { width: 100%; min-height: 43px; padding: .6rem .7rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; font-size: 1rem; }
textarea { resize: vertical; }
.dropzone {
  display: grid; gap: .25rem; justify-items: center; position: relative; overflow: hidden;
  padding: .9rem; border: 1px dashed #bdbdbd; border-radius: 10px; color: var(--muted);
  background: var(--surface); text-align: center; cursor: pointer;
}
.dropzone strong { color: var(--ink); overflow-wrap: anywhere; }
.dropzone span { font-size: .8rem; }
.dropzone .drop-icon { color: var(--blue); font-size: 1.4rem; line-height: 1; }
.dropzone:hover, .dropzone.dragging { border-color: var(--blue); background: var(--blue-soft); }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
progress { width: 100%; height: .7rem; accent-color: var(--blue); }
.admin-section { display: grid; gap: .6rem; padding: 1rem 0 .25rem; border-top: 1px solid var(--line); }
.admin-section .project-row { padding: .7rem .8rem; }
.admin-dashboard { gap: .95rem; }
.admin-tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); }
.admin-tab {
  padding: .68rem .75rem; color: var(--muted); background: transparent;
  border: 0; border-bottom: 2px solid transparent; font-size: .86rem; font-weight: 500;
}
.admin-tab:hover { color: var(--ink); }
.admin-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.admin-pane { display: grid; gap: .9rem; }
.admin-pane h3 { margin-bottom: .15rem; }
.admin-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.admin-pane .logout { justify-self: start; margin-top: .2rem; }
.portfolio-admin-list { display: grid; gap: .5rem; padding: 0; list-style: none; }
.portfolio-admin-item { display: flex; align-items: center; gap: .75rem; min-width: 0; padding: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.portfolio-admin-item img { flex: none; width: 64px; height: 64px; object-fit: contain; background: var(--blue-soft); border-radius: 6px; }
.portfolio-admin-info { flex: 1 1 auto; min-width: 0; }
.portfolio-admin-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.portfolio-admin-meta { margin-top: .22rem; color: var(--muted); font-size: .7rem; line-height: 1.5; }
.danger-text { color: var(--danger); }
.hint { margin: 0; }
.toast, .toast:popover-open {
  position: fixed; inset: auto auto calc(5.5rem + env(safe-area-inset-bottom)) 50%;
  transform: translateX(-50%); z-index: 8; margin: 0; width: max-content; max-width: 90vw;
  padding: .65rem 1rem; color: #fff; background: #252d3e; border: 0; border-radius: 5px;
  text-align: center; font-size: .88rem; box-shadow: 0 3px 20px #1113;
}

.inner-page .select-page { max-width: 720px; }
.access-form { display: grid; gap: 12px; margin-top: 0; }
.access-form label { color: var(--muted); font-size: 13px; font-weight: 400; }
.access-row { display: flex; gap: 12px; }
.access-row input { flex: 1; min-width: 0; background: var(--blue-soft); min-height: 48px; }
.access-row .primary { flex: none; padding-inline: 24px; }
.inner-page main.portfolio-page { width: min(calc(100% - 48px), 1760px); }
.portfolio-grid { --portfolio-columns: 3; display: grid; grid-template-columns: repeat(var(--portfolio-columns), minmax(0, 1fr)); gap: 8px; align-items: start; }
.portfolio-column { min-width: 0; }
.portfolio-grid > .empty { grid-column: 1 / -1; }
.work-card {
  position: relative; display: block; width: 100%; margin: 0 0 8px; padding: 0;
  background: var(--blue-soft); border: 0; border-radius: 1px; overflow: hidden; break-inside: avoid;
  cursor: zoom-in; line-height: 0;
}
.work-card img { display: block; width: 100%; height: auto; background: var(--blue-soft); transition: opacity .35s ease; }
.work-card:hover img { opacity: .9; }
.work-index { display: none; }
.work-viewer { width: 100%; height: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; color: #f5efe5; background: #121110; border: 0; }
.work-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.work-viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: max(.7rem, env(safe-area-inset-top)) 1rem .7rem; font-size: .82rem; letter-spacing: .06em; }
.work-viewer .icon-button { color: #f5efe5; background: #24211e; border-color: #46403a; }
.work-stage { position: relative; display: grid; place-items: center; min-height: 0; touch-action: pan-y pinch-zoom; }
.work-stage img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.work-stage img:not([src]) { visibility: hidden; }
.work-loading, .work-error { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: .55rem .8rem; color: #e8e0d5; background: #121110cc; border-radius: 2px; font-size: .8rem; white-space: nowrap; }
.work-error { color: #ffd8d2; }

.gallery { max-width: 1480px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 4rem) calc(7rem + env(safe-area-inset-bottom)); }
.gallery-header { display: grid; gap: .55rem; margin-bottom: 1.5rem; }
#gallery-error { margin-bottom: .85rem; }
.photos { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; padding: 0; list-style: none; }
.photo { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.photo.is-selected { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.photo-open { display: block; width: 100%; padding: 0; background: var(--blue-soft); border: 0; border-radius: 9px 9px 0 0; overflow: hidden; }
.photo-open img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; }
.photo-number { display: block; padding: .56rem .6rem; color: var(--ink); text-align: center; font-size: .85rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.check { position: absolute; top: .42rem; right: .42rem; display: grid; place-content: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: var(--paper); font-weight: 700; font-size: 1rem; }
.check::before { content: ""; position: absolute; inset: 7px; border: 1.5px solid #fff; border-radius: 50%; background: #212937ad; box-shadow: 0 1px 4px #1114; z-index: 0; }
.check[aria-pressed="true"]::before { background: var(--blue); }
.check[aria-pressed="true"]::after { content: "✓"; position: absolute; inset: 0; display: grid; place-content: center; }
.selection-bar { position: fixed; z-index: 2; inset: auto 0 0; padding: .65rem 1rem calc(.65rem + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
.selection-controls { display: flex; justify-content: center; align-items: center; gap: .6rem; max-width: 100%; }
.selection-controls strong { margin-right: clamp(0rem, 4vw, 1.1rem); font-size: .9rem; white-space: nowrap; }
#empty-selection { margin-top: .65rem; }
.viewer { color: #f6f7fb; background: #111319; width: 100%; height: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; }
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer-header { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: max(.7rem, env(safe-area-inset-top)) 1rem .7rem; }
.viewer-header strong { min-width: 0; overflow-wrap: anywhere; }
.viewer-actions { display: flex; gap: .55rem; align-items: center; }
.viewer .secondary, .viewer .icon-button { color: #f6f7fb; background: #242936; border-color: #3b4658; }
.viewer .secondary[aria-pressed="true"] { color: var(--on-accent); background: var(--blue); border-color: #aaa; }
.viewer-stage { position: relative; display: grid; place-items: center; width: 100%; min-height: 0; touch-action: pan-y pinch-zoom; }
.viewer-stage img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
#viewer-error { position: absolute; top: 48%; padding: .6rem; background: #111d; border-radius: 5px; }
.viewer-arrow { position: absolute; top: 50%; transform: translateY(-50%); min-width: 45px; min-height: 52px; padding: 0; color: #fff; background: #151923bd; border: 1px solid #ffffff49; border-radius: 5px; font-size: 2rem; }
.viewer-arrow.previous { left: .7rem; }
.viewer-arrow.next { right: .7rem; }
.viewer-arrow:disabled { visibility: hidden; }
.viewer-position { padding: .65rem 1rem calc(.65rem + env(safe-area-inset-bottom)); text-align: center; color: #bfc7d5; font-size: .85rem; font-variant-numeric: tabular-nums; }

#admin { width: min(760px, calc(100% - 2rem)); }
@media (min-width: 960px) and (orientation: landscape), (min-width: 1200px) {
  .portfolio-grid { --portfolio-columns: 6; }
}
@media (max-width: 1199px) {
  .photos { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 930px) {
  .photos { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .site-header { width: calc(100% - 40px); min-height: 80px; flex-wrap: wrap; gap: 8px 20px; }
  .brand { font-size: 14px; }
  .site-nav { gap: 20px; font-size: 12px; }
  .nav-manage { margin-left: 0; }
  .inner-page .site-header { align-items: flex-start; flex-direction: column; }
  .landing { width: calc(100% - 48px); padding-block: 48px 108px; }
  .entry-card { min-height: 100px; padding-inline: 0; }
  .entry-title { font-size: 24px; }
  .inner-page main { width: calc(100% - 40px); padding: 40px 0 64px; }
  .page-intro { margin-bottom: 32px; }
  .page-intro h1 { font-size: 26px; }
  .inner-page main.portfolio-page { width: calc(100% - 16px); }
  .portfolio-grid { gap: 6px; }
  .work-card { margin-bottom: 6px; }
  .access-row { flex-direction: column; }
  .access-row .primary { min-height: 48px; }
  .photos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .gallery { padding-top: max(1.5rem, env(safe-area-inset-top)); }
  .gallery-header { margin-bottom: 1rem; }
  #admin { width: 100%; max-width: none; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  #admin .panel-header { padding-top: max(.7rem, env(safe-area-inset-top)); }
  #admin .panel-body { padding-bottom: calc(1.35rem + env(safe-area-inset-bottom)); }
  .project-row { padding-inline: .85rem; }
  .viewer-arrow { min-width: 42px; }
  .portfolio-admin-item { gap: .55rem; }
  .portfolio-admin-item img { width: 54px; height: 54px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Center the original transparent watermark in black. */
.site-header.watermark-header {
  position: relative; display: flex; flex-direction: row; justify-content: center;
  align-items: center; min-height: 86px; gap: 0;
}
.logo-button { display: block; width: min(170px, 48vw); padding: 12px 0; border: 0; color: var(--ink); background: transparent; cursor: pointer; }
.watermark { display: block; width: 100%; height: auto; filter: brightness(0); }
.back-button { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink); font-size: 32px; text-decoration: none; font-weight: 300; }
.review-password { display: grid; gap: .8rem; max-width: 440px; margin: 2rem auto; }
#search-results { margin-top: 24px; }
.search-project { color: var(--ink); text-decoration: none; flex: 1; padding: 8px 0; overflow-wrap: anywhere; }
.portfolio-admin-item input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--ink); }
@media (max-width: 640px) {
 .site-header.watermark-header { min-height: 76px; }
 .logo-button { width: min(150px, 46vw); }
}

/* Portfolio is an uninterrupted photo wall with a fixed, softly veiled logo. */
.portfolio-screen { overflow-x: clip; }
.portfolio-screen .site-header.watermark-header {
  position: fixed; z-index: 5; inset: 0 0 auto; width: 100%; margin: 0;
  pointer-events: none;
}
.portfolio-screen .watermark-header::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: -28px;
  transform: translateX(-50%); width: min(460px, 100vw); height: 158px;
  background: radial-gradient(ellipse at center, #fffffff7 0%, #fffffff0 26%, #ffffffad 46%, #ffffff00 72%);
  pointer-events: none;
}
.portfolio-screen .logo-button { pointer-events: auto; }
.portfolio-screen main.portfolio-page { padding: 16px 0 48px; }
.portfolio-screen .portfolio-grid { overflow-anchor: none; }
/* Only a small moving window of each repeating column is rendered. */
.portfolio-screen.portfolio-looping main.portfolio-page { height: 2000000px; padding: 0; }
.portfolio-screen.portfolio-looping .portfolio-grid {
  position: fixed; inset: 0; width: min(calc(100% - 48px), 1760px);
  height: 100dvh; margin-inline: auto; overflow: hidden; pointer-events: none;
}
.portfolio-screen.portfolio-looping .portfolio-column { position: relative; height: 100%; padding: 0; }
.portfolio-screen.portfolio-looping .work-card { position: absolute; top: 0; left: 0; width: 100%; margin: 0; pointer-events: auto; }
@media (max-width: 640px) {
  .portfolio-screen .watermark-header::before { width: 300px; height: 138px; top: -26px; }
  .portfolio-screen.portfolio-looping .portfolio-grid { width: calc(100% - 16px); }
}
html:has(body.portfolio-looping) { scrollbar-width: none; }
html:has(body.portfolio-looping)::-webkit-scrollbar { display: none; }
.portfolio-screen:not(.portfolio-looping) main.portfolio-page { padding-top: 112px; }
