:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #111;
  color: #eee;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.topbar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: rgb(17 17 17 / 92%); backdrop-filter: blur(8px); border-bottom: 1px solid #292929; }
.topbar-context { display: flex; align-items: center; gap: 20px; min-width: 0; }
.primary-nav { display: flex; gap: 4px; }
.primary-nav a { padding: 7px 10px; border-radius: 5px; color: #aaa; text-decoration: none; }
.primary-nav a:hover, .primary-nav a:focus-visible { color: #fff; background: #242424; }
.primary-nav a[aria-current="page"] { color: #fff; background: #303030; }
.topbar button { border: 0; background: transparent; color: #aaa; cursor: pointer; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.tags-menu { position: relative; color: #ccc; font-size: .9rem; }
.tags-menu summary { cursor: pointer; }
.month-tags { position: absolute; top: calc(100% + 12px); right: 0; display: grid; gap: 5px; width: max-content; min-width: 180px; max-height: 60vh; overflow: auto; padding: 10px; border: 1px solid #444; border-radius: 6px; background: #1b1b1b; box-shadow: 0 8px 28px rgb(0 0 0 / 45%); }
.month-tags button { padding: 7px 9px; border-radius: 4px; text-align: left; background: #292929; color: #eee; }
.month-tags p { padding: 6px; color: #888; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.2rem; }
.status-line { display: flex; gap: 9px; margin-top: 3px; min-height: 1.2em; color: #aaa; font-size: .85rem; }
#current-month { color: #ddd; font-weight: 600; }
#status::before { content: '·'; margin-right: 9px; }
#status:empty::before { content: ''; margin-right: 0; }
.gallery { max-width: 1800px; margin: 0 auto; padding: 18px; }
.month { margin-bottom: 34px; scroll-margin-top: 64px; }
.month-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.month h2 { color: #bbb; font-size: 1rem; font-weight: 600; }
.month-tag-button { padding: 3px 7px; border: 0; border-radius: 3px; background: #292929; color: #aaa; cursor: pointer; font-size: .78rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 3px; }
.photo { position: relative; aspect-ratio: 1; overflow: hidden; padding: 0; border: 0; background: #222; cursor: pointer; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .15s ease; }
.photo:hover img, .photo:focus-visible img { transform: scale(1.04); }
.photo:focus-visible { outline: 2px solid #66aaff; outline-offset: 2px; }
.video-badge { position: absolute; right: 7px; bottom: 7px; display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: rgb(0 0 0 / 68%); color: #fff; font-size: .8rem; }
.sentinel { height: 1px; }
.login-dialog { width: min(360px, calc(100vw - 32px)); border: 1px solid #444; border-radius: 8px; background: #1c1c1c; color: #eee; }
.login-dialog::backdrop { background: rgb(0 0 0 / 65%); }
.login-dialog form { display: grid; gap: 14px; }
.login-dialog label { display: grid; gap: 5px; color: #ccc; font-size: .9rem; }
.login-dialog input { padding: 9px; border: 1px solid #555; border-radius: 4px; background: #111; color: #fff; }
.login-dialog button { padding: 9px; border: 0; border-radius: 4px; background: #4789d9; color: #fff; font: inherit; cursor: pointer; }
.login-dialog button:disabled { cursor: wait; opacity: .6; }
#login-error { min-height: 1.2em; margin: 0; color: #ff9c9c; font-size: .9rem; }
.viewer { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0; overflow: hidden; border: 0; background: rgb(0 0 0 / 96%); }
.viewer::backdrop { background: #000; }
.viewer img, .viewer video { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewer img { cursor: zoom-in; will-change: transform; }
.viewer [hidden] { display: none; }
.viewer-capture-time { position: fixed; top: 16px; left: 16px; z-index: 2; padding: 8px 10px; border-radius: 4px; background: rgb(0 0 0 / 58%); color: #fff; font-size: .9rem; font-variant-numeric: tabular-nums; pointer-events: none; }
.viewer-button, .download { position: fixed; z-index: 2; border: 0; border-radius: 4px; color: #fff; background: rgb(0 0 0 / 58%); font: inherit; cursor: pointer; }
.viewer-button { padding: 8px 14px; font-size: 2rem; line-height: 1; }
.viewer-button:disabled { visibility: hidden; }
.close { top: 14px; right: 16px; }
.previous { top: 50%; left: 12px; transform: translateY(-50%); }
.next { top: 50%; right: 12px; transform: translateY(-50%); }
.download { right: 16px; bottom: 16px; padding: 9px 12px; text-decoration: none; font-size: .9rem; }
.viewer-actions { position: fixed; left: 16px; bottom: 16px; z-index: 2; display: flex; gap: 8px; }
.map-photo, .share-photo, .delete-photo { padding: 9px 12px; border: 0; border-radius: 4px; color: #fff; font: inherit; cursor: pointer; }
.map-photo { background: #3f704d; text-decoration: none; }
.share-photo { background: #3978c4; }
.delete-photo { background: #9f3030; }
.viewer.showing-video .download, .viewer.showing-video .viewer-actions { bottom: 80px; }
.share-photo:disabled, .delete-photo:disabled { cursor: wait; opacity: .6; }
.files-view { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }
.files-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.files-heading h1 { font-size: 1.45rem; }
.files-status { min-height: 1.3em; margin-top: 5px; color: #aaa; font-size: .9rem; }
.file-upload-form { display: flex; align-items: center; gap: 9px; }
.file-upload-form input[type="file"] { max-width: min(420px, 50vw); color: #bbb; }
.file-upload-form input[type="file"]::file-selector-button, .file-upload-form button, .load-more-files { padding: 8px 11px; border: 1px solid #4a4a4a; border-radius: 5px; background: #292929; color: #eee; font: inherit; cursor: pointer; }
.file-upload-form input[type="file"]::file-selector-button { margin-right: 9px; }
.file-upload-form button { border-color: #4789d9; background: #3978c4; }
.file-upload-form button:disabled, .file-upload-form input:disabled, .load-more-files:disabled { cursor: wait; opacity: .6; }
.files-table-wrapper { overflow-x: auto; border: 1px solid #303030; border-radius: 7px; }
.files-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.files-table th, .files-table td { padding: 12px 14px; border-bottom: 1px solid #2b2b2b; text-align: left; vertical-align: middle; }
.files-table th { color: #aaa; background: #1a1a1a; font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.files-table td { color: #bbb; font-variant-numeric: tabular-nums; }
.files-table tbody tr:last-child td { border-bottom: 0; }
.files-table tbody tr:hover:not(.empty-files) { background: #181818; }
.file-name { max-width: 440px; overflow: hidden; color: #f1f1f1; text-overflow: ellipsis; white-space: nowrap; }
.file-name a { display: block; overflow: hidden; color: inherit; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.file-name a:hover, .file-name a:focus-visible { color: #8fc2ff; text-decoration: underline; }
.file-size { white-space: nowrap; }
.file-actions { display: flex; justify-content: flex-end; gap: 8px; white-space: nowrap; }
.file-actions button { padding: 6px 9px; border: 1px solid #4a4a4a; border-radius: 4px; background: #272727; color: #ddd; font: inherit; font-size: .85rem; cursor: pointer; }
.file-actions .delete-file { border-color: #703838; color: #ffb4b4; }
.file-actions button:disabled { cursor: wait; opacity: .6; }
.empty-files td { padding: 40px 14px; color: #888; text-align: center; }
.load-more-files { display: block; margin: 18px auto 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 700px) {
  .topbar { align-items: flex-start; gap: 10px; padding: 10px; }
  .topbar-context { align-items: flex-start; flex-direction: column; gap: 4px; }
  .files-view { padding: 18px 10px 36px; }
  .files-heading { align-items: stretch; flex-direction: column; }
  .file-upload-form { align-items: stretch; flex-direction: column; }
  .file-upload-form input[type="file"] { max-width: 100%; }
}
@media (max-width: 500px) {
  .gallery { padding: 10px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 2px; }
  .viewer-capture-time { top: 8px; left: 8px; padding: 7px 9px; font-size: .82rem; }
  .viewer-actions { left: 8px; gap: 4px; }
  .map-photo, .share-photo, .delete-photo, .download { padding: 7px 9px; font-size: .82rem; }
  .download { right: 8px; }
  .viewer.showing-video .download, .viewer.showing-video .viewer-actions { bottom: 8px; }
}
