*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #1a73e8;
  --blue-dark: #1557b0;
  --gray: #5f6368;
  --border: #e8eaed;
  --bg: #f8f9fa;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: #202124;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ── Login ── */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-logo { margin-bottom: 4px; }

.login-wrap h1 { font-size: 26px; font-weight: 600; }

.subtitle { color: var(--gray); font-size: 15px; margin-bottom: 8px; }

#login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input {
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  outline: none;
  background: white;
  transition: border-color .15s;
}

#login-form input:focus { border-color: var(--blue); }

#login-btn {
  padding: 15px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}

#login-btn:active { background: var(--blue-dark); }
#login-btn:disabled { opacity: .6; cursor: default; }

.error { color: #d93025; font-size: 14px; text-align: center; }

/* ── App layout ── */

#app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: white;
  border-bottom: 1px solid var(--border);
}

header span { font-size: 17px; font-weight: 600; }

#logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray);
  display: flex;
  padding: 4px;
}

/* ── Tabs ── */

.tab-pane {
  padding: 16px 16px 96px;
  flex: 1;
}

.section-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
}

/* ── Album grid ── */

.album-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.album-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  cursor: pointer;
  position: relative;
  aspect-ratio: 4/3;
  transition: transform .1s;
  -webkit-user-select: none;
  user-select: none;
}

.album-card:active { transform: scale(.96); }

.album-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-thumb-placeholder {
  position: absolute;
  inset: 0;
  background: var(--border);
}

.album-footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 24px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  color: white;
}

.album-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.album-count { font-size: 12px; opacity: .85; margin-top: 1px; }

.album-skeleton {
  aspect-ratio: 4/3;
  background: var(--border);
  border-radius: var(--radius);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* ── Upload progress ── */

#upload-status {
  margin-top: 20px;
  padding: 16px;
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

.progress-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}

#upload-bar {
  background: var(--blue);
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width .3s ease;
}

#upload-msg {
  font-size: 14px;
  color: var(--gray);
  text-align: center;
}

/* ── Photo feed ── */

.feed-pane {
  padding: 0 0 96px !important;
  background: var(--bg);
}

#feed-grid {
  background: var(--bg);
}

.feed-section { margin-bottom: 4px; }

.feed-date {
  padding: 16px 16px 8px;
  font-size: 14px;
  font-weight: 600;
  color: #202124;
  background: var(--bg);
  letter-spacing: .1px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.photo-cell {
  aspect-ratio: 1;
  background: var(--border);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.photo-owner {
  position: absolute;
  bottom: 5px;
  left: 5px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,.45);
  padding: 2px 6px;
  border-radius: 10px;
  pointer-events: none;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

.photo-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feed-empty {
  padding: 64px 16px;
  text-align: center;
  color: var(--gray);
  font-size: 15px;
}

/* Lightbox */
#lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: white;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
  opacity: .8;
}

/* ── Bottom nav ── */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: white;
  border-top: 1px solid var(--border);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 11px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray);
  font-size: 11px;
  font-weight: 500;
  transition: color .15s;
}

.nav-btn.active { color: var(--blue); }
.nav-btn.active svg { stroke: var(--blue); }
