:root {
  color-scheme: dark;
  --bg: #090908;
  --panel: #171715;
  --panel-2: #22211d;
  --gold: #f0c956;
  --gold-soft: #ffe7a0;
  --text: #fff8e7;
  --muted: #b9b3a4;
  --line: rgba(240, 201, 86, .2);
  --danger: #7a2922;
  --shadow: 0 22px 60px rgba(0, 0, 0, .42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 70% -10%, rgba(240, 201, 86, .12), transparent 32rem), var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, .button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 7vw, 4.5rem); line-height: .95; letter-spacing: -.05em; }
h2 { margin-bottom: .4rem; font-size: clamp(1.55rem, 4vw, 2.5rem); }
h3 { margin-bottom: .45rem; }
.hidden { display: none !important; }
.eyebrow { margin-bottom: .45rem; color: var(--gold); font-weight: 900; font-size: .76rem; letter-spacing: .22em; }
.muted { color: var(--muted); line-height: 1.5; }
.grow { flex: 1 1 18rem; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(1.25rem, env(safe-area-inset-bottom)); }
.login-card { width: min(100%, 34rem); padding: clamp(1.5rem, 6vw, 3rem); border: 1px solid var(--line); border-radius: 34px; background: linear-gradient(145deg, rgba(35, 34, 30, .98), rgba(14, 14, 13, .99)); box-shadow: var(--shadow); }
.login-card > .muted { margin: 1rem 0 2rem; }
.brand-icon, .hero-icon { display: grid; place-items: center; color: #17150e; background: linear-gradient(145deg, var(--gold-soft), var(--gold)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.brand-icon { width: 4.25rem; height: 4.25rem; margin-bottom: 1.5rem; border-radius: 22px; font-size: 1.8rem; }
.text-link { display: block; margin-top: 1.5rem; color: var(--gold); text-align: center; }

.stack { display: grid; gap: 1rem; }
label { display: grid; gap: .5rem; color: var(--gold-soft); font-weight: 800; }
input, select { width: 100%; min-height: 3.25rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 16px; outline: 0; background: #10100f; color: var(--text); }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240, 201, 86, .12); }
.primary, .secondary, .danger, .button, .file-button { min-height: 3.25rem; padding: .8rem 1.15rem; border: 0; border-radius: 16px; font-weight: 900; text-align: center; text-decoration: none; }
.primary { background: linear-gradient(135deg, var(--gold-soft), var(--gold)); color: #18150c; }
.secondary, .button.secondary { border: 1px solid var(--line); background: #25241f; color: var(--gold-soft); }
.danger { background: var(--danger); color: #fff0e8; }
.compact { min-height: 2.8rem; padding: .65rem .9rem; }
.action-row { display: flex; flex-wrap: wrap; gap: .55rem; }

.app { min-height: 100vh; }
.site-header { width: min(100% - 2rem, 82rem); margin: 0 auto; padding: max(1.4rem, env(safe-area-inset-top)) 0 1.5rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.account-button { width: 3.1rem; height: 3.1rem; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; background: var(--panel-2); color: var(--gold); font-weight: 900; }
.content { width: min(100% - 2rem, 82rem); min-height: 65vh; margin: 0 auto; padding-bottom: 3rem; }
.hero-card, .create-card, .upload-card, .album-toolbar, .empty-card { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(34,33,29,.96), rgba(20,20,18,.98)); box-shadow: var(--shadow); }
.hero-card { display: flex; align-items: center; gap: clamp(1rem, 4vw, 2rem); padding: clamp(1.25rem, 4vw, 2.2rem); border-radius: 30px; }
.hero-card p:last-child { margin-bottom: 0; color: var(--muted); }
.hero-icon { width: 5rem; height: 5rem; flex: 0 0 auto; border-radius: 24px; font-size: 2rem; }
.create-card { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; margin: 1rem 0 1.4rem; padding: 1rem; border-radius: 24px; }

.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 1rem; }
.album-card { overflow: hidden; min-height: 18rem; padding: 0; border: 1px solid var(--line); border-radius: 26px; background: var(--panel); color: var(--text); text-align: left; box-shadow: var(--shadow); }
.album-cover { position: relative; height: 12rem; display: grid; place-items: center; overflow: hidden; background: linear-gradient(145deg, #2f2c23, #151513); color: var(--gold); font-size: 3rem; }
.album-cover img { width: 100%; height: 100%; object-fit: cover; }
.album-copy { padding: 1.1rem 1.2rem 1.3rem; }
.album-copy h2 { margin: 0 0 .35rem; font-size: 1.35rem; }
.album-copy p { margin: 0; color: var(--muted); }
.empty-card { padding: 3rem 1.5rem; border-radius: 28px; text-align: center; }
.empty-card > span { display: block; margin-bottom: .8rem; color: var(--gold); font-size: 3rem; }

.album-toolbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.2rem; padding: 1rem; border-radius: 26px; }
.album-heading h2, .album-heading p { margin-bottom: .2rem; }
.upload-card { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 1rem; margin: 1rem 0; padding: 1.25rem; border-radius: 26px; }
.upload-card p { margin-bottom: 0; }
.file-button { display: grid; place-items: center; background: #2a2923; color: var(--gold-soft); border: 1px dashed rgba(240,201,86,.5); cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.progress { grid-column: 1 / -1; padding-top: .4rem; }
.progress > div { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .55rem; color: var(--muted); }
progress { width: 100%; height: .7rem; border: 0; border-radius: 999px; overflow: hidden; background: #0e0e0d; }
progress::-webkit-progress-bar { background: #0e0e0d; }
progress::-webkit-progress-value { background: var(--gold); }
progress::-moz-progress-bar { background: var(--gold); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(42vw, 13rem), 1fr)); gap: .65rem; }
.photo-card { position: relative; aspect-ratio: 1 / 1; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); }
.photo-card img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .25s ease; }
.photo-card:active img { transform: scale(.98); }
.photo-label { position: absolute; inset: auto 0 0; padding: 2.2rem .7rem .65rem; background: linear-gradient(transparent, rgba(0,0,0,.78)); color: white; font-size: .78rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.load-more { width: 100%; margin-top: 1rem; }

dialog { width: min(calc(100% - 1rem), 42rem); max-height: min(90vh, 60rem); padding: 1.2rem; border: 1px solid var(--line); border-radius: 28px; background: #171715; color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(8px); }
.photo-dialog { width: min(calc(100% - 1rem), 62rem); }
.dialog-head, .viewer-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1rem; }
.icon-button { width: 2.8rem; height: 2.8rem; border: 1px solid var(--line); border-radius: 50%; background: #292821; color: var(--text); font-size: 1.5rem; }
.inline-card { padding: 1rem; border: 1px solid var(--line); border-radius: 20px; background: #10100f; }
.passkey-row { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.passkey-row:last-child { border-bottom: 0; }
.viewer-image-wrap { display: grid; place-items: center; min-height: 12rem; max-height: 62vh; overflow: hidden; border-radius: 20px; background: #090908; }
.viewer-image-wrap img { max-width: 100%; max-height: 62vh; object-fit: contain; }
.viewer-caption { margin: .8rem 0; white-space: pre-wrap; }
.caption-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: .7rem; margin: 1rem 0; }
.viewer-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }
.viewer-actions > * { flex: 1 1 12rem; }

footer { width: min(100% - 2rem, 82rem); margin: 0 auto; padding: 1rem 0 max(1.4rem, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: .7rem; color: var(--gold-soft); font-weight: 800; }
.online-dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--gold); box-shadow: 0 0 14px var(--gold); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); width: min(calc(100% - 2rem), 34rem); padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 16px; background: #24231f; color: var(--text); box-shadow: var(--shadow); transform: translate(-50%, 140%); opacity: 0; transition: .22s ease; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { border-color: rgba(255,110,90,.55); color: #ffd6d0; }

@media (max-width: 760px) {
  .site-header, .content, footer { width: min(100% - 1.2rem, 82rem); }
  .site-header { align-items: start; }
  .site-header h1 { font-size: 2.65rem; }
  .hero-card { align-items: flex-start; }
  .hero-icon { width: 4rem; height: 4rem; border-radius: 20px; }
  .album-toolbar { grid-template-columns: 1fr; }
  .album-toolbar > .compact { justify-self: start; }
  .upload-card { grid-template-columns: 1fr; }
  .upload-card > button, .file-button { width: 100%; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .caption-form { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .hero-card { display: block; }
  .hero-icon { margin-bottom: 1rem; }
  .photo-grid { gap: .45rem; }
  .photo-card { border-radius: 16px; }
}
