:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e7eaf0;
  --muted: #98a1b3;
  --accent: #4f7cff;
  --accent-hover: #3d68e6;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must always win over class rules that set an
   explicit `display` (e.g. .status/.user use display:flex). Without this,
   hidden sections like the loading spinner never actually hide. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand-mark { color: var(--accent); font-size: 1.2rem; }
.brand-name { letter-spacing: 0.2px; }
.user { display: flex; align-items: center; gap: 14px; }
.user-name { color: var(--muted); font-size: 0.92rem; }

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: #262b36; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }

/* Main */
.main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 40px 28px; }

/* Hero */
.hero { text-align: center; padding: 80px 20px; }
.hero h1 { font-size: 2.2rem; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 28px; font-size: 1.05rem; }

/* Gallery */
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.gallery-head h1 { font-size: 1.5rem; margin: 0; }
.search {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.92rem;
  min-width: 220px;
}
.search:focus { outline: none; border-color: var(--accent); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.tile:hover { transform: translateY(-3px); border-color: var(--accent); background: var(--surface-2); }
.tile-icon { font-size: 1.8rem; line-height: 1; }
.tile-body { flex: 1; }
.tile-title { font-weight: 600; font-size: 1.05rem; margin-bottom: 4px; }
.tile-desc { color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.tile-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chip {
  font-size: 0.72rem;
  color: var(--accent);
  background: rgba(79, 124, 255, 0.12);
  border: 1px solid rgba(79, 124, 255, 0.3);
  padding: 3px 8px;
  border-radius: 999px;
}
.owner { font-size: 0.72rem; color: var(--muted); }

.empty { color: var(--muted); text-align: center; padding: 40px; }

/* Status / spinner */
.status { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 80px 20px; color: var(--muted); }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Notice */
.notice { text-align: center; padding: 60px 20px; color: var(--muted); }
.notice code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; color: var(--text); }

/* Footer */
.footer { text-align: center; padding: 20px; color: var(--muted); font-size: 0.82rem; border-top: 1px solid var(--border); }
