:root {
  --ink: #173044;
  --ink-soft: #5c6c78;
  --navy: #123c69;
  --navy-deep: #092743;
  --sky: #2f8ab8;
  --sun: #f6bd3c;
  --coral: #df6847;
  --mint: #79b8a4;
  --paper: #fffdf8;
  --cloud: #f3f6f3;
  --line: #dce4e4;
  --white: #fff;
  --shadow: 0 18px 45px rgba(20, 48, 68, .12);
  --max: 1180px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif; line-height: 1.65; letter-spacing: 0; }
button, input, select { font: inherit; }
button:disabled { opacity: .55; cursor: wait; }
a:focus-visible, button:focus-visible, .file-picker:focus-within { outline: 3px solid var(--sky); outline-offset: 4px; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.12; }
h2 { margin-bottom: 0; font-size: 3rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: .7rem 1rem; color: var(--navy); background: var(--white); border-radius: 4px; }
.skip-link:focus { top: 1rem; }
.site-header, .admin-header { height: 76px; padding: 0 max(24px, calc((100vw - var(--max)) / 2)); display: flex; align-items: center; justify-content: space-between; }
.site-header { position: sticky; top: 0; z-index: 10; gap: 16px; padding-inline: max(24px, calc((100% - var(--max)) / 2 + 24px)); color: var(--ink); background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; font-size: .96rem; font-weight: 800; }
.brand-title { margin: 0; font: inherit; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; display: inline-grid; place-items: center; color: var(--navy-deep); background: var(--sun); border-radius: 50%; font-size: 1rem; }
.primary-action { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; padding: .72rem 1.25rem; color: var(--navy-deep); background: var(--sun); border: 0; border-radius: 4px; text-decoration: none; font-weight: 800; cursor: pointer; box-shadow: 0 8px 20px rgba(246,189,60,.18); }
.primary-action:hover { background: #ffd064; transform: translateY(-1px); }

.works-section { max-width: var(--max); min-height: calc(100svh - 160px); margin: 0 auto; padding: 24px 24px 48px; scroll-margin-top: 100px; }
.filter-bar { display: flex; flex-shrink: 0; gap: .4rem; }
.filter-button { min-height: 44px; padding: .5rem 1rem; flex: 0 0 auto; border: 0; border-radius: 24px; background: transparent; color: var(--ink-soft); cursor: pointer; font-weight: 700; font-size: .9rem; }
.filter-button:hover { color: var(--ink); background: #eaf0ef; }
.filter-button.active { color: var(--navy); background: #e5edf2; }
.travel-section { margin-bottom: 28px; }
.travel-heading, .travel-heading-copy { display: flex; align-items: center; gap: 14px; }
.travel-heading { justify-content: space-between; margin: 4px 0 16px; }
.travel-heading h2 { font-size: 1.3rem; }
.travel-heading-copy > span { color: var(--ink-soft); font-size: .8rem; }
.map-fit, .gallery-button { min-height: 40px; padding: .4rem .8rem; background: var(--white); border: 1px solid var(--line); border-radius: 8px; color: var(--navy); font-size: .8rem; font-weight: 700; cursor: pointer; }
.map-fit:disabled, .gallery-button:disabled { cursor: default; }
.map-fit:hover:enabled, .gallery-button:hover:enabled { background: #eaf0ef; }
.travel-map { position: relative; z-index: 0; height: clamp(340px, 48vw, 520px); isolation: isolate; border: 1px solid var(--line); border-radius: 16px; background: #dce9ed; font-family: inherit; }
.travel-map .leaflet-control-attribution { font-size: 10px; }
.travel-map .leaflet-control-zoom { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; }
.travel-map .leaflet-control-zoom a { color: var(--navy); }
.travel-map .photo-pin { border: 0; background: none; }
.photo-pin-button { position: relative; display: flex; align-items: center; flex-direction: column; width: 88px; min-height: 92px; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; }
.photo-pin-frame { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); place-items: center; width: 72px; height: 62px; padding: 4px; border-radius: 9px; color: var(--ink-soft); background: var(--white); box-shadow: 0 3px 12px #17304440; transition: transform .15s; }
.photo-pin-frame::after { content: ""; position: absolute; bottom: -7px; left: 28px; width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 8px solid var(--white); }
/* Override Leaflet's marker image reset, which is loaded after this stylesheet. */
.travel-map .photo-pin .photo-pin-frame img { width: 100%; height: 100%; min-width: 0; min-height: 0; border-radius: 5px; object-fit: cover; }
.photo-pin-city { max-width: 130px; margin-top: 12px; padding: 2px 7px; border-radius: 5px; background: #fffdf8f2; color: var(--ink); box-shadow: 0 1px 5px #17304420; font-size: 12px; line-height: 1.5; font-weight: 700; white-space: nowrap; }
.photo-pin-count { position: absolute; right: 0; top: -7px; display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; border: 2px solid var(--white); border-radius: 14px; color: var(--white); background: var(--coral); font-size: 11px; font-weight: 800; }
.photo-pin-button:hover .photo-pin-frame { transform: translateY(-3px); }
.photo-pin-button:focus-visible { outline-offset: 5px; border-radius: 9px; }
.map-status { margin: 10px 0 0; color: var(--ink-soft); font-size: .8rem; }
.map-status:empty { display: none; }
.work-grid { min-height: 220px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; align-items: start; }
.work-grid.masonry { grid-auto-rows: 1px; row-gap: 0; }
.work-card { min-width: 0; }
.work-card-inner { overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: 12px; }
.work-image { display: block; width: 100%; padding: 0; aspect-ratio: 4 / 3; overflow: hidden; border: 0; background: #edf0ed; cursor: zoom-in; }
.work-image img { width: 100%; height: 100%; object-fit: contain; }
.work-image:focus-visible { outline-offset: -4px; }
.image-unavailable { display: grid; place-items: center; color: var(--ink-soft); font-size: .8rem; }
.work-content { padding: 12px; }
.work-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; color: var(--ink-soft); font-size: .7rem; }
.work-content .work-meta { margin-top: 12px; }
.work-meta time { overflow-wrap: anywhere; }
.type-label { padding: .1rem .4rem; color: var(--navy); background: #e5f1f6; border-radius: 3px; font-weight: 700; }
.type-label.travel { color: #9a3c20; background: #fbe7df; }
.type-label.spark { color: #795012; background: #fff0c7; }
.work-card h3 { margin-bottom: 0; font-size: .98rem; line-height: 1.55; }
.record-open { display: -webkit-box; width: 100%; padding: 0; overflow: hidden; border: 0; background: transparent; text-align: left; font: inherit; font-weight: 700; cursor: pointer; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.record-open:hover { color: var(--navy); }
.work-card p { margin: 6px 0 0; color: var(--ink-soft); font-size: .83rem; }
.text-work { background: #f0f4f2; }
.text-work .work-content { padding: 20px 16px; }
.loading-state, .empty-state { grid-column: 1 / -1; min-height: 220px; padding: 2rem; display: grid; place-items: center; text-align: center; color: var(--ink-soft); border: 1px dashed #bdcaca; border-radius: 8px; background: #f8faf8; }
.empty-state p { margin-bottom: 0; }
.empty-state button { margin-top: .6rem; }
.empty-state { align-content: center; }
.work-card h3, .work-card p, .admin-post h3, .admin-post p { overflow-wrap: anywhere; }
.work-card p { white-space: pre-line; }

.site-footer { max-width: var(--max); margin: 0 auto; padding: 20px 24px; display: flex; justify-content: space-between; gap: 1rem; color: var(--ink-soft); font-size: .76rem; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-underline-offset: 4px; }

html:has(.record-dialog[open]) { overflow: hidden; }
.record-dialog { --dialog-gap: clamp(24px, 4svh, 40px); position: fixed; inset: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); margin: auto; width: min(960px, calc(100% - 2 * var(--dialog-gap))); max-height: calc(100svh - 2 * var(--dialog-gap) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 0; overflow: auto; overscroll-behavior: contain; color: var(--ink); background: var(--white); border: 0; border-radius: 16px; box-shadow: var(--shadow); }
.record-dialog::backdrop { background: rgba(9, 24, 36, .7); }
.dialog-close { position: sticky; top: 12px; z-index: 1; float: right; width: 40px; height: 40px; margin: 12px 12px -52px 0; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--white); cursor: pointer; }
.record-media { position: relative; height: min(60svh, 640px); background: #edf0ed; }
.record-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.record-media-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--ink-soft); font-size: .85rem; }
.record-spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--sky); border-radius: 50%; animation: record-spin .8s linear infinite; }
@keyframes record-spin { to { transform: rotate(360deg); } }
.record-content { padding: 28px; overflow-wrap: anywhere; }
.record-content h2 { margin: 0 44px 16px 0; font-size: 1.35rem; line-height: 1.5; }
.record-content .work-meta { justify-content: flex-start; gap: 1rem; }
.record-city { margin-bottom: 8px; color: var(--navy); font-size: 1.1rem; font-weight: 800; }
.record-gallery { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px 28px; color: var(--ink-soft); font-size: .8rem; }
.record-caption { margin: 16px 0 0; }
.city-record-dialog { width: min(1180px, calc(100% - 2 * var(--dialog-gap))); }
.city-gallery { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
.city-trip-picker { position: sticky; top: 0; max-height: calc(100svh - 2 * var(--dialog-gap) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 24px 16px; overflow-y: auto; overscroll-behavior: contain; }
.city-gallery-title { margin: 0 0 20px; font-size: 1.2rem; line-height: 1.5; overflow-wrap: anywhere; }
.city-gallery-viewer { min-width: 0; border-left: 1px solid var(--line); }
.city-trip-list { display: grid; gap: 8px; }
.city-trip-choice { width: 100%; min-width: 0; padding: 12px; text-align: left; background: var(--white); border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.city-trip-choice:hover { background: var(--cloud); }
.city-trip-choice[aria-pressed="true"] { color: var(--navy); background: #e5edf2; border-color: var(--line); }
.city-trip-copy { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.city-trip-copy strong { font-size: .9rem; }
.city-trip-copy > span { color: var(--ink-soft); font-size: .75rem; }
.city-trip-mobile { display: none; }

@media (max-width: 700px) {
  .city-gallery { grid-template-columns: minmax(0, 1fr); }
  .city-trip-picker { position: static; max-height: none; padding: 20px; overflow: visible; }
  .city-gallery-title { margin: 0 44px 12px 0; }
  .city-trip-list { display: none; }
  .city-trip-mobile { display: grid; }
  .city-trip-mobile select { font-size: 16px; }
  .city-gallery-viewer { border-left: 0; border-top: 1px solid var(--line); }
}

.admin-body { min-height: 100vh; background: var(--cloud); }
.admin-header { position: relative; color: var(--navy); background: var(--white); border-bottom: 1px solid var(--line); }
.quiet-action { color: var(--navy); font-weight: 800; text-decoration: underline; text-underline-offset: 4px; }
.button-reset { border: 0; background: transparent; cursor: pointer; }
.admin-main { width: min(1080px, calc(100% - 48px)); margin: 0 auto; padding: 70px 0 110px; }
.login-panel { max-width: 590px; margin: 7vh auto 0; padding: 3rem; background: var(--white); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.login-panel h1, .dashboard h1 { margin-bottom: .7rem; color: var(--navy); font-family: "STKaiti", "KaiTi", serif; font-size: 3.5rem; }
.login-form { margin-top: 2rem; }
.login-form > input { margin: .5rem 0 1.2rem; }
label { display: grid; gap: .5rem; color: var(--ink); font-size: .9rem; font-weight: 800; }
input, select { width: 100%; min-width: 0; min-height: 46px; padding: .7rem .8rem; color: var(--ink); background: var(--white); border: 1px solid #b9c7ca; border-radius: 4px; outline: none; }
input:focus, select:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(47,138,184,.14); }
input:read-only { background: var(--cloud); }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: .7rem; }
.compact-action { min-width: 86px; }
.form-message { min-height: 1.5rem; margin: .7rem 0 0; color: var(--coral); font-size: .86rem; white-space: pre-line; overflow-wrap: anywhere; }
.form-message.success { color: #2d705a; }
.dashboard-heading, .manage-heading { display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.dashboard-layout { margin-top: 2rem; }
.upload-panel { padding: 2rem; display: grid; gap: 1.2rem; background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.two-columns:has(> [hidden]) { grid-template-columns: 1fr; }
.editor-modes, .trip-photo-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
.trip-fields { display: grid; gap: 1rem; }
.trip-import { display: flex; align-items: flex-end; flex-wrap: wrap; gap: .75rem; }
.trip-import label { flex: 1 1 200px; min-width: 0; }
.trip-import button { min-height: 46px; }
.replace-photo { position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 4px; color: var(--navy); background: var(--white); cursor: pointer; font-size: .85rem; font-weight: 400; }
.replace-photo input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.replace-photo:focus-within { outline: 3px solid var(--sky); outline-offset: 4px; }
.file-picker { min-height: 112px; padding: 1.2rem; place-items: center; align-content: center; text-align: center; border: 1px dashed #9badb1; border-radius: 6px; background: #f7faf9; cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.file-picker-title { color: var(--navy); font-size: 1rem; }
.file-picker small { color: var(--ink-soft); font-weight: 400; }
.upload-items { display: grid; gap: 1.5rem; }
.upload-items:empty { display: none; }
.upload-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 1.5rem; padding-block: 1.5rem; border-top: 1px solid var(--line); }
.upload-item.metadata-incomplete { padding: 1.5rem 1rem; border: 1px solid #d5a13b; border-inline-start: 4px solid #b8750d; border-radius: 6px; background: #fffaf0; }
.metadata-warning { margin: 0; color: #87500a; font-size: .85rem; font-weight: 700; }
.upload-item-media, .upload-item-fields { min-width: 0; }
.upload-item-preview { width: 100%; max-height: 340px; object-fit: contain; border-radius: 6px; background: #eef2f1; }
.upload-item-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .6rem; font-size: .82rem; }
.upload-item-name { overflow-wrap: anywhere; color: var(--ink-soft); }
.upload-item-heading button { flex-shrink: 0; min-height: 40px; }
.upload-item-fields { display: grid; align-content: start; gap: 1rem; }
.upload-item-fields .form-message:empty { display: none; }
.photo-field { display: grid; gap: .5rem; }
.photo-checkbox { display: flex; align-items: center; gap: .5rem; min-height: 32px; font-weight: 400; font-size: .82rem; }
.photo-checkbox input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--navy); }
.metadata-hint { margin: 0; color: var(--ink-soft); font-size: .78rem; overflow-wrap: anywhere; }
.metadata-hint:empty { display: none; }
.city-picker { position: relative; display: grid; gap: .5rem; }
.city-results { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.city-results button { display: block; width: 100%; min-height: 44px; padding: .6rem .8rem; border: 0; background: none; font-size: .85rem; text-align: left; cursor: pointer; }
.city-results button:hover, .city-results button[aria-selected="true"] { color: var(--navy); background: #e5edf2; }
.submit-action { justify-self: start; }
.submit-actions, .post-actions { display: flex; align-items: center; gap: .75rem; }
.manage-section { margin-top: 4rem; }
.manage-heading h2 { font-size: 1.7rem; }
.manage-heading span { color: var(--ink-soft); }
.admin-posts { margin-top: 1.2rem; display: grid; gap: .7rem; }
.admin-post { min-height: 84px; padding: .8rem; display: grid; grid-template-columns: 92px 1fr auto; gap: 1rem; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: 6px; }
.admin-post-thumb { width: 92px; height: 64px; object-fit: cover; border-radius: 4px; background: #e9eeee; }
.admin-post-placeholder { display: grid; place-items: center; color: var(--sun); font-size: 1.5rem; }
.admin-post h3 { margin-bottom: .15rem; font-size: 1rem; }
.admin-post > div { min-width: 0; }
.admin-post p { margin: 0; color: var(--ink-soft); font-size: .82rem; }
.edit-button, .delete-button, .import-button { min-width: 48px; min-height: 40px; padding: .35rem .6rem; border: 1px solid #efc5b9; border-radius: 4px; color: #a9472b; background: #fff8f5; cursor: pointer; font-size: .85rem; }
.edit-button, .import-button { border-color: var(--line); color: var(--navy); background: var(--white); }
.delete-button:hover { background: #fde9e2; }
.admin-empty { padding: 2rem; color: var(--ink-soft); text-align: center; border: 1px dashed #bcc9c9; border-radius: 6px; }
.admin-empty button { margin-left: .5rem; }

@media (max-width: 1100px) {
  .work-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  h2 { font-size: 2.5rem; }
  .site-header { height: 68px; }
  .work-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  h2 { font-size: 2.2rem; }
  .site-header, .admin-header { padding-left: 18px; padding-right: 18px; }
  .brand { font-size: .86rem; }
  .site-header { height: auto; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 12px; padding: 18px 12px 0; }
  .site-header .brand { min-height: 32px; gap: .55rem; font-size: 1.05rem; letter-spacing: .04em; }
  .site-header .brand-mark { width: 30px; height: 30px; flex-shrink: 0; }
  .works-section { padding: 16px 12px 32px; scroll-margin-top: 120px; }
  .site-header .filter-bar { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
  .site-header .filter-button { position: relative; min-width: 44px; padding: .5rem .25rem .65rem; border-radius: 0; background: transparent; font-size: .875rem; }
  .site-header .filter-button.active { color: var(--navy); }
  .site-header .filter-button.active::after { content: ""; position: absolute; bottom: 0; left: calc(50% - 10px); width: 20px; height: 3px; border-radius: 3px 3px 0 0; background: var(--sun); }
  .travel-heading { align-items: flex-start; gap: 8px; }
  .travel-heading-copy { align-items: flex-start; flex-direction: column; gap: 5px; }
  .travel-heading h2 { font-size: 1.15rem; }
  .travel-map { height: 380px; border-radius: 12px; }
  .map-fit { font-size: .75rem; }
  .work-grid { column-gap: 12px; }
  .work-card-inner { border-radius: 10px; }
  .work-content { padding: 10px; }
  .work-card h3 { font-size: .9rem; }
  .work-card p { font-size: .78rem; }
  .work-meta { gap: .25rem; font-size: .64rem; }
  .type-label { padding: .1rem .3rem; }
  .text-work .work-content { padding: 16px 12px; }
  .site-footer { padding: 20px 18px; }
  .record-dialog { --dialog-gap: 20px; border-radius: 12px; }
  .record-content { padding: 20px; }
  .record-gallery { padding: 0 20px 20px; }
  .admin-main { width: calc(100% - 36px); padding-top: 42px; }
  .login-panel { margin-top: 2vh; padding: 1.5rem; }
  .login-panel h1, .dashboard h1 { font-size: 2.6rem; }
  .password-row, .two-columns { grid-template-columns: 1fr; }
  .dashboard-heading { align-items: flex-end; }
  .upload-panel { padding: 1.25rem; }
  .upload-item { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .upload-item-preview { max-height: 260px; }
  .submit-actions { flex-wrap: wrap; }
  .admin-post { grid-template-columns: 68px 1fr auto; gap: .7rem; }
  .admin-post-thumb { width: 68px; height: 56px; }
  .post-actions { flex-direction: column; gap: .4rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
