@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --paper: #f7f7f2;
  --surface: #ffffff;
  --ink: #171816;
  --muted: #666960;
  --line: #dedfd6;
  --soft: #efefe9;
  --lime: #d8f95d;
  --danger: #b73d30;
  --radius: 14px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
main { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
button, input { font: inherit; }
button { cursor: pointer; }
form { margin: 0; }
a { color: inherit; }

.site-header, header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-size: 20px; font-weight: 700; letter-spacing: -.05em; text-decoration: none; }
.brand img { width: 30px; height: 30px; }
nav { display: flex; align-items: center; gap: 18px; font: 12px "DM Mono", monospace; }
nav a { text-decoration: none; }
nav a:hover { text-decoration: underline; text-underline-offset: 4px; }
.username { color: var(--muted); }
.quiet { border: 0; padding: 0; background: transparent; color: var(--ink); font: 12px "DM Mono", monospace; }
.eyebrow { margin: 0; color: var(--muted); font: 500 11px/1.35 "DM Mono", monospace; letter-spacing: .07em; }
.page-lede { margin: 10px 0 0; max-width: 580px; color: var(--muted); font-size: 16px; line-height: 1.5; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(40px, 5vw, 64px); line-height: 1; letter-spacing: -.065em; }
h2 { letter-spacing: -.045em; }
.button, button:not(.quiet) { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; border: 1px solid var(--ink); border-radius: 9px; padding: 10px 15px; background: var(--ink); color: #fff; font-weight: 600; text-decoration: none; transition: background .16s, transform .16s; }
.button:hover, button:not(.quiet):hover { background: #33352f; transform: translateY(-1px); }
.error { color: var(--danger); font-size: 14px; }
.success { color: #3a6410; font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Landing */
.home-page main { min-height: 100vh; padding: 0 0 22px; }
.rays { display: none; }
.upload-stage { width: min(600px, 100%); margin: 0 auto; padding: 64px 0 38px; text-align: center; }
.hero-ghost { display: block; width: 92px; height: 92px; margin: 0 auto 18px; filter: drop-shadow(5px 6px 0 var(--lime)); }
.home-page h1 { font-size: clamp(58px, 8vw, 92px); text-transform: uppercase; }
h1 span { margin-left: .2em; }
.intro { margin: 22px auto 30px; max-width: 460px; color: var(--muted); line-height: 1.5; }
.upload-form { display: grid; gap: 12px; }
.drop-zone { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px dashed #93958d; border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; }
.drop-zone:hover { border-color: var(--ink); }
.drop-zone input, .compact-upload input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.drop-zone img { width: 44px; height: 44px; padding: 4px; border: 1px solid var(--ink); border-radius: 9px; background: var(--lime); }
.drop-zone #drop-ghost.hide { display: none; }
.upload-copy { flex: 1; min-width: 0; }
.drop-zone strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-zone small, .selected-count { display: block; margin-top: 4px; color: var(--muted); font: 11px "DM Mono", monospace; }
.preview-stack, .gallery-preview-stack { display: flex; align-items: center; }
.preview-stack img, .gallery-preview-stack img, .preview-stack b, .gallery-preview-stack b { width: 31px; height: 31px; margin-left: -7px; border: 1px solid var(--ink); border-radius: 7px; object-fit: cover; background: var(--lime); }
.preview-stack img:first-child, .gallery-preview-stack img:first-child { margin-left: 0; }
.preview-stack b, .gallery-preview-stack b { display: grid; place-items: center; font: 10px "DM Mono", monospace; }
.home-page footer { display: flex; justify-content: space-between; gap: 30px; border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); font: 11px/1.5 "DM Mono", monospace; }
.home-page footer p { max-width: 720px; margin: 0; }
.home-page footer span { color: var(--ink); white-space: nowrap; }

/* Authentication and settings */
.account-page main { padding-bottom: 48px; }
.account-shell { display: grid; grid-template-columns: minmax(250px, .8fr) minmax(340px, 1fr); margin: 60px auto 0; max-width: 940px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.account-note { padding: 42px; background: var(--lime); }
.account-note img { width: 70px; height: 70px; margin-bottom: 35px; }
.account-note h1, .card h2 { margin: 0; font-size: clamp(38px, 4vw, 56px); line-height: .92; letter-spacing: -.07em; text-transform: uppercase; }
.account-note > p:last-child { margin: 24px 0 0; line-height: 1.45; }
.card { padding: 42px; }
.card h2 { margin: 8px 0 28px; font-size: 42px; text-transform: none; }
.card label { display: block; margin: 16px 0; font-size: 14px; font-weight: 600; }
.card input, .new-folder input { display: block; width: 100%; min-height: 44px; margin-top: 7px; padding: 10px 12px; border: 1px solid #bfc1b8; border-radius: 8px; background: #fff; color: var(--ink); }
.card input:focus, .new-folder input:focus { outline: 2px solid var(--lime); outline-offset: 1px; border-color: var(--ink); }
.card button { width: 100%; margin: 12px 0; }
.account-switch { color: var(--muted); }
.settings-list { display: grid; gap: 8px; }
.settings-list a, .settings-list span { padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 14px; }
.settings-list a:hover { color: #4f6e08; }
.settings-form { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }

/* Gallery: Explore surface */
.app-shell { padding-bottom: 58px; }
.gallery-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 28px; padding: 52px 0 28px; }
.gallery-toolbar h1, .admin-heading h1 { margin-top: 8px; }
.compact-upload { display: flex; align-items: center; gap: 10px; min-width: 370px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.file-picker { flex: 1; min-width: 115px; cursor: pointer; }
.compact-title { font-size: 14px; font-weight: 600; }
.compact-upload .selected-count { margin: 0; white-space: nowrap; }
.compact-upload button { min-height: 39px; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.folder-panel { display: flex; align-items: end; justify-content: space-between; gap: 22px; padding: 20px 0 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.folder-copy { min-width: 0; }
.folder-hint { margin: 6px 0 12px; color: var(--muted); font-size: 14px; }
.folder-list { display: flex; flex-wrap: wrap; gap: 8px; }
.folder-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; }
.folder-row .quiet { color: var(--muted); font-size: 11px; }
.folder-row .quiet:hover { color: var(--ink); text-decoration: underline; }
.folder-empty { color: var(--muted); font-size: 14px; }
.new-folder { display: flex; flex: 0 0 300px; gap: 8px; }
.new-folder input { min-width: 0; margin: 0; }
.new-folder button { flex: none; min-height: 44px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; padding-top: 26px; }
.media-card { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.media-card > a { display: block; background: var(--soft); }
.grid img { display: block; width: 100%; aspect-ratio: 1 / .8; object-fit: cover; }
.media-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 11px; }
.media-card-foot p { overflow: hidden; margin: 0; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.danger { min-width: 29px; min-height: 29px; border-color: #e5bbb6 !important; border-radius: 7px !important; padding: 0 !important; background: #fff7f6 !important; color: var(--danger) !important; font-size: 18px !important; }
.empty-gallery { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 22px; min-height: 230px; margin-top: 26px; padding: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.empty-gallery img { width: 70px; height: 70px; padding: 7px; border: 1px solid var(--ink); border-radius: 12px; background: var(--lime); }
.empty-gallery h2 { margin: 5px 0 7px; font-size: 25px; }
.empty-gallery p:last-child { margin: 0; color: var(--muted); }

/* Admin: Operate surface */
.admin-heading { padding: 52px 0 28px; }
.admin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.admin-grid article { padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.admin-grid p { margin: 0 0 18px; color: var(--muted); font: 11px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .05em; }
.admin-grid strong { display: block; font-size: 38px; line-height: 1; letter-spacing: -.06em; }
.admin-grid span { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; }
.admin-users { margin-top: 24px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.section-heading { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.section-heading p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.admin-table-head, .admin-user-row { display: grid; grid-template-columns: minmax(190px, 1.4fr) 1fr 1fr 90px; gap: 16px; align-items: center; padding: 12px 18px; }
.admin-table-head { color: var(--muted); font: 11px "DM Mono", monospace; border-bottom: 1px solid var(--line); }
.admin-user-row { min-height: 58px; border-bottom: 1px solid var(--line); font-size: 14px; }
.admin-user-row:last-child { border-bottom: 0; }
.admin-user-name { color: var(--ink); font-weight: 600; text-decoration: none; }
.admin-user-name:hover { text-decoration: underline; text-underline-offset: 4px; }
.admin-user-name small { margin-left: 5px; color: var(--muted); font: 11px "DM Mono", monospace; }
.admin-detail-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; }
.admin-section { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.admin-section .section-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.admin-section .section-heading strong { font-size: 28px; letter-spacing: -.05em; }
.admin-folder-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 18px 18px; }
.admin-folder-list span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font-size: 13px; }
.admin-empty { margin: 0; padding: 18px; color: var(--muted); font-size: 14px; }
.password-panel form { padding: 16px 18px 6px; }
.password-panel label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.password-panel input { width: 100%; min-height: 44px; border: 1px solid #bfc1b8; border-radius: 8px; padding: 10px 12px; }
.password-panel input:focus { outline: 2px solid var(--lime); outline-offset: 1px; border-color: var(--ink); }
.password-panel button { width: 100%; margin-top: 10px; }
.password-panel .error, .password-panel .success { margin: 12px 18px 18px; }
.admin-media-section { margin-top: 16px; }
.admin-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; padding: 16px 18px 18px; }
.admin-media-card { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); text-decoration: none; }
.admin-media-card:hover { border-color: var(--ink); }
.admin-media-card img { display: block; width: 100%; aspect-ratio: 1 / .8; object-fit: cover; }
.admin-media-card span { display: block; overflow: hidden; padding: 8px 9px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; color: var(--muted); font: 11px "DM Mono", monospace; font-weight: 500; }
.badge-admin { border-color: #bdcf77; background: #f2f8d8; color: #45570d; }
.badge-on { border-color: #b7d7bd; background: #f1faf3; color: #326b3c; }
.badge-off { border-color: #ebc0b9; background: #fff3f1; color: #963c2e; }
.danger-text { color: var(--danger) !important; font-size: 12px; }
.danger-text:hover { text-decoration: underline; }

/* 404 */
.not-found-page { display: grid; min-height: 100vh; place-items: center; }
.not-found-shell { width: min(640px, calc(100% - 48px)); }
.not-found-shell > .brand { margin-bottom: 74px; }
.not-found-content { max-width: 520px; }
.not-found-content > img { width: 82px; height: 82px; margin-bottom: 24px; padding: 8px; border: 1px solid var(--ink); border-radius: 13px; background: var(--lime); }
.not-found-content h1 { margin: 9px 0 15px; }
.not-found-content p { max-width: 420px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.not-found-content .button { margin-top: 12px; }

@media (max-width: 720px) {
  main { width: min(100% - 32px, 1180px); }
  .site-header, header { min-height: 64px; }
  nav { gap: 10px; font-size: 11px; }
  .gallery-toolbar, .folder-panel { display: grid; align-items: start; }
  .gallery-toolbar { padding: 38px 0 22px; }
  .gallery-toolbar h1, .admin-heading h1 { font-size: 42px; }
  .compact-upload { width: 100%; min-width: 0; }
  .folder-panel { gap: 16px; }
  .new-folder { width: 100%; flex-basis: auto; }
  .empty-gallery { grid-template-columns: 1fr; min-height: 0; }
  .admin-heading { padding: 38px 0 22px; }
  .admin-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-table-head { display: none; }
  .admin-user-row { grid-template-columns: 1fr auto; gap: 8px; }
  .admin-user-row > :nth-child(2), .admin-user-row > :nth-child(3) { grid-column: 1; }
  .admin-detail-grid { grid-template-columns: 1fr; }
  .admin-media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-shell { grid-template-columns: 1fr; margin-top: 32px; }
  .account-note { padding: 28px; }
  .card { padding: 28px; }
  .home-page footer { display: grid; gap: 9px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
