:root {
  --paper: #f7f7f5;
  --ink: #202321;
  --muted: #626861;
  --line: #dedfda;
  --control-line: #858a84;
  --accent: #b8e986;
  --white: #fff;
  --mono: "DM Mono", ui-monospace, monospace;
  --sans: "DM Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible, .photo-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.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; }
.form-error { flex-basis: 100%; margin: 7px 0 0; color: #9b4149; font-size: 11px; }

.topbar, .album-topbar { display: flex; align-items: center; justify-content: space-between; height: 72px; padding: 0 4.5vw; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 600; letter-spacing: -.06em; }
.brand-mark { display: grid; width: 18px; height: 18px; grid-template-columns: repeat(2, 1fr); gap: 2px; transform: rotate(-8deg); }
.brand-mark i { background: var(--ink); }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { background: #91c962; }

.home-main { width: min(1080px, 91vw); margin: 0 auto; }
.welcome { padding: 64px 0 52px; }
.kicker, .section-label, .album-meta { color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.kicker { margin: 0 0 24px; }
.home-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 38px; }
.primary-button, .upload-button { display: inline-flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 15px; background: var(--ink); color: var(--white); font-size: 11px; }
.primary-button span, .upload-button span { color: var(--accent); font-size: 16px; }
.join-form { display: flex; align-items: center; min-height: 38px; border: 1px solid var(--control-line); background: transparent; }
.join-form input { width: 210px; padding: 0 12px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.join-form input::placeholder { color: var(--muted); }
.join-form button { align-self: stretch; padding: 0 13px; border-left: 1px solid var(--control-line); background: transparent; color: var(--ink); font-size: 11px; }
.remembered { padding-bottom: 80px; }
.section-label { display: flex; align-items: center; gap: 12px; }
.section-line { width: 28px; height: 1px; background: var(--line); }
.album-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 16px; }
.album-card { position: relative; border: 1px solid var(--line); background: rgba(255,255,255,.22); }
.album-card:hover { background: var(--white); }
.album-card-open { display: block; }
.album-card-preview { display: grid; place-items: center; aspect-ratio: 1.45 / 1; background: linear-gradient(135deg, #d9e8c6, #e8e3d5 48%, #ccd8e0); background-position: center; background-size: cover; color: rgba(32,35,33,.5); font-family: var(--mono); font-size: 9px; text-transform: uppercase; }
.album-card-preview.has-image { color: transparent; }
.album-card h2 { margin: 0; padding: 15px 17px 17px; font-size: 15px; font-weight: 500; letter-spacing: -.03em; }
.delete-album { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 24px; height: 24px; background: rgba(32,35,33,.68); color: var(--white); font-size: 17px; line-height: 1; opacity: 0; transition: opacity .2s; }
.album-card:hover .delete-album, .delete-album:focus-visible { opacity: 1; }

.modal { position: fixed; z-index: 15; inset: 0; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 23, 21, .56); }
.modal-card { position: relative; z-index: 1; width: min(420px, 100%); padding: 28px; background: var(--paper); box-shadow: 0 20px 60px rgba(20,23,21,.2); }
.modal-card .kicker { margin: 0 0 13px; }
.modal-card h2 { margin: 0 0 20px; font-size: 25px; font-weight: 500; letter-spacing: -.05em; }
.modal-card input { width: 100%; min-height: 43px; padding: 0 12px; border: 1px solid var(--control-line); outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.modal-card input:focus { border-color: var(--ink); }
.modal-card label:not(.sr-only) { display: block; margin: 0 0 7px; color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.modal-card label:not(.sr-only) + input + label:not(.sr-only) { margin-top: 16px; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 17px; margin-top: 23px; }
.cancel-button { padding: 0; background: transparent; color: var(--muted); font-size: 11px; }

#home-view.has-albums .home-main { width: min(1220px, 91vw); }
#home-view.has-albums .welcome { display: grid; grid-template-columns: minmax(0, 1fr) 270px; align-items: end; gap: 60px; padding: 8vh 0 48px; border-bottom: 1px solid var(--line); }
#home-view.has-albums .kicker { margin: 0; }
#home-view.has-albums .home-actions { flex-direction: column; align-items: stretch; margin-top: 0; }
#home-view.has-albums .primary-button { justify-content: space-between; }
#home-view.has-albums .join-form { width: 100%; }
#home-view.has-albums .join-form input { width: 100%; }
#home-view.has-albums .remembered { padding: 34px 0 80px; }
#home-view.has-albums .section-label { color: var(--ink); }
#home-view.has-albums .album-list { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
#home-view.has-albums .album-card { min-height: 0; }
#home-view.has-albums .album-card h2 { font-size: 18px; }

.album-topbar { gap: 22px; }
.back-button, .share-button { padding: 0; background: transparent; color: var(--muted); font-size: 11px; }
.back-button span { margin-right: 5px; color: var(--ink); font-size: 16px; }
.album-heading { display: flex; align-items: center; gap: 9px; margin-right: auto; }
.album-heading h1 { max-width: 52vw; margin: 0; overflow: hidden; font-size: 14px; font-weight: 500; letter-spacing: -.03em; text-overflow: ellipsis; white-space: nowrap; }
.album-dot { width: 6px; height: 6px; background: var(--accent); }
.album-actions { display: flex; align-items: center; gap: 18px; }
.share-button span { margin-left: 4px; color: var(--ink); }
.download-button, .delete-button, .favorite-button { padding: 0; background: transparent; color: var(--muted); font-size: 10px; }
.download-button:hover, .favorite-button:hover { color: var(--ink); }
.delete-button { color: #a05d5d; }
.album-main { width: 96vw; margin: 0 auto; }
.album-meta { display: flex; gap: 8px; padding: 16px 0 2px; }
.meta-separator { color: var(--line); }
.album-content { display: grid; grid-template-columns: minmax(0, 1fr) 270px; align-items: start; gap: 18px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; padding: 14px 0 70px; }
.photo-card { position: relative; min-width: 0; cursor: pointer; animation: reveal .35s both; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.photo-card-image { overflow: hidden; aspect-ratio: 1 / 1; background: #e9eae5; }
.photo-card img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .4s cubic-bezier(.2,.7,.2,1); }
.photo-card:hover img { transform: scale(1.035); }
.photo-card.is-selected .photo-card-image { outline: 3px solid var(--accent); outline-offset: -3px; }
.photo-card.is-selected::after { position: absolute; top: 9px; right: 9px; display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; background: var(--accent); color: var(--ink); content: "✓"; font-size: 12px; font-weight: 600; }
.photo-credit { position: absolute; right: 8px; bottom: 8px; left: 8px; padding-top: 24px; background: linear-gradient(transparent, rgba(0,0,0,.56)); color: white; font-family: var(--mono); font-size: 9px; opacity: 0; transition: opacity .2s; }
.photo-card:hover .photo-credit, .photo-card:focus-within .photo-credit { opacity: 1; }
.photo-credit span { display: block; padding: 0 7px 7px; }
.empty-state { display: grid; justify-items: center; gap: 16px; padding: 80px 0; color: var(--muted); text-align: center; }
.empty-state p { margin: 0; }
.preview-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }
.lightbox-image-wrap.unsupported::after { content: "Preview unavailable — original can still be downloaded"; padding: 32px; color: var(--muted); font-family: var(--mono); font-size: 10px; text-align: center; text-transform: uppercase; }

.selection-panel { position: sticky; top: 14px; max-height: calc(100vh - 110px); overflow: hidden auto; border: 1px solid var(--line); background: var(--white); }
.selection-header { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--white); }
.selection-toggle { display: flex; align-items: center; gap: 10px; padding: 0; background: transparent; color: var(--ink); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }
.selection-toggle > span:last-child { display: none; }
.selection-clear { font-size: 10px; }
.selection-items { display: grid; gap: 8px; padding: 10px; }
.selection-item { display: grid; grid-template-columns: 48px minmax(0, 1fr) 24px; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.selection-item > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selection-preview { width: 48px; height: 48px; padding: 0; overflow: hidden; background: #e9eae5; }
.selection-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.selection-remove { width: 24px; height: 24px; padding: 0; background: transparent; color: var(--muted); font-size: 17px; }
.selection-remove:hover { color: var(--ink); }

.drop-overlay { position: fixed; z-index: 8; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; background: rgba(184, 233, 134, .16); transition: opacity .16s ease; }
.drop-overlay.visible { opacity: 1; }
.drop-message { display: flex; align-items: center; gap: 13px; padding: 16px 20px; border: 1px solid var(--ink); background: rgba(247, 247, 245, .93); color: var(--ink); font-size: 13px; box-shadow: 0 12px 40px rgba(32,35,33,.12); }
.drop-message span { font-size: 22px; }
.drop-message p { margin: 0; }

.lightbox { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 24px; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(20, 23, 21, .86); }
.lightbox-dialog { position: relative; z-index: 1; width: min(900px, 92vw); overflow: auto; background: var(--paper); }
.close-button { position: absolute; z-index: 2; top: 14px; right: 14px; display: grid; place-items: center; width: 30px; height: 30px; background: rgba(0,0,0,.55); color: white; font-size: 22px; line-height: 1; }
.lightbox-nav { position: absolute; z-index: 2; top: 50%; width: 34px; height: 42px; background: rgba(0,0,0,.5); color: white; font-size: 20px; transform: translateY(-50%); }
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }
.lightbox-image-wrap { display: grid; place-items: center; max-height: 75vh; min-height: 280px; background: #e8e8e3; }
.lightbox-image-wrap img { display: block; max-width: 100%; max-height: 75vh; object-fit: contain; transition: filter .18s ease; }
.lightbox-image-wrap img.is-low-res { filter: blur(2px); }
.lightbox-details { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 19px 23px 22px; }
.lightbox-details p { margin: 0; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.lightbox-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-family: var(--mono); font-size: 9px; text-transform: uppercase; }
.photo-actions { display: flex; align-items: center; gap: 15px; }
.favorite-button { color: var(--ink); }
.favorite-button.is-favorite { color: #b95e64; }
.favorite-button span { margin-left: 3px; }
.engagement { padding: 0 23px 23px; border-top: 1px solid var(--line); }
.local-note { margin: 13px 0 0; color: var(--muted); font-family: var(--mono); font-size: 9px; text-transform: uppercase; }
.reactions { display: flex; gap: 6px; padding: 13px 0; }
.reactions button { padding: 5px 8px; border: 1px solid var(--control-line); background: transparent; color: var(--ink); font-size: 12px; }
.reactions button.active { border-color: var(--accent); background: #effbdc; }
.reactions button span { margin-left: 3px; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.comment-form { display: flex; border-bottom: 1px solid var(--line); }
.comment-form input { flex: 1; padding: 9px 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.comment-form input::placeholder { color: var(--muted); }
.comment-form button { padding: 0 0 0 12px; background: transparent; color: var(--ink); font-size: 11px; }
.comments { display: grid; gap: 8px; padding-top: 12px; }
.comment { display: flex; gap: 8px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.comment strong { color: var(--ink); font-weight: 500; }
.toast { position: fixed; z-index: 20; right: 18px; bottom: 18px; padding: 11px 14px; background: var(--ink); color: var(--white); font-family: var(--mono); font-size: 10px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 850px) {
  .topbar, .album-topbar { padding: 0 4vw; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .topbar, .album-topbar { height: auto; min-height: 64px; padding: 14px 4vw; }
  .welcome { padding: 48px 0 40px; }
  .home-actions { align-items: stretch; flex-direction: column; }
  .home-actions, .primary-button, .join-form { width: 100%; }
  .primary-button { justify-content: center; }
  .join-form input { min-width: 0; width: 100%; }
  #home-view.has-albums .welcome { display: block; padding: 48px 0 34px; }
  #home-view.has-albums .home-actions { margin-top: 28px; }
  .album-topbar { align-items: center; flex-wrap: wrap; gap: 14px; }
  .album-heading { order: 3; width: 100%; }
  .album-actions { flex: 1; flex-wrap: wrap; justify-content: flex-end; min-width: 0; margin-left: auto; }
  .back-button, .share-button, .album-actions .download-button, .upload-button { display: inline-flex; min-height: 42px; align-items: center; padding: 8px 6px; border: 1px solid var(--control-line); color: var(--ink); }
  .album-actions .upload-button, .empty-state .upload-button { border-color: var(--ink); color: var(--white); }
  .album-actions { gap: 6px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; padding-top: 8px; }
  .album-content { display: block; }
  .selection-panel { position: fixed; z-index: 9; right: 12px; bottom: 12px; left: 12px; max-height: min(70vh, 520px); border-color: var(--ink); box-shadow: 0 12px 36px rgba(32,35,33,.18); }
  .selection-panel:not(.is-expanded) .selection-items { display: none; }
  .selection-toggle > span:last-child { display: block; font-size: 16px; transform: rotate(180deg); }
  .selection-panel.is-expanded .selection-toggle > span:last-child { transform: none; }
  .album-list { grid-template-columns: 1fr; }
  #home-view.has-albums .album-list { grid-template-columns: 1fr; }
  .delete-album { opacity: 1; width: 42px; height: 42px; border: 1px solid var(--control-line); }
  .lightbox-details { align-items: flex-start; flex-direction: column; padding: 16px; }
  .photo-actions { flex-wrap: wrap; }
  .close-button { width: 42px; height: 42px; }
  .lightbox-nav { width: 42px; height: 48px; }
  .photo-actions button, .reactions button, .comment-form input, .comment-form button { min-height: 42px; }
  .photo-actions button { padding: 8px 6px; }
}
